@akanjs/devkit 3.2.0-rc.3 → 3.2.0-rc.31

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 +369 -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 +17 -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} +32 -262
  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 +28 -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 -13
  210. package/preview/previewView.test.ts +33 -3
  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} +25 -4
  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 +31 -10
  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 +52 -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 +1 -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 +16 -3
  268. package/workflow/plan.ts +14 -2
  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} +1 -1
  294. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
  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
@@ -1,7 +1,7 @@
1
1
  import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { AppExecutor, LibExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
4
- import { makeCliTempWorkspace, tempRoots, writeText } from "../testHelpers";
3
+ import { AppExecutor, LibExecutor, ModuleExecutor, PkgExecutor, WorkspaceExecutor } from "../executors";
4
+ import { makeCliTempWorkspace, tempRoots, writeText } from "../test/testHelpers";
5
5
  import {
6
6
  App,
7
7
  type ArgMeta,
@@ -476,6 +476,19 @@ describe("a Sys that defaults to the only app", () => {
476
476
  if (!meta) throw new Error(`no Sys meta on ${key}`);
477
477
  return meta;
478
478
  };
479
+ const track = tempRoots();
480
+ const moduleWorkspace = async () => {
481
+ const { root, workspace } = track(await makeCliTempWorkspace());
482
+ for (const [sys, name] of [
483
+ ["apps/web", "card"],
484
+ ["libs/util", "photo"],
485
+ ] as const) {
486
+ await writeText(path.join(root, sys, "akan.config.ts"), "export default {};\n");
487
+ await writeText(path.join(root, sys, "lib", name, `${name}.constant.ts`), "export {};\n");
488
+ }
489
+ await writeText(path.join(root, "apps/web/lib/_billing/billing.service.ts"), "export {};\n");
490
+ return workspace;
491
+ };
479
492
 
480
493
  test("the opted-in command takes a one-app workspace's app without asking, even on a piped stdin", async () => {
481
494
  setTTY(undefined);
@@ -525,19 +538,24 @@ describe("a Sys that defaults to the only app", () => {
525
538
  expect(asked).toEqual([]);
526
539
  });
527
540
 
528
- test("without a terminal, the only lib, pkg or module is not taken, as a command may be removing it", async () => {
541
+ test("without a terminal, a command that deletes nothing takes the only lib, pkg or module; a terminal is asked", async () => {
529
542
  setTTY(undefined);
530
543
  const workspace = workspaceWith([]);
531
544
  workspace.getExecs = async () => [[], ["util"], []];
532
545
  workspace.getPkgs = async () => ["tools"];
533
- const rerunOf = (name: string) => rerunCommandOf([name], [undefined], 0);
534
- await expect(
535
- getInternalArgumentValue({ key: "", idx: 0, type: "Lib" }, undefined, workspace, rerunOf("remove-library")),
536
- ).rejects.toThrow("so rerun it as `akan remove-library <lib>` (choices: util).");
537
- await expect(
538
- getInternalArgumentValue({ key: "", idx: 0, type: "Pkg" }, undefined, workspace, rerunOf("remove-package")),
539
- ).rejects.toThrow("so rerun it as `akan remove-package <pkg>` (choices: tools).");
546
+ workspace.getDirInModule = async (basePath) => (basePath === "libs/util/lib" ? ["photo"] : []);
547
+ const lib = await getInternalArgumentValue({ key: "", idx: 0, type: "Lib" }, undefined, workspace);
548
+ expect(lib instanceof LibExecutor ? lib.name : null).toBe("util");
549
+ const pkg = await getInternalArgumentValue({ key: "", idx: 0, type: "Pkg" }, undefined, workspace);
550
+ expect(pkg instanceof PkgExecutor ? pkg.name : null).toBe("tools");
551
+ const mod = await getInternalArgumentValue({ key: "", idx: 0, type: "Module" }, undefined, workspace);
552
+ expect(mod instanceof ModuleExecutor ? `${mod.sys.name}:${mod.name}` : null).toBe("util:photo");
540
553
  expect(asked).toEqual([]);
554
+
555
+ setTTY(true);
556
+ answer = "util";
557
+ await getInternalArgumentValue({ key: "", idx: 0, type: "Lib" }, undefined, workspace);
558
+ expect(asked).toEqual([["util"]]);
541
559
  });
542
560
 
543
561
  test("without a terminal, a named target the workspace lacks is refused, not swapped for the only one", async () => {
@@ -608,6 +626,49 @@ describe("a Sys that defaults to the only app", () => {
608
626
  expect(taken instanceof AppExecutor ? taken.name : null).toBe("web");
609
627
  expect(asked).toEqual([]);
610
628
  });
629
+
630
+ test("a module an app or a lib lacks is refused with the modules there are, in a terminal too", async () => {
631
+ setTTY(true);
632
+ answer = "util";
633
+ const workspace = await moduleWorkspace();
634
+ for (const value of ["util:nope", "web:nope"]) {
635
+ const sysName = value.split(":")[0];
636
+ await expect(
637
+ getInternalArgumentValue(
638
+ { key: "", idx: 0, type: "Module" },
639
+ value,
640
+ workspace,
641
+ rerunCommandOf(["create-view", value], [value], 0),
642
+ ),
643
+ ).rejects.toThrow(
644
+ `Unknown module '${value}': ${sysName} has no such module, so rerun it as \`akan create-view <sys:module>\` (choices: web:card, util:photo).`,
645
+ );
646
+ }
647
+ expect(asked).toEqual([]);
648
+ const photo = await getInternalArgumentValue({ key: "", idx: 0, type: "Module" }, "util:photo", workspace);
649
+ expect(photo instanceof ModuleExecutor ? `${photo.sys.name}:${photo.name}` : null).toBe("util:photo");
650
+ });
651
+
652
+ test("a service module is taken by its exact name where the target opts in, as remove-module does", async () => {
653
+ setTTY(true);
654
+ const workspace = await moduleWorkspace();
655
+ const services = { key: "", idx: 0, type: "Module", option: { services: true } } as const;
656
+ const billing = await getInternalArgumentValue(services, "web:_billing", workspace, undefined, {
657
+ destructive: true,
658
+ });
659
+ expect(billing instanceof ModuleExecutor ? `${billing.sys.name}:${billing.name}` : null).toBe("web:_billing");
660
+ await expect(
661
+ getInternalArgumentValue(services, undefined, workspace, rerunCommandOf(["remove-module"], [undefined], 0), {
662
+ destructive: true,
663
+ }),
664
+ ).rejects.toThrow(
665
+ "so rerun it as `akan remove-module <sys:module>` (choices: web:card, web:_billing, util:photo).",
666
+ );
667
+ await expect(
668
+ getInternalArgumentValue({ key: "", idx: 0, type: "Module" }, "web:_billing", workspace),
669
+ ).rejects.toThrow("Unknown module 'web:_billing': web has no such module");
670
+ expect(asked).toEqual([]);
671
+ });
611
672
  });
612
673
 
613
674
  describe("the line a refused target is rerun with", () => {
@@ -683,7 +744,7 @@ describe("a target left out where no terminal can ask for it", () => {
683
744
 
684
745
  test("exits at once with the choices and the line to rerun when there are several", async () => {
685
746
  const refused = await run(["web", "admin"]);
686
- expect(refused.code).toBe(1);
747
+ expect(refused.code).toBe(2);
687
748
  expect(refused.stdout).toContain(
688
749
  "Missing app or lib: stdin is not a terminal to prompt on, so rerun it as `akan create-thing photo <app-or-lib> --force`",
689
750
  );
@@ -693,7 +754,7 @@ describe("a target left out where no terminal can ask for it", () => {
693
754
 
694
755
  test("a destructive command exits with the line to rerun even when the workspace has one app", async () => {
695
756
  const refused = await run(["web"], ["remove-thing"]);
696
- expect(refused.code).toBe(1);
757
+ expect(refused.code).toBe(2);
697
758
  expect(refused.stdout).toContain(
698
759
  "Missing app: this command deletes files and never picks its target, so rerun it as `akan remove-thing <app>` (choices: web).",
699
760
  );
@@ -704,7 +765,10 @@ describe("a target left out where no terminal can ask for it", () => {
704
765
 
705
766
  describe("the exit code of a command that failed", () => {
706
767
  const track = tempRoots();
707
- const run = async (failure: string, { option = "", args = [] as string[] } = {}) => {
768
+ const run = async (
769
+ failure: string,
770
+ { option = "", args = [], argv = ["verdict", ...args] }: { option?: string; args?: string[]; argv?: string[] } = {},
771
+ ) => {
708
772
  const { root } = track(await makeCliTempWorkspace());
709
773
  await writeText(path.join(root, "package.json"), '{ "name": "repo", "version": "1.0.0" }\n');
710
774
  await writeText(path.join(root, "tsconfig.json"), "{}\n");
@@ -712,7 +776,8 @@ describe("the exit code of a command that failed", () => {
712
776
  await writeText(
713
777
  entry,
714
778
  [
715
- `import { command, ExitCodeError, markCliErrorPrinted, runCommands, runner, script } from ${JSON.stringify(path.join(import.meta.dir, "index.ts"))};`,
779
+ `import { AkanError } from ${JSON.stringify(Bun.resolveSync("akanjs/base", import.meta.dir))};`,
780
+ `import { CliError, command, ExitCodeError, markCliErrorPrinted, runCommands, runner, script } from ${JSON.stringify(path.join(import.meta.dir, "index.ts"))};`,
716
781
  'class VerdictRunner extends runner("verdict") {}',
717
782
  'class VerdictScript extends script("verdict", [VerdictRunner]) {}',
718
783
  'class VerdictCommand extends command("verdict", [VerdictScript], ({ public: target }) => ({',
@@ -724,7 +789,7 @@ describe("the exit code of a command that failed", () => {
724
789
  "",
725
790
  ].join("\n"),
726
791
  );
727
- const proc = Bun.spawn(["bun", entry, "verdict", ...args], { cwd: root, stdout: "pipe", stderr: "pipe" });
792
+ const proc = Bun.spawn(["bun", entry, ...argv], { cwd: root, stdout: "pipe", stderr: "pipe" });
728
793
  const [stdout, stderr, code] = await Promise.all([
729
794
  new Response(proc.stdout).text(),
730
795
  new Response(proc.stderr).text(),
@@ -740,6 +805,28 @@ describe("the exit code of a command that failed", () => {
740
805
  expect((await run('new Error("broke")')).code).toBe(1);
741
806
  }, 30_000);
742
807
 
808
+ test("is the table's for a CliError's code, and 1 for an AkanError of any other code", async () => {
809
+ const [checked, unknown, gone] = await Promise.all([
810
+ run('new CliError("checkFailed", "found problems")'),
811
+ run('new CliError("unknownTarget", "no app shop")'),
812
+ run('new AkanError("documentNotFound", "gone")'),
813
+ ]);
814
+ expect([checked.code, unknown.code, gone.code]).toEqual([3, 2, 1]);
815
+ expect(checked.stdout).toContain("found problems");
816
+ }, 30_000);
817
+
818
+ test("is 2 for a flag commander refuses, a value outside the choices and an unknown command", async () => {
819
+ const choice = ' }).option("mode", String, { enum: ["a", "b"]';
820
+ const [flag, outside, unknownCommand] = await Promise.all([
821
+ run('new Error("broke")', { args: ["--nope"] }),
822
+ run('new Error("broke")', { option: choice, args: ["--mode", "c"] }),
823
+ run('new Error("broke")', { argv: ["verdikt"] }),
824
+ ]);
825
+ expect([flag.code, outside.code, unknownCommand.code]).toEqual([2, 2, 2]);
826
+ expect(outside.stdout).toContain("option '--mode' argument 'c' is invalid");
827
+ expect(unknownCommand.stderr).toContain("unknown command 'verdikt'");
828
+ }, 30_000);
829
+
743
830
  test("is usageExitCode for a flag commander refuses before the command runs, failureExitCode after", async () => {
744
831
  const option = ", failureExitCode: 4, usageExitCode: 2";
745
832
  expect((await run('new Error("broke")', { option, args: ["--nope"] })).code).toBe(2);
@@ -767,7 +854,7 @@ describe("the exit code of a command that failed", () => {
767
854
 
768
855
  const thrown = await run('new Error("broke")', { option, args: ["--json"] });
769
856
  expect(thrown.code).toBe(1);
770
- expect(thrown.stdout).toContain("broke\n");
857
+ expect(thrown.stderr).toContain("broke\n");
771
858
  expect(lastOf(thrown.stdout)).toEqual({ message: "broke", usage: false, given: { json: true } });
772
859
 
773
860
  const help = await run('new Error("broke")', { option, args: ["--help"] });
@@ -775,6 +862,94 @@ describe("the exit code of a command that failed", () => {
775
862
  expect(help.stdout).not.toContain('"usage"');
776
863
  }, 60_000);
777
864
 
865
+ test("with JSON asked for, ends stdout with ok, error and code, and prints the message to stderr", async () => {
866
+ const json = ' }).option("json", Boolean, { default: false';
867
+ const format = ' }).option("format", String, { default: "text", enum: ["text", "json"]';
868
+ const marked =
869
+ '(() => { const error = new CliError("checkFailed", "verify failed"); markCliErrorPrinted(error); return error; })()';
870
+ const [unknown, plain, refused, answered, text] = await Promise.all([
871
+ run('new CliError("unknownTarget", "no app shop")', { option: json, args: ["--json"] }),
872
+ run('new Error("broke")', { option: format, args: ["--format", "json"] }),
873
+ run('new Error("broke")', { option: json, args: ["--json", "--nope"] }),
874
+ run(marked, { option: format, args: ["--format", "json"] }),
875
+ run('new Error("broke")', { option: format }),
876
+ ]);
877
+ expect(unknown.code).toBe(2);
878
+ expect(JSON.parse(unknown.stdout)).toEqual({ ok: false, error: "no app shop", code: "unknownTarget" });
879
+ expect(unknown.stderr).toContain("no app shop");
880
+ expect(plain.code).toBe(1);
881
+ expect(JSON.parse(plain.stdout)).toEqual({ ok: false, error: "broke", code: "failed" });
882
+ expect(refused.code).toBe(2);
883
+ expect(JSON.parse(refused.stdout)).toEqual({ ok: false, error: "unknown option '--nope'", code: "usage" });
884
+ expect(answered.code).toBe(3);
885
+ expect(answered.stdout.trim()).toBe("");
886
+ expect(text.stdout).toContain("broke\n");
887
+ expect(text.stdout).not.toContain('"code"');
888
+ }, 60_000);
889
+
890
+ test("is usageExitCode for a usage or unknown-target failure where 2 answers something else", async () => {
891
+ const option = ", usageExitCode: 1";
892
+ const [flag, unknown, verdict] = await Promise.all([
893
+ run('new Error("broke")', { option, args: ["--nope"] }),
894
+ run('new CliError("unknownTarget", "Unknown app \'shop\'")', { option }),
895
+ run('new ExitCodeError("needs a new store build", 2)', { option }),
896
+ ]);
897
+ expect([flag.code, unknown.code, verdict.code]).toEqual([1, 1, 2]);
898
+ }, 30_000);
899
+
900
+ test("is 130 for a prompt closed with Ctrl+C", async () => {
901
+ const closed = await run(
902
+ 'Object.assign(new Error("User force closed the prompt with SIGINT"), { name: "ExitPromptError" })',
903
+ );
904
+ expect(closed.code).toBe(130);
905
+ }, 30_000);
906
+
907
+ test("answers JSON for an ExitCodeError, a thrown object and an unhandled rejection", async () => {
908
+ const json = ' }).option("json", Boolean, { default: false';
909
+ const late = 'await (void Promise.reject(new CliError("refused", "late")), new Promise(() => {}))';
910
+ const [verdict, checked, thrown, rejected] = await Promise.all([
911
+ run('new ExitCodeError("needs a new store build", 2)', { option: json, args: ["--json"] }),
912
+ run('new ExitCodeError("found problems", 3)', { option: json, args: ["--json"] }),
913
+ run('{ reason: "an object" }', { option: json, args: ["--json"] }),
914
+ run(late, { option: json, args: ["--json"] }),
915
+ ]);
916
+ expect(JSON.parse(verdict.stdout)).toEqual({ ok: false, error: "needs a new store build", code: "refused" });
917
+ expect(verdict.code).toBe(2);
918
+ expect(JSON.parse(checked.stdout)).toEqual({ ok: false, error: "found problems", code: "checkFailed" });
919
+ expect(checked.code).toBe(3);
920
+ expect(JSON.parse(thrown.stdout)).toEqual({ ok: false, error: '{"reason":"an object"}', code: "failed" });
921
+ expect(JSON.parse(rejected.stdout)).toEqual({ ok: false, error: "late", code: "refused" });
922
+ expect(rejected.code).toBe(2);
923
+ }, 60_000);
924
+
925
+ test("ends with each reason an aggregate holds, where a bundler log names its file and line", async () => {
926
+ const graphFailure = [
927
+ "await (async () => {",
928
+ ' await Bun.write("graph/server.ts", \'import { env } from "./env.server.debug";\\nexport default env;\\n\');',
929
+ ' const result = await Bun.build({ entrypoints: ["graph/server.ts"], target: "bun", throw: false });',
930
+ ' return new AggregateError(result.logs, "[licenseNotices] server graph failed");',
931
+ "})()",
932
+ ].join("\n");
933
+ const reason = ' Could not resolve: "./env.server.debug" (graph/server.ts:1:21)';
934
+ const json = ' }).option("json", Boolean, { default: false';
935
+ const [text, asJson] = await Promise.all([
936
+ run(graphFailure),
937
+ run(graphFailure, { option: json, args: ["--json"] }),
938
+ ]);
939
+ expect(text.code).toBe(1);
940
+ expect(stripAnsi(text.stdout).trimEnd().split("\n").slice(-2)).toEqual([
941
+ "[licenseNotices] server graph failed",
942
+ reason,
943
+ ]);
944
+ expect(asJson.code).toBe(1);
945
+ expect(JSON.parse(asJson.stdout)).toEqual({
946
+ ok: false,
947
+ error: "[licenseNotices] server graph failed",
948
+ code: "failed",
949
+ });
950
+ expect(stripAnsi(asJson.stderr).trimEnd().split("\n").at(-1)).toBe(reason);
951
+ }, 30_000);
952
+
778
953
  test("prints nothing more for an error the command marked as printed", async () => {
779
954
  const marked = await run(
780
955
  '(() => { const error = new Error("printed already"); markCliErrorPrinted(error); return error; })()',
@@ -1,15 +1,14 @@
1
+ import { CliError } from "./cliError";
2
+
1
3
  //* A failure that is an answer, not a breakage: the CLI exits with its code, so a CI tells the two apart.
2
- export class ExitCodeError extends Error {
4
+ export class ExitCodeError extends CliError {
3
5
  override readonly name = "ExitCodeError";
4
6
 
5
- constructor(
6
- message: string,
7
- readonly exitCode: number,
8
- ) {
9
- super(message);
7
+ constructor(message: string, exitCode: number) {
8
+ super(exitCode === 2 ? "refused" : exitCode === 3 ? "checkFailed" : "failed", message, { exitCode });
10
9
  }
11
10
 
12
11
  static codeOf(error: unknown): number | null {
13
- return error instanceof ExitCodeError ? error.exitCode : null;
12
+ return CliError.exitCodeOf(error);
14
13
  }
15
14
  }
@@ -1,4 +1,5 @@
1
1
  export * from "./argMeta";
2
+ export * from "./cliError";
2
3
  export * from "./command";
3
4
  export * from "./commandBuilder";
4
5
  export * from "./dependencyBuilder";
@@ -44,6 +44,7 @@ export interface TargetOption {
44
44
  runsOnWorkspaceRoot?: boolean;
45
45
  stdio?: boolean;
46
46
  failureExitCode?: number;
47
+ /** The exit of a `usage` or `unknownTarget` failure, for a command whose 2 already answers something else. */
47
48
  usageExitCode?: number;
48
49
  /** It deletes files in its app, lib, pkg or module, so one left out or unknown is refused, never picked or asked. */
49
50
  destructive?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { mkdir, symlink } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { tempDirs, writeJson } from "../testHelpers";
4
+ import { tempDirs, writeJson } from "../test/testHelpers";
5
5
  import { WorkspaceVersionCheck } from "./workspaceVersionCheck";
6
6
 
7
7
  const makeRoot = tempDirs("akan-version-check-");
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync, realpathSync } from "node:fs";
2
2
  import path from "node:path";
3
- import type { PackageJson } from "../types";
3
+ import type { PackageJson } from "../workspace/types";
4
4
 
5
5
  export class WorkspaceVersionCheck {
6
6
  static readonly #exemptCommands = new Set(["update", "create-workspace"]);