@akanjs/devkit 3.2.0-rc.9 → 3.2.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 +0 -529
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/README.ko.md +3 -2
  4. package/README.md +4 -2
  5. package/akanApp/BackendImportGraph.test.ts +1 -1
  6. package/akanApp/akanApp.host.test.ts +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,126 @@
1
+ import ts from "typescript";
2
+
3
+ export class BareErrorScanner {
4
+ static readonly #builtins: ReadonlySet<string> = new Set([
5
+ "Error",
6
+ "TypeError",
7
+ "RangeError",
8
+ "SyntaxError",
9
+ "ReferenceError",
10
+ "EvalError",
11
+ "URIError",
12
+ "AggregateError",
13
+ ]);
14
+ static readonly #globals: ReadonlySet<string> = new Set(["globalThis", "window", "self"]);
15
+ //? Without the lib and imports, a name the binder resolves is one this file declares, and an unresolved one is global.
16
+ static readonly #options: ts.CompilerOptions = { noLib: true, noResolve: true, noEmit: true, types: [] };
17
+
18
+ lines(sourceFile: ts.SourceFile): number[] {
19
+ const declared = BareErrorScanner.#declaredNamesOf(sourceFile);
20
+ const shadows = [...BareErrorScanner.#builtins, ...BareErrorScanner.#globals].some((name) => declared.has(name));
21
+ if (!shadows) return BareErrorScanner.#scan(sourceFile, () => true);
22
+ const rootName = sourceFile.fileName.endsWith(".tsx") ? "/scan.tsx" : "/scan.ts";
23
+ const scope = ts.createSourceFile(
24
+ rootName,
25
+ sourceFile.text,
26
+ ts.ScriptTarget.Latest,
27
+ true,
28
+ rootName.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS,
29
+ );
30
+ const checker = ts
31
+ .createProgram({
32
+ rootNames: [rootName],
33
+ options: BareErrorScanner.#options,
34
+ host: BareErrorScanner.#hostOf(scope),
35
+ })
36
+ .getTypeChecker();
37
+ return BareErrorScanner.#scan(
38
+ scope,
39
+ (identifier) =>
40
+ !checker
41
+ .getSymbolAtLocation(identifier)
42
+ ?.declarations?.some((declaration) => declaration.getSourceFile() === scope),
43
+ );
44
+ }
45
+
46
+ static #scan(sourceFile: ts.SourceFile, isGlobal: (identifier: ts.Identifier) => boolean) {
47
+ const lines: number[] = [];
48
+ const visit = (node: ts.Node) => {
49
+ const constructed = ts.isNewExpression(node) || ts.isCallExpression(node) ? node.expression : null;
50
+ const extended =
51
+ ts.isClassDeclaration(node) || ts.isClassExpression(node)
52
+ ? node.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0]?.expression
53
+ : null;
54
+ const target = constructed ?? extended;
55
+ if (target && BareErrorScanner.#namesBuiltin(target, isGlobal))
56
+ lines.push(sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);
57
+ ts.forEachChild(node, visit);
58
+ };
59
+ ts.forEachChild(sourceFile, visit);
60
+ return lines;
61
+ }
62
+
63
+ static #declaredNamesOf(sourceFile: ts.SourceFile) {
64
+ const names = new Set<string>();
65
+ const visit = (node: ts.Node) => {
66
+ if (ts.isIdentifier(node) && BareErrorScanner.#declares(node.parent, node)) names.add(node.text);
67
+ ts.forEachChild(node, visit);
68
+ };
69
+ ts.forEachChild(sourceFile, visit);
70
+ return names;
71
+ }
72
+
73
+ static #declares(parent: ts.Node, identifier: ts.Identifier) {
74
+ return (
75
+ (ts.isVariableDeclaration(parent) ||
76
+ ts.isParameter(parent) ||
77
+ ts.isBindingElement(parent) ||
78
+ ts.isFunctionDeclaration(parent) ||
79
+ ts.isFunctionExpression(parent) ||
80
+ ts.isClassDeclaration(parent) ||
81
+ ts.isClassExpression(parent) ||
82
+ ts.isImportSpecifier(parent) ||
83
+ ts.isImportClause(parent) ||
84
+ ts.isNamespaceImport(parent) ||
85
+ ts.isImportEqualsDeclaration(parent) ||
86
+ ts.isEnumDeclaration(parent) ||
87
+ ts.isModuleDeclaration(parent)) &&
88
+ parent.name === identifier
89
+ );
90
+ }
91
+
92
+ static #namesBuiltin(expression: ts.Expression, isGlobal: (identifier: ts.Identifier) => boolean) {
93
+ const callee = BareErrorScanner.#unwrapped(expression);
94
+ if (ts.isIdentifier(callee)) return BareErrorScanner.#builtins.has(callee.text) && isGlobal(callee);
95
+ if (!ts.isPropertyAccessExpression(callee) || !BareErrorScanner.#builtins.has(callee.name.text)) return false;
96
+ const owner = BareErrorScanner.#unwrapped(callee.expression);
97
+ return ts.isIdentifier(owner) && BareErrorScanner.#globals.has(owner.text) && isGlobal(owner);
98
+ }
99
+
100
+ static #unwrapped(expression: ts.Expression) {
101
+ let current = expression;
102
+ while (
103
+ ts.isParenthesizedExpression(current) ||
104
+ ts.isAsExpression(current) ||
105
+ ts.isSatisfiesExpression(current) ||
106
+ ts.isNonNullExpression(current) ||
107
+ ts.isTypeAssertionExpression(current)
108
+ )
109
+ current = current.expression;
110
+ return current;
111
+ }
112
+
113
+ static #hostOf(scope: ts.SourceFile): ts.CompilerHost {
114
+ return {
115
+ getSourceFile: (fileName) => (fileName === scope.fileName ? scope : undefined),
116
+ writeFile: () => undefined,
117
+ getDefaultLibFileName: () => "/lib.d.ts",
118
+ useCaseSensitiveFileNames: () => true,
119
+ getCanonicalFileName: (fileName) => fileName,
120
+ getCurrentDirectory: () => "/",
121
+ getNewLine: () => "\n",
122
+ fileExists: (fileName) => fileName === scope.fileName,
123
+ readFile: () => undefined,
124
+ };
125
+ }
126
+ }
@@ -39,6 +39,14 @@ const placementOf = (file: string, writes: string[]): MaintainabilityViolation =
39
39
  line: 1,
40
40
  writes,
41
41
  });
42
+ const bareOf = (file: string, count: number): MaintainabilityViolation => ({
43
+ kind: "bareError",
44
+ rule: "akan.error.bare-error",
45
+ key: file,
46
+ file,
47
+ line: 1,
48
+ lines: Array.from({ length: count }, (_, idx) => idx + 1),
49
+ });
42
50
  const baselineOf = (
43
51
  sections: { [rule in DebtRuleId]?: Record<string, number> },
44
52
  reasons: Record<string, string> = {},
@@ -217,6 +225,71 @@ describe("MaintainabilityBaseline", () => {
217
225
  expect(baseline.tightenedBy([]).reasons.size).toBe(0);
218
226
  });
219
227
 
228
+ test("moves a moved file's entries and reasons to its new path, matching the file before the first #", () => {
229
+ const reason = "The canvas is one pointer state machine.";
230
+ const baseline = baselineOf(
231
+ {
232
+ "akan.size.file": { "lib/a/A.Zone.tsx": 900, "lib/a/A.Zone.tsxx": 700 },
233
+ "akan.component.store-access": { "lib/a/A.Zone.tsx#Canvas": 30, "lib/a/A.Zone.tsx#Canvas#2": 25 },
234
+ },
235
+ { "lib/a/A.Zone.tsx#Canvas": reason },
236
+ );
237
+
238
+ const moved = baseline.movedBy(new Map([["lib/a/A.Zone.tsx", "lib/b/A.Zone.tsx"]]));
239
+
240
+ expect([...(moved.sections.get("akan.size.file") ?? [])]).toEqual([
241
+ ["lib/b/A.Zone.tsx", 900],
242
+ ["lib/a/A.Zone.tsxx", 700],
243
+ ]);
244
+ expect([...(moved.sections.get("akan.component.store-access") ?? [])]).toEqual([
245
+ ["lib/b/A.Zone.tsx#Canvas", 30],
246
+ ["lib/b/A.Zone.tsx#Canvas#2", 25],
247
+ ]);
248
+ expect([...moved.reasons]).toEqual([["lib/b/A.Zone.tsx#Canvas", reason]]);
249
+ expect(baseline.movedBy(new Map())).toBe(baseline);
250
+ });
251
+
252
+ test("holds a total rule to the sum of its section: a moved count passes, a raised sum names the files that rose", () => {
253
+ const baseline = baselineOf({ "akan.error.bare-error": { "server/a.ts": 2, "server/b.ts": 1 } });
254
+
255
+ expect(baseline.unallowed([bareOf("server/c.ts", 3)])).toEqual([]);
256
+ expect(baseline.unallowed([bareOf("server/a.ts", 3), bareOf("server/b.ts", 1)])).toEqual([
257
+ bareOf("server/a.ts", 3),
258
+ ]);
259
+ expect(baseline.tightenedBy([bareOf("server/c.ts", 2)]).sections.get("akan.error.bare-error")).toEqual(
260
+ new Map([["server/c.ts", 2]]),
261
+ );
262
+ expect(baseline.tightenedBy([bareOf("server/a.ts", 4)]).sections.get("akan.error.bare-error")).toEqual(
263
+ new Map([
264
+ ["server/a.ts", 2],
265
+ ["server/b.ts", 1],
266
+ ]),
267
+ );
268
+ expect(baselineOf({ "akan.error.bare-error": { "server/c.ts": 3 } }).grownFrom(baseline)).toEqual([]);
269
+ expect(baselineOf({ "akan.error.bare-error": { "server/c.ts": 4 } }).grownFrom(baseline)).toEqual([
270
+ { rule: "akan.error.bare-error", key: MaintainabilityBaseline.totalKey, count: 4, committed: 3 },
271
+ ]);
272
+ expect(baseline.grownFrom(new MaintainabilityBaseline())).toEqual([
273
+ { rule: "akan.error.bare-error", key: MaintainabilityBaseline.totalKey, count: 3, committed: undefined },
274
+ ]);
275
+ });
276
+
277
+ test("names a total recorded above the code's and no other, on a total rule only", () => {
278
+ const baseline = baselineOf({
279
+ "akan.size.file": { "lib/a/A.Zone.tsx": 900 },
280
+ "akan.error.bare-error": { "server/a.ts": 2, "server/b.ts": 1 },
281
+ });
282
+
283
+ expect(baseline.staleTotals([bareOf("server/a.ts", 2)])).toEqual([
284
+ { rule: "akan.error.bare-error", count: 2, recorded: 3 },
285
+ ]);
286
+ expect(baseline.staleTotals([])).toEqual([{ rule: "akan.error.bare-error", count: 0, recorded: 3 }]);
287
+ expect(baseline.staleTotals([bareOf("server/c.ts", 3)])).toEqual([]);
288
+ expect(baseline.staleTotals([bareOf("server/c.ts", 4)])).toEqual([]);
289
+ expect(baseline.tightenedBy([bareOf("server/a.ts", 1)]).staleTotals([bareOf("server/a.ts", 1)])).toEqual([]);
290
+ expect(new MaintainabilityBaseline().staleTotals([])).toEqual([]);
291
+ });
292
+
220
293
  test("prints the rule sections in rule order with sorted keys, as Biome would, and reprints them unchanged", () => {
221
294
  const baseline = MaintainabilityBaseline.of([
222
295
  writeOf("lib/z/z.store.ts#run"),
@@ -1,4 +1,4 @@
1
- import { JsonFormatter } from "./jsonFormatter";
1
+ import { JsonFormatter } from "../util/jsonFormatter";
2
2
  import type { DebtRuleId, MaintainabilityViolation } from "./maintainabilityContract";
3
3
 
4
4
  export interface BaselineEntryGrowth {
@@ -14,9 +14,16 @@ export interface BaselineEntry {
14
14
  reason?: string;
15
15
  }
16
16
 
17
+ export interface BaselineStaleTotal {
18
+ rule: DebtRuleId;
19
+ count: number;
20
+ recorded: number;
21
+ }
22
+
17
23
  type Counts = ReadonlyMap<string, number>;
18
24
 
19
- //* One section per rule, each key holding what the gate measured: lines, members, store accesses, writes or calls.
25
+ //* One section per rule, each key holding what the gate measured: lines, members, accesses, writes, calls or the
26
+ //* built-in Errors constructed or extended.
20
27
  //* A count only falls, so a recorded entry cannot take on more of the debt it records.
21
28
  export class MaintainabilityBaseline {
22
29
  static readonly fileName = "akan.baseline.json";
@@ -32,7 +39,13 @@ export class MaintainabilityBaseline {
32
39
  "akan.component.write-chain",
33
40
  "akan.write.placement",
34
41
  "akan.service.call-in-loop",
42
+ "akan.error.bare-error",
35
43
  ] as const satisfies readonly DebtRuleId[];
44
+ //* Added after baselines were committed: where the reference holds no section for one, its code there is the floor.
45
+ static readonly lateRules: ReadonlySet<DebtRuleId> = new Set(["akan.error.bare-error"]);
46
+ //* Held to the package's sum, so a moved or split file keeps its count; the per-file entries name the file that rose.
47
+ static readonly totalRules: ReadonlySet<DebtRuleId> = new Set(["akan.error.bare-error"]);
48
+ static readonly totalKey = "(total)";
36
49
  static readonly reasonedRules: ReadonlySet<DebtRuleId> = new Set([
37
50
  "akan.size.file",
38
51
  "akan.size.component",
@@ -48,6 +61,7 @@ export class MaintainabilityBaseline {
48
61
  if (violation.kind === "storeAccess") return violation.accessCount;
49
62
  if (violation.kind === "multiWrite") return violation.writeCount;
50
63
  if (violation.kind === "writePlacement") return violation.writes.length;
64
+ if (violation.kind === "bareError") return violation.lines.length;
51
65
  return violation.calls.length;
52
66
  }
53
67
 
@@ -116,6 +130,30 @@ export class MaintainabilityBaseline {
116
130
  return recorded !== undefined && MaintainabilityBaseline.countOf(violation) <= recorded;
117
131
  }
118
132
 
133
+ unallowed(violations: MaintainabilityViolation[]) {
134
+ const measured = MaintainabilityBaseline.of(violations);
135
+ return violations.filter(
136
+ (violation) =>
137
+ !(
138
+ MaintainabilityBaseline.totalRules.has(violation.rule) &&
139
+ measured.totalOf(violation.rule) <= this.totalOf(violation.rule)
140
+ ) && !this.allows(violation),
141
+ );
142
+ }
143
+
144
+ staleTotals(violations: MaintainabilityViolation[]): BaselineStaleTotal[] {
145
+ const measured = MaintainabilityBaseline.of(violations);
146
+ return [...MaintainabilityBaseline.totalRules].flatMap((rule) => {
147
+ const count = measured.totalOf(rule);
148
+ const recorded = this.totalOf(rule);
149
+ return count < recorded ? [{ rule, count, recorded }] : [];
150
+ });
151
+ }
152
+
153
+ totalOf(rule: DebtRuleId) {
154
+ return [...(this.sections.get(rule)?.values() ?? [])].reduce((sum, count) => sum + count, 0);
155
+ }
156
+
119
157
  recordedOf(violation: MaintainabilityViolation) {
120
158
  return this.sections.get(violation.rule)?.get(violation.key);
121
159
  }
@@ -140,13 +178,55 @@ export class MaintainabilityBaseline {
140
178
  );
141
179
  }
142
180
 
181
+ rulesOutside(other: MaintainabilityBaseline | null): DebtRuleId[] {
182
+ return [...this.sections]
183
+ .filter(
184
+ ([rule, counts]) =>
185
+ counts.size && (other === null || (MaintainabilityBaseline.lateRules.has(rule) && !other.sections.has(rule))),
186
+ )
187
+ .map(([rule]) => rule);
188
+ }
189
+
190
+ withSectionsOf(other: MaintainabilityBaseline | null, rules: ReadonlySet<DebtRuleId>) {
191
+ if (!other) return this;
192
+ const sections = new Map(this.sections);
193
+ for (const rule of rules) sections.set(rule, other.sections.get(rule) ?? new Map());
194
+ return new MaintainabilityBaseline(sections, this.reasons);
195
+ }
196
+
197
+ movedBy(moves: ReadonlyMap<string, string>) {
198
+ if (!moves.size) return this;
199
+ const movedKey = (key: string) => {
200
+ const file = key.split("#", 1)[0] ?? key;
201
+ const to = moves.get(file);
202
+ return to === undefined ? key : `${to}${key.slice(file.length)}`;
203
+ };
204
+ const sections = new Map(
205
+ [...this.sections].map(([rule, counts]) => {
206
+ const moved = new Map<string, number>();
207
+ for (const [key, count] of counts) {
208
+ const to = movedKey(key);
209
+ moved.set(to, Math.max(moved.get(to) ?? 0, count));
210
+ }
211
+ return [rule, moved];
212
+ }),
213
+ );
214
+ return new MaintainabilityBaseline(
215
+ sections,
216
+ new Map([...this.reasons].map(([key, reason]) => [movedKey(key), reason])),
217
+ );
218
+ }
219
+
143
220
  tightenedBy(violations: MaintainabilityViolation[]) {
144
221
  const current = MaintainabilityBaseline.of(violations);
145
222
  const sections = new Map(
146
- [...this.sections].map(([rule, counts]) => [
147
- rule,
148
- MaintainabilityBaseline.#lowered(counts, current.sections.get(rule) ?? new Map()),
149
- ]),
223
+ [...this.sections].map(([rule, counts]) => {
224
+ const measured = current.sections.get(rule) ?? new Map<string, number>();
225
+ if (!MaintainabilityBaseline.totalRules.has(rule))
226
+ return [rule, MaintainabilityBaseline.#lowered(counts, measured)];
227
+ //? Over budget, a file that went down may only have moved its count; recording it would refuse that move later.
228
+ return [rule, current.totalOf(rule) > this.totalOf(rule) ? counts : measured];
229
+ }),
150
230
  );
151
231
  return new MaintainabilityBaseline(sections).#withReasonsOf(this.reasons);
152
232
  }
@@ -161,12 +241,20 @@ export class MaintainabilityBaseline {
161
241
  //* Only a shape entry grows with a reason: a write rule guards correctness, whatever the reason.
162
242
  grownFrom(committed: MaintainabilityBaseline): BaselineEntryGrowth[] {
163
243
  return [...this.sections].flatMap(([rule, counts]) =>
164
- MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map())
165
- .filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key)))
166
- .map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })),
244
+ MaintainabilityBaseline.totalRules.has(rule)
245
+ ? this.#totalGrownFrom(committed, rule)
246
+ : MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map())
247
+ .filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key)))
248
+ .map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })),
167
249
  );
168
250
  }
169
251
 
252
+ #totalGrownFrom(committed: MaintainabilityBaseline, rule: DebtRuleId): BaselineEntryGrowth[] {
253
+ const count = this.totalOf(rule);
254
+ const recorded = committed.sections.has(rule) ? committed.totalOf(rule) : undefined;
255
+ return count > (recorded ?? 0) ? [{ rule, key: MaintainabilityBaseline.totalKey, count, committed: recorded }] : [];
256
+ }
257
+
170
258
  stringify() {
171
259
  const sections = MaintainabilityBaseline.debtRules.flatMap((rule) => {
172
260
  const counts = this.sections.get(rule);