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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/CHANGELOG.md +0 -529
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/README.ko.md +3 -2
  4. package/README.md +4 -2
  5. package/akanApp/BackendImportGraph.test.ts +1 -1
  6. package/akanApp/akanApp.host.test.ts +152 -6
  7. package/akanApp/akanApp.host.ts +187 -1220
  8. package/akanApp/akanApp.host.wiring.test.ts +931 -0
  9. package/akanApp/builderGap.ts +68 -0
  10. package/akanApp/builderRequestRelay.test.ts +93 -0
  11. package/akanApp/builderRequestRelay.ts +100 -0
  12. package/akanApp/builderRssRecycler.ts +182 -0
  13. package/akanApp/devBackend.ts +394 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +200 -0
  16. package/akanApp/devIdleSuspend.test.ts +221 -0
  17. package/akanApp/devIdleSuspend.ts +192 -0
  18. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  19. package/akanApp/devRecycler.test.ts +66 -0
  20. package/akanApp/devRecycler.ts +305 -0
  21. package/akanApp/devStartTimeline.test.ts +115 -0
  22. package/akanApp/devStartTimeline.ts +69 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +45 -17
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiReport.test.ts +34 -3
  29. package/apiReport/apiReportDiff.ts +35 -1
  30. package/apiReport/apiReportPolicy.ts +3 -2
  31. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +2 -49
  32. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +71 -8
  33. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +60 -21
  34. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  35. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +17 -1
  36. package/{routeJsBudget.ts → app/routeJsBudget.ts} +9 -3
  37. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  38. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  39. package/artifact/implicitRootLayout.test.ts +71 -3
  40. package/artifact/implicitRootLayout.ts +9 -3
  41. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  42. package/biome.base.json +2 -1
  43. package/cloud/cloudApi.test.ts +1 -1
  44. package/cloud/configLock.test.ts +1 -1
  45. package/cloud/globalConfig.test.ts +1 -1
  46. package/cloud/globalConfig.ts +1 -1
  47. package/cloud/updatePackUpload.test.ts +1 -1
  48. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  49. package/codeAgent/agent/AkanCodeServices.ts +23 -0
  50. package/codeAgent/agent/akanCodePaths.ts +1 -1
  51. package/codeAgent/agent/akanCodeServices.test.ts +54 -0
  52. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  53. package/codeAgent/agent/codeAgent.test.ts +1 -1
  54. package/codeAgent/skills/akan-debug/SKILL.md +8 -5
  55. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  56. package/codeAgent/skills/akan-mcp/SKILL.md +19 -1
  57. package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
  58. package/codeAgent/skills/akan-validate/SKILL.md +3 -3
  59. package/codeAgent/tools/AkanCli.ts +1 -1
  60. package/codeAgent/tools/AkanToolPack.ts +2 -2
  61. package/codeAgent/tools/akanCodePlugins.test.ts +1 -1
  62. package/commandDecorators/command.ts +35 -6
  63. package/commandDecorators/commandBuilder.ts +1 -1
  64. package/commandDecorators/commandDecorators.test.ts +107 -6
  65. package/commandDecorators/targetMeta.ts +2 -0
  66. package/commandDecorators/workspaceVersionCheck.test.ts +70 -1
  67. package/commandDecorators/workspaceVersionCheck.ts +64 -14
  68. package/context/akanContext.ts +576 -0
  69. package/context/akanContextInspection.ts +296 -0
  70. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  71. package/{akanMcpContract.ts → context/akanMcpContract.ts} +16 -256
  72. package/context/doctor/agentGuideCheck.ts +81 -0
  73. package/context/doctor/configLeftoverCheck.ts +35 -0
  74. package/context/doctor/doctorFindings.ts +70 -0
  75. package/context/doctor/generatedFreshness.ts +56 -0
  76. package/context/doctor/moduleShapeCheck.ts +88 -0
  77. package/context/doctor/recipeDuplicateCheck.ts +42 -0
  78. package/context/doctor/recipeIndexCheck.ts +87 -0
  79. package/context/doctor/rootShapeCheck.ts +55 -0
  80. package/context/doctor/workflowScope.ts +97 -0
  81. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  82. package/context/safeRead.ts +9 -0
  83. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  84. package/devkitUtils.test.ts +39 -5
  85. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  86. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  87. package/docs/errorCodeReference.test.ts +282 -0
  88. package/docs/errorCodeReference.ts +71 -0
  89. package/docs/errorCodeScan.ts +551 -0
  90. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  91. package/executors/appExecutor.ts +463 -0
  92. package/executors/commandExecutionError.ts +53 -0
  93. package/executors/executor.ts +527 -0
  94. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  95. package/{executors.test.ts → executors/executors.test.ts} +106 -18
  96. package/executors/index.ts +8 -0
  97. package/executors/libExecutor.ts +23 -0
  98. package/executors/moduleExecutor.ts +18 -0
  99. package/executors/pkgExecutor.ts +129 -0
  100. package/executors/sysExecutor.ts +301 -0
  101. package/executors/workspaceExecutor.ts +277 -0
  102. package/frontendBuild/allRoutesBuilder.test.ts +1 -1
  103. package/frontendBuild/autoImportSync.test.ts +1 -1
  104. package/frontendBuild/autoImportSync.ts +1 -1
  105. package/frontendBuild/buildCacheStamp.test.ts +42 -0
  106. package/frontendBuild/buildCacheStamp.ts +23 -0
  107. package/frontendBuild/buildRouteClient.test.ts +1 -1
  108. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  109. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  110. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  111. package/frontendBuild/cssCandidateCache.test.ts +70 -1
  112. package/frontendBuild/cssCandidateCache.ts +17 -10
  113. package/frontendBuild/cssCompiler.test.ts +3 -2
  114. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  115. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  116. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  117. package/frontendBuild/fontOptimizer.test.ts +145 -4
  118. package/frontendBuild/fontOptimizer.ts +103 -18
  119. package/frontendBuild/fontPruner.test.ts +1 -1
  120. package/frontendBuild/frontendBuild.test.ts +3 -3
  121. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  122. package/frontendBuild/hmrWatcher.test.ts +1 -1
  123. package/frontendBuild/hmrWatcher.ts +22 -1
  124. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  125. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  126. package/frontendBuild/nativeCore.test.ts +1 -1
  127. package/frontendBuild/optionalPeers.test.ts +36 -8
  128. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  129. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  130. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  131. package/frontendBuild/precompressArtifacts.ts +19 -6
  132. package/frontendBuild/serverGraphFile.ts +1 -1
  133. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  134. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
  135. package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
  136. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  137. package/frontendBuild/vendorImportScanner.test.ts +1 -1
  138. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  139. package/frontendBuild/watchRootResolver.test.ts +1 -1
  140. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  141. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  142. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  143. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  144. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  145. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  146. package/{prompter.ts → guideline/prompter.ts} +2 -3
  147. package/incrementalBuilder/buildBatch.proc.ts +16 -5
  148. package/incrementalBuilder/buildBatchProtocol.ts +3 -0
  149. package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
  150. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  151. package/incrementalBuilder/builderBoot.ts +113 -0
  152. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  153. package/incrementalBuilder/builderChannel.test.ts +1 -1
  154. package/incrementalBuilder/builderChannel.ts +19 -2
  155. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  156. package/incrementalBuilder/builderLanes.ts +157 -0
  157. package/incrementalBuilder/builderWatch.ts +213 -0
  158. package/incrementalBuilder/csrRegistry.ts +234 -0
  159. package/incrementalBuilder/incrementalBuilder.host.test.ts +16 -0
  160. package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
  161. package/incrementalBuilder/incrementalBuilder.proc.test.ts +142 -7
  162. package/incrementalBuilder/incrementalBuilder.proc.ts +82 -823
  163. package/incrementalBuilder/ssrRegistry.ts +282 -0
  164. package/index.ts +22 -22
  165. package/integration/devStability.integration.test.ts +62 -56
  166. package/integration/devStabilityHarness.test.ts +1 -1
  167. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  168. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  169. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  170. package/lint/gritRules.test.ts +1 -1
  171. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  172. package/lint/no-import-common-err.grit +31 -0
  173. package/lint/no-init-fetch-in-client.grit +1 -1
  174. package/mobile/desktopBin.test.ts +1 -1
  175. package/mobile/desktopRelease.test.ts +1 -1
  176. package/mobile/desktopServerStage.test.ts +2 -2
  177. package/mobile/desktopServerStage.ts +1 -1
  178. package/mobile/nativeApi.test.ts +1 -1
  179. package/mobile/nativeApp.test.ts +1 -1
  180. package/mobile/nativeConfig.test.ts +1 -1
  181. package/mobile/nativePluginFolders.test.ts +1 -1
  182. package/mobile/nativePublicEnv.test.ts +1 -1
  183. package/mobile/nativePublicEnv.ts +2 -1
  184. package/mobile/nativeWebDir.test.ts +1 -1
  185. package/mobile/serverBundleSecrets.test.ts +1 -1
  186. package/mobile/tarWriter.test.ts +1 -1
  187. package/mobile/updatePackFolder.test.ts +1 -1
  188. package/package.json +173 -9
  189. package/packageExports.test.ts +20 -2
  190. package/piDependencyPins.test.ts +1 -1
  191. package/pipeline/PipelineDefinition.ts +1 -1
  192. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  193. package/platformTest/LinuxDockerTarget.ts +1 -1
  194. package/platformTest/PlatformTestRun.test.ts +1 -1
  195. package/platformTest/TestSnapshot.test.ts +1 -1
  196. package/platformTest/WindowsSshTarget.ts +1 -1
  197. package/preview/previewView.test.ts +23 -1
  198. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  199. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  200. package/quality/bareErrorScanner.ts +126 -0
  201. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  202. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  203. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  204. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  205. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  206. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  207. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  208. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  209. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +41 -1
  210. package/{qualityScanner.ts → quality/qualityScanner.ts} +25 -91
  211. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  212. package/quality/workspaceSourceFiles.ts +82 -0
  213. package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
  214. package/{subspace.ts → subspace/subspace.ts} +5 -5
  215. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  216. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  217. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  218. package/transforms/barrelAnalyzer.ts +31 -10
  219. package/transforms/browserDirnamePlugin.test.ts +1 -1
  220. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  221. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  222. package/transforms/pureLazyMarker.test.ts +1 -1
  223. package/transforms/serverEnvPlugin.test.ts +1 -1
  224. package/transforms/serverEnvProfile.test.ts +1 -1
  225. package/transforms/sideEffectImportOrder.test.ts +1 -1
  226. package/transforms/transforms.test.ts +52 -2
  227. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  228. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  229. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  230. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  231. package/typecheck/projectTypecheck.test.ts +23 -1
  232. package/typecheck/projectTypecheck.ts +10 -2
  233. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  234. package/{typeChecker.ts → typecheck/typeChecker.ts} +5 -4
  235. package/typecheck/typecheck.proc.ts +6 -2
  236. package/typecheck/typecheckFailure.ts +1 -1
  237. package/util/errorReport.ts +66 -0
  238. package/{fileSys.test.ts → util/fileSys.test.ts} +13 -0
  239. package/{fileSys.ts → util/fileSys.ts} +2 -2
  240. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  241. package/workflow/constantSource.ts +187 -0
  242. package/workflow/dictionarySource.ts +184 -0
  243. package/workflow/executor.ts +6 -9
  244. package/workflow/fieldExpression.ts +153 -0
  245. package/workflow/fieldLabel.ts +61 -0
  246. package/workflow/fieldOrder.ts +117 -0
  247. package/workflow/fieldType.ts +2 -1
  248. package/workflow/guardCatalog.test.ts +1 -1
  249. package/workflow/keyRename.ts +1 -1
  250. package/workflow/moduleIndex.test.ts +2 -2
  251. package/workflow/moduleIndex.ts +2 -2
  252. package/workflow/modulePaths.ts +27 -0
  253. package/workflow/mutationScaffold.ts +7 -15
  254. package/workflow/mutationSource.ts +2 -1
  255. package/workflow/plan.ts +2 -1
  256. package/workflow/primitiveReport.ts +78 -0
  257. package/workflow/rolloutGate.test.ts +1 -1
  258. package/workflow/rolloutGate.ts +1 -1
  259. package/workflow/serviceSource.ts +33 -0
  260. package/workflow/signalSource.ts +96 -0
  261. package/workflow/source.ts +50 -1100
  262. package/workflow/sourceAst.ts +30 -0
  263. package/workflow/sourceImports.ts +105 -0
  264. package/workflow/sourceText.ts +13 -0
  265. package/workflow/templateSource.ts +30 -0
  266. package/workflow/testSource.ts +31 -0
  267. package/workflow/types.ts +1 -1
  268. package/workflow/uiPolicy.ts +1 -1
  269. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  270. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  271. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  272. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  273. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  274. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  275. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  276. package/{libSource.ts → workspace/libSource.ts} +1 -1
  277. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  278. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  279. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  280. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
  281. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
  282. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  283. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  284. package/akanContext.ts +0 -1083
  285. package/executors.ts +0 -1749
  286. /package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +0 -0
  287. /package/{akanMcpToolError.ts → context/akanMcpToolError.ts} +0 -0
  288. /package/{moduleFieldNames.test.ts → context/moduleFieldNames.test.ts} +0 -0
  289. /package/{moduleFieldNames.ts → context/moduleFieldNames.ts} +0 -0
  290. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  291. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  292. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  293. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  294. /package/{linter.ts → lint/linter.ts} +0 -0
  295. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  296. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  297. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  298. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  299. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  300. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  301. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  302. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  303. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  304. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  305. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  306. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  307. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  308. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  309. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  310. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  311. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  312. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  313. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  314. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  315. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  316. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  317. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  318. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  319. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  320. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  321. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  322. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  323. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  324. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  325. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  326. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  327. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  328. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  329. /package/{writePath.ts → quality/writePath.ts} +0 -0
  330. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  331. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  332. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  333. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  334. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  335. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  336. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  337. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  338. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  339. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  340. /package/{semver.ts → util/semver.ts} +0 -0
  341. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  342. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  343. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  344. /package/{spinner.ts → util/spinner.ts} +0 -0
  345. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  346. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  347. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  348. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  349. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  350. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  351. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  352. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  353. /package/{types.ts → workspace/types.ts} +0 -0
@@ -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);