@akanjs/devkit 3.2.0-rc.2 → 3.2.0-rc.21

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 (365) hide show
  1. package/CHANGELOG.md +350 -11
  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 +257 -1
  7. package/akanApp/akanApp.host.ts +146 -1223
  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/devHostPolicy.test.ts +11 -11
  17. package/akanApp/devHostPolicy.ts +2 -4
  18. package/akanApp/devIdleSuspend.test.ts +221 -0
  19. package/akanApp/devIdleSuspend.ts +192 -0
  20. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  21. package/akanApp/devRecycler.test.ts +66 -0
  22. package/akanApp/devRecycler.ts +305 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +24 -1
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiDeclarationPrinter.ts +120 -0
  29. package/apiReport/apiReport.test.ts +526 -0
  30. package/apiReport/apiReport.ts +232 -0
  31. package/apiReport/apiReportDiff.ts +160 -0
  32. package/apiReport/apiReportPolicy.ts +65 -0
  33. package/apiReport/apiTargets.ts +311 -0
  34. package/apiReport/changesetBump.ts +19 -0
  35. package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
  36. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
  37. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
  38. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
  39. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  40. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
  41. package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
  42. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  43. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  44. package/artifact/implicitRootLayout.test.ts +71 -3
  45. package/artifact/implicitRootLayout.ts +21 -4
  46. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  47. package/biome.base.json +2 -1
  48. package/cloud/cloudApi.test.ts +1 -1
  49. package/cloud/configLock.test.ts +1 -1
  50. package/cloud/globalConfig.test.ts +1 -1
  51. package/cloud/globalConfig.ts +1 -1
  52. package/cloud/updatePackUpload.test.ts +1 -1
  53. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  54. package/codeAgent/agent/akanCodePaths.ts +1 -1
  55. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  56. package/codeAgent/agent/codeAgent.test.ts +1 -1
  57. package/codeAgent/skills/akan-debug/SKILL.md +10 -3
  58. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  59. package/codeAgent/skills/akan-mcp/SKILL.md +13 -2
  60. package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
  61. package/codeAgent/skills/akan-transport/SKILL.md +2 -0
  62. package/codeAgent/skills/akan-validate/SKILL.md +1 -0
  63. package/codeAgent/tools/AkanCli.ts +1 -1
  64. package/codeAgent/tools/AkanToolPack.ts +1 -1
  65. package/codeAgent/tools/McpClient.ts +28 -6
  66. package/codeAgent/tools/McpToolPack.ts +1 -1
  67. package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
  68. package/commandDecorators/argMeta.ts +4 -0
  69. package/commandDecorators/cliError.ts +72 -0
  70. package/commandDecorators/command.ts +165 -91
  71. package/commandDecorators/commandBuilder.ts +1 -1
  72. package/commandDecorators/commandDecorators.test.ts +191 -16
  73. package/commandDecorators/exitCodeError.ts +6 -7
  74. package/commandDecorators/index.ts +1 -0
  75. package/commandDecorators/targetMeta.ts +1 -0
  76. package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
  77. package/commandDecorators/workspaceVersionCheck.ts +1 -1
  78. package/context/akanContext.ts +576 -0
  79. package/context/akanContextInspection.ts +296 -0
  80. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  81. package/{akanMcpContract.ts → context/akanMcpContract.ts} +33 -263
  82. package/context/akanMcpToolError.ts +16 -0
  83. package/context/doctor/agentGuideCheck.ts +81 -0
  84. package/context/doctor/configLeftoverCheck.ts +35 -0
  85. package/context/doctor/doctorFindings.ts +70 -0
  86. package/context/doctor/generatedFreshness.ts +56 -0
  87. package/context/doctor/moduleShapeCheck.ts +88 -0
  88. package/context/doctor/recipeDuplicateCheck.ts +39 -0
  89. package/context/doctor/recipeIndexCheck.ts +87 -0
  90. package/context/doctor/rootShapeCheck.ts +55 -0
  91. package/context/doctor/workflowScope.ts +97 -0
  92. package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
  93. package/context/moduleFieldNames.ts +25 -0
  94. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  95. package/context/safeRead.ts +9 -0
  96. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  97. package/devkitUtils.test.ts +39 -5
  98. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  99. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  100. package/docs/errorCodeReference.test.ts +282 -0
  101. package/docs/errorCodeReference.ts +71 -0
  102. package/docs/errorCodeScan.ts +551 -0
  103. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  104. package/executors/appExecutor.ts +448 -0
  105. package/executors/commandExecutionError.ts +53 -0
  106. package/executors/executor.ts +527 -0
  107. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  108. package/{executors.test.ts → executors/executors.test.ts} +76 -15
  109. package/executors/index.ts +8 -0
  110. package/executors/libExecutor.ts +23 -0
  111. package/executors/moduleExecutor.ts +18 -0
  112. package/executors/pkgExecutor.ts +129 -0
  113. package/executors/sysExecutor.ts +301 -0
  114. package/executors/workspaceExecutor.ts +277 -0
  115. package/frontendBuild/allRoutesBuilder.test.ts +17 -5
  116. package/frontendBuild/allRoutesBuilder.ts +24 -6
  117. package/frontendBuild/autoImportSync.test.ts +1 -1
  118. package/frontendBuild/autoImportSync.ts +1 -1
  119. package/frontendBuild/buildRouteClient.test.ts +1 -1
  120. package/frontendBuild/bundleDefine.ts +2 -0
  121. package/frontendBuild/clientBuildTypes.ts +5 -2
  122. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  123. package/frontendBuild/clientEntryDiscovery.test.ts +58 -0
  124. package/frontendBuild/clientEntryDiscovery.ts +25 -6
  125. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  126. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  127. package/frontendBuild/cssCompiler.test.ts +1 -1
  128. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  129. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  130. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  131. package/frontendBuild/fontOptimizer.test.ts +1 -1
  132. package/frontendBuild/fontPruner.test.ts +1 -1
  133. package/frontendBuild/frontendBuild.test.ts +3 -3
  134. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  135. package/frontendBuild/hmrWatcher.test.ts +1 -1
  136. package/frontendBuild/hmrWatcher.ts +22 -1
  137. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  138. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  139. package/frontendBuild/nativeCore.test.ts +148 -0
  140. package/frontendBuild/optionalPeers.test.ts +36 -8
  141. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  142. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  143. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  144. package/frontendBuild/precompressArtifacts.ts +1 -1
  145. package/frontendBuild/serverGraphFile.ts +1 -1
  146. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  147. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
  148. package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
  149. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  150. package/frontendBuild/vendorImportScanner.test.ts +25 -4
  151. package/frontendBuild/vendorImportScanner.ts +25 -10
  152. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  153. package/frontendBuild/watchRootResolver.test.ts +1 -1
  154. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  155. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  156. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  157. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  158. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  159. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  160. package/{prompter.ts → guideline/prompter.ts} +2 -3
  161. package/incrementalBuilder/buildBatch.proc.ts +14 -4
  162. package/incrementalBuilder/buildBatchProtocol.ts +2 -0
  163. package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
  164. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  165. package/incrementalBuilder/builderBoot.ts +106 -0
  166. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  167. package/incrementalBuilder/builderChannel.test.ts +1 -1
  168. package/incrementalBuilder/builderChannel.ts +11 -0
  169. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  170. package/incrementalBuilder/builderLanes.ts +157 -0
  171. package/incrementalBuilder/builderWatch.ts +213 -0
  172. package/incrementalBuilder/csrRegistry.ts +234 -0
  173. package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
  174. package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
  175. package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
  176. package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
  177. package/incrementalBuilder/ssrRegistry.ts +278 -0
  178. package/index.ts +22 -22
  179. package/integration/devStability.integration.test.ts +62 -56
  180. package/integration/devStabilityHarness.test.ts +1 -1
  181. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  182. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  183. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  184. package/lint/gritRules.test.ts +1 -1
  185. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  186. package/lint/no-import-common-err.grit +31 -0
  187. package/lint/no-init-fetch-in-client.grit +1 -1
  188. package/lint/no-web-only-api-outside-webkit.grit +3 -3
  189. package/mobile/desktopBin.test.ts +1 -1
  190. package/mobile/desktopRelease.test.ts +1 -1
  191. package/mobile/desktopServerStage.test.ts +2 -2
  192. package/mobile/desktopServerStage.ts +1 -1
  193. package/mobile/nativeApi.test.ts +1 -1
  194. package/mobile/nativeApp.test.ts +1 -1
  195. package/mobile/nativeConfig.test.ts +1 -1
  196. package/mobile/nativePluginFolders.test.ts +1 -1
  197. package/mobile/nativePublicEnv.test.ts +1 -1
  198. package/mobile/nativeWebDir.test.ts +1 -1
  199. package/mobile/serverBundleSecrets.test.ts +1 -1
  200. package/mobile/tarWriter.test.ts +1 -1
  201. package/mobile/updatePackFolder.test.ts +1 -1
  202. package/package.json +167 -3
  203. package/packageExports.test.ts +20 -2
  204. package/piDependencyPins.test.ts +1 -1
  205. package/pipeline/PipelineDefinition.ts +1 -1
  206. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  207. package/platformTest/PlatformTestRun.test.ts +1 -1
  208. package/platformTest/TestSnapshot.test.ts +1 -1
  209. package/preview/PreviewView.ts +32 -11
  210. package/preview/previewView.test.ts +76 -9
  211. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  212. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  213. package/quality/bareErrorScanner.ts +126 -0
  214. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  215. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  216. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  217. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  218. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  219. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  220. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  221. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  222. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
  223. package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
  224. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  225. package/{subspace.test.ts → subspace/subspace.test.ts} +9 -3
  226. package/{subspace.ts → subspace/subspace.ts} +5 -5
  227. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  228. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  229. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  230. package/transforms/barrelAnalyzer.ts +26 -8
  231. package/transforms/browserDirnamePlugin.test.ts +1 -1
  232. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  233. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  234. package/transforms/pureLazyMarker.test.ts +1 -1
  235. package/transforms/serverEnvPlugin.test.ts +1 -1
  236. package/transforms/serverEnvProfile.test.ts +1 -1
  237. package/transforms/sideEffectImportOrder.test.ts +1 -1
  238. package/transforms/transforms.test.ts +29 -2
  239. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  240. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  241. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  242. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  243. package/typecheck/projectTypecheck.test.ts +1 -1
  244. package/typecheck/projectTypecheck.ts +6 -2
  245. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  246. package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
  247. package/typecheck/typecheck.proc.ts +4 -3
  248. package/typecheck/typecheckFailure.ts +7 -2
  249. package/util/errorReport.ts +66 -0
  250. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  251. package/workflow/artifacts.ts +8 -7
  252. package/workflow/constantSource.ts +187 -0
  253. package/workflow/dictionarySource.ts +184 -0
  254. package/workflow/executor.ts +6 -9
  255. package/workflow/fieldExpression.ts +153 -0
  256. package/workflow/fieldLabel.ts +61 -0
  257. package/workflow/fieldOrder.ts +117 -0
  258. package/workflow/fieldType.ts +93 -0
  259. package/workflow/guardCatalog.test.ts +1 -1
  260. package/workflow/index.ts +2 -0
  261. package/workflow/keyRename.ts +1 -1
  262. package/workflow/moduleIndex.test.ts +2 -2
  263. package/workflow/moduleIndex.ts +2 -2
  264. package/workflow/modulePaths.ts +27 -0
  265. package/workflow/mutationScaffold.ts +7 -15
  266. package/workflow/mutationSource.ts +2 -1
  267. package/workflow/plainName.ts +28 -0
  268. package/workflow/plan.ts +15 -9
  269. package/workflow/primitiveReport.ts +78 -0
  270. package/workflow/rolloutGate.test.ts +1 -1
  271. package/workflow/rolloutGate.ts +1 -1
  272. package/workflow/serviceSource.ts +33 -0
  273. package/workflow/signalSource.ts +96 -0
  274. package/workflow/source.ts +50 -1105
  275. package/workflow/sourceAst.ts +30 -0
  276. package/workflow/sourceImports.ts +105 -0
  277. package/workflow/sourceText.ts +13 -0
  278. package/workflow/templateSource.ts +30 -0
  279. package/workflow/testSource.ts +31 -0
  280. package/workflow/types.ts +1 -1
  281. package/workflow/uiPolicy.ts +1 -1
  282. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  283. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  284. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  285. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  286. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  287. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  288. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  289. package/{libSource.ts → workspace/libSource.ts} +1 -1
  290. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  291. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  292. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  293. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +85 -1
  294. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +41 -6
  295. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  296. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  297. package/akanContext.ts +0 -1084
  298. package/constantFieldNames.ts +0 -18
  299. package/executors.ts +0 -1749
  300. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  301. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  302. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  303. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  304. /package/{linter.ts → lint/linter.ts} +0 -0
  305. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  306. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  307. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  308. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  309. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  310. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  311. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  312. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  313. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  314. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  315. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  316. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  317. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  318. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  319. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  320. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  321. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  322. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  323. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  324. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  325. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  326. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  327. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  328. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  329. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  330. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  331. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  332. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  333. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  334. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  335. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  336. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  337. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  338. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  339. /package/{writePath.ts → quality/writePath.ts} +0 -0
  340. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  341. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  342. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  343. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  344. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  345. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  346. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  347. /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
  348. /package/{fileSys.ts → util/fileSys.ts} +0 -0
  349. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  350. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  351. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  352. /package/{semver.ts → util/semver.ts} +0 -0
  353. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  354. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  355. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  356. /package/{spinner.ts → util/spinner.ts} +0 -0
  357. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  358. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  359. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  360. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  361. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  362. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  363. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  364. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  365. /package/{types.ts → workspace/types.ts} +0 -0
@@ -129,7 +129,43 @@ export const writeJson = async (filePath: string, value: object) => {
129
129
  await writeText(filePath, `${JSON.stringify(value, null, 2)}\n`);
130
130
  };
131
131
 
132
- const repoRoot = path.resolve(import.meta.dir, "../../..");
132
+ export const heldMtimeIndex = () => {
133
+ const primes: PromiseWithResolvers<void>[] = [];
134
+ const scans: PromiseWithResolvers<string[]>[] = [];
135
+ class SourceMtimeIndex {
136
+ #primed = false;
137
+ readonly trackedFileCount = 0;
138
+ readonly coverageGaps: { path: string; code: string }[] = [];
139
+ readonly hasUnsettledDirs = false;
140
+ get primed() {
141
+ return this.#primed;
142
+ }
143
+ async prime() {
144
+ const gate = Promise.withResolvers<void>();
145
+ primes.push(gate);
146
+ await gate.promise;
147
+ this.#primed = true;
148
+ }
149
+ collectChanges() {
150
+ const scan = Promise.withResolvers<string[]>();
151
+ scans.push(scan);
152
+ return scan.promise;
153
+ }
154
+ }
155
+ return { SourceMtimeIndex, primes, scans };
156
+ };
157
+
158
+ //? FSEvents drops what lands before its stream is up, so the save repeats until the watcher has acted on one.
159
+ export const saveUntil = async (file: string, seen: () => boolean, timeoutMs = 5_000) => {
160
+ const deadline = Date.now() + timeoutMs;
161
+ for (let n = 0; !seen() && Date.now() < deadline; n++) {
162
+ await writeFile(file, `export const x = ${n};\n`);
163
+ await new Promise((resolve) => setTimeout(resolve, 50));
164
+ }
165
+ return seen();
166
+ };
167
+
168
+ const repoRoot = path.resolve(import.meta.dir, "../../../..");
133
169
  const biomeBin = path.join(repoRoot, "node_modules", ".bin", process.platform === "win32" ? "biome.exe" : "biome");
134
170
  export const hasBiome = existsSync(biomeBin);
135
171
 
@@ -38,6 +38,12 @@ const LOCAL_NAMED_RE = /(?:^|\n)\s*export\s+\{\s*([^}]*?)\s*\}(?!\s*from)/g;
38
38
 
39
39
  const CANDIDATE_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
40
40
 
41
+ interface BarrelWalk {
42
+ visited: Set<string>;
43
+ read: Set<string>;
44
+ following: Set<string>;
45
+ }
46
+
41
47
  export class BarrelAnalyzer {
42
48
  readonly #logger = new Logger("BarrelAnalyzer");
43
49
  readonly #opts: BarrelAnalyzerOptions;
@@ -96,7 +102,7 @@ export class BarrelAnalyzer {
96
102
  const map: BarrelExportMap = new Map();
97
103
  const read = new Set<string>();
98
104
  this.#read.set(pkgName, read);
99
- await this.#walk(pkg.entryFile, pkg, map, read);
105
+ await this.#walk(pkg.entryFile, pkg, map, { visited: new Set(), read, following: new Set([pkg.entryFile]) });
100
106
  return map;
101
107
  } catch (err) {
102
108
  this.#logger.error(`analyze failed for ${pkgName}: ${(err as Error).message}`);
@@ -104,9 +110,10 @@ export class BarrelAnalyzer {
104
110
  }
105
111
  }
106
112
 
107
- async #walk(absFile: string, pkg: PackageEntry, map: BarrelExportMap, visited: Set<string>): Promise<void> {
108
- if (visited.has(absFile)) return;
109
- visited.add(absFile);
113
+ async #walk(absFile: string, pkg: PackageEntry, map: BarrelExportMap, walk: BarrelWalk): Promise<void> {
114
+ if (walk.visited.has(absFile)) return;
115
+ walk.visited.add(absFile);
116
+ walk.read.add(absFile);
110
117
  const file = Bun.file(absFile);
111
118
  if (!(await file.exists())) return;
112
119
  const source = await file.text();
@@ -119,11 +126,12 @@ export class BarrelAnalyzer {
119
126
  authoritative.delete("default");
120
127
 
121
128
  const attributed = new Set<string>();
122
- const attribute = (listBody: string, subpath: string) => {
129
+ const attribute = (listBody: string, subpath: string, source?: BarrelExportMap | null) => {
123
130
  for (const item of parseNamedList(listBody)) {
124
131
  if (item.isType || item.imported === "default" || !authoritative.has(item.local)) continue;
125
132
  attributed.add(item.local);
126
- if (!map.has(item.local)) map.set(item.local, { subpath, originalName: item.imported });
133
+ if (map.has(item.local)) continue;
134
+ map.set(item.local, source?.get(item.imported) ?? { subpath, originalName: item.imported });
127
135
  }
128
136
  };
129
137
 
@@ -152,7 +160,7 @@ export class BarrelAnalyzer {
152
160
  const targetAbs = await this.#resolveRel(absFile, spec);
153
161
  if (!targetAbs) continue;
154
162
  const targetSubpath = this.#subpathFor(pkg, targetAbs);
155
- if (targetSubpath) attribute(namedList, targetSubpath);
163
+ if (targetSubpath) attribute(namedList, targetSubpath, await this.#exportsOf(targetAbs, pkg, walk));
156
164
  }
157
165
  }
158
166
 
@@ -172,10 +180,20 @@ export class BarrelAnalyzer {
172
180
 
173
181
  for (const spec of starSpecs) {
174
182
  const targetAbs = await this.#resolveRel(absFile, spec);
175
- if (targetAbs) await this.#walk(targetAbs, pkg, map, visited);
183
+ if (targetAbs) await this.#walk(targetAbs, pkg, map, walk);
176
184
  }
177
185
  }
178
186
 
187
+ //? A name re-exported by name from a barrel is mapped to the file that declares it, as a star walk would map it:
188
+ //? a rewrite to the barrel itself would load every module behind it.
189
+ async #exportsOf(absFile: string, pkg: PackageEntry, walk: BarrelWalk): Promise<BarrelExportMap | null> {
190
+ if (walk.following.has(absFile)) return null;
191
+ const map: BarrelExportMap = new Map();
192
+ const following = new Set([...walk.following, absFile]);
193
+ await this.#walk(absFile, pkg, map, { visited: new Set(), read: walk.read, following });
194
+ return map;
195
+ }
196
+
179
197
  #scanExports(source: string, absFile: string): Set<string> {
180
198
  try {
181
199
  const transpiler = [".tsx", ".jsx"].includes(path.extname(absFile)) ? this.#tsxTranspiler : this.#tsTranspiler;
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { realpathSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { tempDirs, writeText } from "../testHelpers";
4
+ import { tempDirs, writeText } from "../test/testHelpers";
5
5
  import { createBrowserDirnamePlugin } from "./browserDirnamePlugin";
6
6
 
7
7
  const makeTempRoot = tempDirs("akan-devkit-browser-dirname-");
@@ -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 { createExternalizeFrameworkPlugin } from "./externalizeFrameworkPlugin";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-devkit-externalize-");
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { symlink } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { tempDirs, writeText } from "../testHelpers";
4
+ import { tempDirs, writeText } from "../test/testHelpers";
5
5
  import { createBarrelImportsPlugin } from "./barrelImportsPlugin";
6
6
  import { McpAppPageTrimmer } from "./mcpAppPageTrimmer";
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { tempDirs, writeText } from "../testHelpers";
3
+ import { tempDirs, writeText } from "../test/testHelpers";
4
4
  import { PureLazyMarker } from "./pureLazyMarker";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-pure-lazy-");
@@ -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 { createServerEnvPlugin } from "./serverEnvPlugin";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-devkit-server-env-");
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
3
  import { Logger } from "akanjs/common";
4
- import { tempDirs, writeText as write } from "../testHelpers";
4
+ import { tempDirs, writeText as write } from "../test/testHelpers";
5
5
  import { ServerEnvProfile } from "./serverEnvProfile";
6
6
 
7
7
  const makeTempRoot = tempDirs("akan-devkit-server-env-profile-");
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { tempDirs, writeText } from "../testHelpers";
3
+ import { tempDirs, writeText } from "../test/testHelpers";
4
4
  import { SideEffectImportOrder } from "./sideEffectImportOrder";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-devkit-side-effect-order-");
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
- import { ApplicationBuildReporter } from "../applicationBuildReporter";
5
- import { tempDirs, writeText as write } from "../testHelpers";
4
+ import { ApplicationBuildReporter } from "../app/applicationBuildReporter";
5
+ import { tempDirs, writeText as write } from "../test/testHelpers";
6
6
  import { BarrelAnalyzer, type BarrelExportTarget } from "./barrelAnalyzer";
7
7
  import { createTsconfigPackageResolver, rewriteBarrelImports } from "./barrelImportsPlugin";
8
8
  import {
@@ -209,6 +209,33 @@ describe("BarrelAnalyzer and rewriteBarrelImports", () => {
209
209
  expect(map?.get("OnlyA")).toEqual({ subpath: "@scope/pkg/a", originalName: "OnlyA" });
210
210
  });
211
211
 
212
+ test("a name re-exported by name from a sub-barrel maps to the file that declares it", async () => {
213
+ const root = await makeTempRoot();
214
+ const pkgDir = path.join(root, "pkg");
215
+ await write(
216
+ path.join(pkgDir, "index.ts"),
217
+ 'export { A, Bee as B2 } from "./sub";\nexport { C } from "./cycleA";\n',
218
+ );
219
+ await write(path.join(pkgDir, "sub", "index.ts"), 'export * from "./a";\nexport { B as Bee } from "./b";\n');
220
+ await write(path.join(pkgDir, "sub", "a.ts"), "export const A = 1;\n");
221
+ await write(path.join(pkgDir, "sub", "b.ts"), "export const B = 2;\n");
222
+ await write(path.join(pkgDir, "cycleA.ts"), 'export { C } from "./cycleB";\n');
223
+ await write(path.join(pkgDir, "cycleB.ts"), 'export { C } from "./cycleA";\n');
224
+ const analyzer = new BarrelAnalyzer({
225
+ resolvePackage: async () => ({ pkgName: "@scope/pkg", entryFile: path.join(pkgDir, "index.ts"), pkgDir }),
226
+ });
227
+
228
+ const map = await analyzer.analyze("@scope/pkg");
229
+ expect(map?.get("A")).toEqual({ subpath: "@scope/pkg/sub/a", originalName: "A" });
230
+ expect(map?.get("B2")).toEqual({ subpath: "@scope/pkg/sub/b", originalName: "B" });
231
+ expect(map?.get("C")).toEqual({ subpath: "@scope/pkg/cycleA", originalName: "C" });
232
+ expect(
233
+ (await analyzer.filesOf("@scope/pkg"))
234
+ .map((file) => path.relative(pkgDir, file))
235
+ .sort((a, b) => a.localeCompare(b)),
236
+ ).toEqual(["cycleA.ts", "cycleB.ts", "index.ts", "sub/a.ts", "sub/b.ts", "sub/index.ts"]);
237
+ });
238
+
212
239
  test("two analyses that interleave each keep their own place in their barrel", async () => {
213
240
  const root = await makeTempRoot();
214
241
  const barrels = { first: ["a1", "a2", "a3"], second: ["b1", "b2"] } as const;
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { mkdir, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { tempDirs } from "../testHelpers";
4
+ import { tempDirs } from "../test/testHelpers";
5
5
  import { createTsconfigPackageResolver } from "./barrelImportsPlugin";
6
6
 
7
7
  const makeTempRoot = tempDirs("akan-devkit-resolver-");
@@ -3,9 +3,9 @@ import { readFile, stat, writeFile } from "node:fs/promises";
3
3
  import type { AddressInfo } from "node:net";
4
4
  import path from "node:path";
5
5
  import { Client, type Connection, Server, utils } from "ssh2";
6
+ import { createTempApp, isolateEnv, tempRoots } from "../test/testHelpers";
6
7
  import { createTunnel } from "./createTunnel";
7
8
  import { SshHostKeys } from "./sshHostKeys";
8
- import { createTempApp, isolateEnv, tempRoots } from "./testHelpers";
9
9
 
10
10
  const freePort = () => {
11
11
  const listener = Bun.listen({ hostname: "127.0.0.1", port: 0, socket: { data() {} } });
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import type { ConnectConfig } from "ssh2";
3
- import { type AppExecutor, WorkspaceExecutor } from "./executors";
4
- import { ShellOnlyEnv } from "./shellOnlyEnv";
3
+ import { type AppExecutor, WorkspaceExecutor } from "../executors";
4
+ import { ShellOnlyEnv } from "../util/shellOnlyEnv";
5
5
  import { SshHostKeys } from "./sshHostKeys";
6
6
  import { createSshTunnel } from "./sshTunnel";
7
7
 
@@ -1,8 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { mkdir, rm, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { ConfigLock } from "./cloud/configLock";
5
- import { FileSys } from "./fileSys";
4
+ import { ConfigLock } from "../cloud/configLock";
5
+ import { FileSys } from "../util/fileSys";
6
6
 
7
7
  type KnownHosts = Record<string, string>;
8
8
 
@@ -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 { ProjectTypecheck } from "./projectTypecheck";
5
5
  import { TypecheckFailure } from "./typecheckFailure";
6
6
 
@@ -1,6 +1,7 @@
1
1
  import { mkdir, rm } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import type { TypecheckRecord } from "../typeChecker";
3
+ import { CliError } from "../commandDecorators/cliError";
4
+ import type { TypecheckRecord } from "./typeChecker";
4
5
  import { TypecheckFailure } from "./typecheckFailure";
5
6
 
6
7
  export interface ProjectTypecheckOptions {
@@ -69,7 +70,10 @@ export class ProjectTypecheck {
69
70
  if (exitCode === 0) return;
70
71
  const records = report === "records" ? ProjectTypecheck.#parseRecords(stdout) : null;
71
72
  if (records?.length) throw new TypecheckFailure(records);
72
- throw new Error((stderr || stdout).trim() || `Typecheck failed with exit code ${exitCode}`);
73
+ const output = (stderr || stdout).trim();
74
+ if (exitCode === TypecheckFailure.workerExitCode && report === "pretty")
75
+ throw new CliError("checkFailed", output || "Typecheck failed");
76
+ throw new Error(output || `Typecheck failed with exit code ${exitCode}`);
73
77
  }
74
78
 
75
79
  static #parseRecords(stdout: string): TypecheckRecord[] | null {
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
3
  import * as ts from "typescript";
4
- import { tempDirs, writeJson, writeText } from "./testHelpers";
4
+ import { tempDirs, writeJson, writeText } from "../test/testHelpers";
5
5
  import { TypeChecker } from "./typeChecker";
6
6
 
7
7
  const makeTempRoot = tempDirs("akan-devkit-type-checker-");
@@ -3,7 +3,7 @@ import * as path from "node:path";
3
3
  import chalk from "chalk";
4
4
  import * as ts from "typescript";
5
5
 
6
- import type { Executor } from "./executors";
6
+ import type { Executor } from "../executors";
7
7
 
8
8
  export interface ProjectTypecheckResult {
9
9
  configPath: string;
@@ -1,5 +1,6 @@
1
1
  import { Logger } from "akanjs/common";
2
- import { TypeChecker } from "../typeChecker";
2
+ import { TypeChecker } from "./typeChecker";
3
+ import { TypecheckFailure } from "./typecheckFailure";
3
4
 
4
5
  try {
5
6
  const filePath = process.env.AKAN_TYPECHECK_FILE;
@@ -28,11 +29,11 @@ try {
28
29
  //? Not process.cwd(): that is the realpath (/private/var on macOS) while TypeScript keeps the spelling it was given.
29
30
  const root = process.env.AKAN_TYPECHECK_ROOT ?? process.cwd();
30
31
  process.stdout.write(JSON.stringify(TypeChecker.toRecords(result.errors, root)));
31
- process.exit(result.errors.length > 0 ? 1 : 0);
32
+ process.exit(result.errors.length > 0 ? TypecheckFailure.workerExitCode : 0);
32
33
  }
33
34
  if (result.errors.length > 0) {
34
35
  console.error(result.message);
35
- process.exit(1);
36
+ process.exit(TypecheckFailure.workerExitCode);
36
37
  }
37
38
  } catch (error) {
38
39
  console.error(error instanceof Error ? error.message : String(error));
@@ -1,8 +1,13 @@
1
- import type { TypecheckRecord } from "../typeChecker";
1
+ import { CliError } from "../commandDecorators/cliError";
2
+ import type { TypecheckRecord } from "./typeChecker";
3
+
4
+ export class TypecheckFailure extends CliError<"checkFailed"> {
5
+ //? The worker's exit when the project has type errors, so its crash, which exits 1, is told apart.
6
+ static readonly workerExitCode = 3;
2
7
 
3
- export class TypecheckFailure extends Error {
4
8
  constructor(readonly records: TypecheckRecord[]) {
5
9
  super(
10
+ "checkFailed",
6
11
  records
7
12
  .slice(0, 20)
8
13
  .map((record) => `${record.file ?? "-"}:${record.line}:${record.col} ${record.code} ${record.message}`)
@@ -0,0 +1,66 @@
1
+ import { realpathSync } from "node:fs";
2
+ import path from "node:path";
3
+
4
+ export class ErrorReport {
5
+ static readonly shownNestedErrors = 20;
6
+
7
+ static format(error: unknown, workspaceRoot = process.cwd()): string {
8
+ return ErrorReport.#format(error, workspaceRoot, []);
9
+ }
10
+
11
+ static #format(error: unknown, workspaceRoot: string, ancestors: readonly unknown[]): string {
12
+ if (ancestors.includes(error)) return "[circular]";
13
+ const chain = [...ancestors, error];
14
+ if (error instanceof AggregateError) {
15
+ const shown = error.errors.slice(0, ErrorReport.shownNestedErrors);
16
+ const hidden = error.errors.length - shown.length;
17
+ const nestedMessages = [
18
+ ...shown.map(
19
+ (nestedError, index) =>
20
+ ErrorReport.#format(nestedError, workspaceRoot, chain).trim() || `Unknown error ${index + 1}`,
21
+ ),
22
+ ...(hidden > 0 ? [`…and ${hidden} more`] : []),
23
+ ]
24
+ .map((message) => message.replace(/^/gm, " "))
25
+ .join("\n");
26
+ const message = nestedMessages ? `${error.message}\n${nestedMessages}` : error.message;
27
+ return `${message}${ErrorReport.#causeOf(error, workspaceRoot, chain)}`;
28
+ }
29
+ if (error instanceof Error)
30
+ return `${ErrorReport.#withLocation(error.message, error, workspaceRoot)}${ErrorReport.#causeOf(error, workspaceRoot, chain)}`;
31
+ if (typeof error === "object" && error !== null && "message" in error)
32
+ return ErrorReport.#withLocation(String(error.message), error, workspaceRoot);
33
+ return String(error);
34
+ }
35
+
36
+ static #causeOf(error: Error, workspaceRoot: string, chain: readonly unknown[]): string {
37
+ return error.cause ? `\nCaused by: ${ErrorReport.#format(error.cause, workspaceRoot, chain)}` : "";
38
+ }
39
+
40
+ static #withLocation(message: string, error: object, workspaceRoot: string): string {
41
+ const { position } = error as { position?: { file: string; line: number; column: number } | null };
42
+ if (!position?.file) return message;
43
+ const file = ErrorReport.#relativeToWorkspace(position.file, workspaceRoot);
44
+ const location = position.line > 0 ? `${file}:${position.line}:${position.column}` : file;
45
+ return message.includes(location) ? message : message.replace(/^.*/, (headline) => `${headline} (${location})`);
46
+ }
47
+
48
+ // Bun names the file by its realpath, so a workspace root reached through a symlink is matched by its own too.
49
+ static #relativeToWorkspace(file: string, workspaceRoot: string): string {
50
+ if (!path.isAbsolute(file)) return file;
51
+ for (const root of [workspaceRoot, ErrorReport.#realpathOf(workspaceRoot)]) {
52
+ const relative = path.relative(root, file);
53
+ if (!relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))
54
+ return relative.replaceAll(path.sep, "/");
55
+ }
56
+ return file;
57
+ }
58
+
59
+ static #realpathOf(dir: string): string {
60
+ try {
61
+ return realpathSync(dir);
62
+ } catch {
63
+ return dir;
64
+ }
65
+ }
66
+ }
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import { formatWithBiome, hasBiome } from "../test/testHelpers";
2
3
  import { JsonFormatter } from "./jsonFormatter";
3
- import { formatWithBiome, hasBiome } from "./testHelpers";
4
4
 
5
5
  const pad = (length: number) => "x".repeat(length);
6
6
  const thousands = Array.from({ length: 40 }, (_, idx) => idx * 1000);
@@ -95,11 +95,11 @@ export const createWorkflowApplyReport = ({
95
95
  postApplyChecks?: WorkflowApplyReport["postApplyChecks"];
96
96
  recommendations?: WorkflowApplyReport["recommendations"];
97
97
  }): WorkflowApplyReport => {
98
- const validationCommands = recommendedValidationCommands ?? commands;
99
- const nextActionsWithIntent = nextActions.map((action) => ({
100
- ...action,
101
- action: inferNextActionCode(action, diagnostics),
102
- }));
98
+ const status = workflowStatus(diagnostics);
99
+ const validationCommands = status === "failed" ? [] : (recommendedValidationCommands ?? commands);
100
+ const nextActionsWithIntent = nextActions
101
+ .map((action) => ({ ...action, action: inferNextActionCode(action, diagnostics) }))
102
+ .filter((action) => status !== "failed" || action.action !== "validate");
103
103
  if (sourceChangeBlocked(diagnostics) && !nextActionsWithIntent.some((action) => action.action === "blocked")) {
104
104
  nextActionsWithIntent.unshift({
105
105
  command: `akan workflow explain ${workflow}`,
@@ -111,12 +111,13 @@ export const createWorkflowApplyReport = ({
111
111
  (left, right) => nextActionPriority(left, diagnostics) - nextActionPriority(right, diagnostics),
112
112
  );
113
113
  const sourceFilesChanged = uniqueBy(changedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
114
- const generatedFilesSynced = uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
114
+ const generatedFilesSynced =
115
+ status === "failed" ? [] : uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
115
116
  return {
116
117
  schemaVersion: 1,
117
118
  workflow,
118
119
  mode,
119
- status: workflowStatus(diagnostics),
120
+ status,
120
121
  summary: {
121
122
  sourceFilesChanged,
122
123
  generatedFilesSynced,