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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/CHANGELOG.md +350 -11
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/README.ko.md +3 -2
  4. package/README.md +4 -2
  5. package/akanApp/BackendImportGraph.test.ts +1 -1
  6. package/akanApp/akanApp.host.test.ts +257 -1
  7. package/akanApp/akanApp.host.ts +146 -1223
  8. package/akanApp/akanApp.host.wiring.test.ts +727 -0
  9. package/akanApp/builderGap.ts +68 -0
  10. package/akanApp/builderRequestRelay.test.ts +93 -0
  11. package/akanApp/builderRequestRelay.ts +100 -0
  12. package/akanApp/builderRssRecycler.ts +182 -0
  13. package/akanApp/devBackend.ts +392 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +196 -0
  16. package/akanApp/devHostPolicy.test.ts +11 -11
  17. package/akanApp/devHostPolicy.ts +2 -4
  18. package/akanApp/devIdleSuspend.test.ts +221 -0
  19. package/akanApp/devIdleSuspend.ts +192 -0
  20. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  21. package/akanApp/devRecycler.test.ts +66 -0
  22. package/akanApp/devRecycler.ts +305 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +24 -1
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiDeclarationPrinter.ts +120 -0
  29. package/apiReport/apiReport.test.ts +526 -0
  30. package/apiReport/apiReport.ts +232 -0
  31. package/apiReport/apiReportDiff.ts +160 -0
  32. package/apiReport/apiReportPolicy.ts +65 -0
  33. package/apiReport/apiTargets.ts +311 -0
  34. package/apiReport/changesetBump.ts +19 -0
  35. package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
  36. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
  37. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
  38. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
  39. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  40. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
  41. package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
  42. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  43. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  44. package/artifact/implicitRootLayout.test.ts +71 -3
  45. package/artifact/implicitRootLayout.ts +21 -4
  46. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  47. package/biome.base.json +2 -1
  48. package/cloud/cloudApi.test.ts +1 -1
  49. package/cloud/configLock.test.ts +1 -1
  50. package/cloud/globalConfig.test.ts +1 -1
  51. package/cloud/globalConfig.ts +1 -1
  52. package/cloud/updatePackUpload.test.ts +1 -1
  53. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  54. package/codeAgent/agent/akanCodePaths.ts +1 -1
  55. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  56. package/codeAgent/agent/codeAgent.test.ts +1 -1
  57. package/codeAgent/skills/akan-debug/SKILL.md +10 -3
  58. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  59. package/codeAgent/skills/akan-mcp/SKILL.md +13 -2
  60. package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
  61. package/codeAgent/skills/akan-transport/SKILL.md +2 -0
  62. package/codeAgent/skills/akan-validate/SKILL.md +1 -0
  63. package/codeAgent/tools/AkanCli.ts +1 -1
  64. package/codeAgent/tools/AkanToolPack.ts +1 -1
  65. package/codeAgent/tools/McpClient.ts +28 -6
  66. package/codeAgent/tools/McpToolPack.ts +1 -1
  67. package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
  68. package/commandDecorators/argMeta.ts +4 -0
  69. package/commandDecorators/cliError.ts +72 -0
  70. package/commandDecorators/command.ts +165 -91
  71. package/commandDecorators/commandBuilder.ts +1 -1
  72. package/commandDecorators/commandDecorators.test.ts +191 -16
  73. package/commandDecorators/exitCodeError.ts +6 -7
  74. package/commandDecorators/index.ts +1 -0
  75. package/commandDecorators/targetMeta.ts +1 -0
  76. package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
  77. package/commandDecorators/workspaceVersionCheck.ts +1 -1
  78. package/context/akanContext.ts +576 -0
  79. package/context/akanContextInspection.ts +296 -0
  80. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  81. package/{akanMcpContract.ts → context/akanMcpContract.ts} +33 -263
  82. package/context/akanMcpToolError.ts +16 -0
  83. package/context/doctor/agentGuideCheck.ts +81 -0
  84. package/context/doctor/configLeftoverCheck.ts +35 -0
  85. package/context/doctor/doctorFindings.ts +70 -0
  86. package/context/doctor/generatedFreshness.ts +56 -0
  87. package/context/doctor/moduleShapeCheck.ts +88 -0
  88. package/context/doctor/recipeDuplicateCheck.ts +39 -0
  89. package/context/doctor/recipeIndexCheck.ts +87 -0
  90. package/context/doctor/rootShapeCheck.ts +55 -0
  91. package/context/doctor/workflowScope.ts +97 -0
  92. package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
  93. package/context/moduleFieldNames.ts +25 -0
  94. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  95. package/context/safeRead.ts +9 -0
  96. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  97. package/devkitUtils.test.ts +39 -5
  98. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  99. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  100. package/docs/errorCodeReference.test.ts +282 -0
  101. package/docs/errorCodeReference.ts +71 -0
  102. package/docs/errorCodeScan.ts +551 -0
  103. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  104. package/executors/appExecutor.ts +448 -0
  105. package/executors/commandExecutionError.ts +53 -0
  106. package/executors/executor.ts +527 -0
  107. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  108. package/{executors.test.ts → executors/executors.test.ts} +76 -15
  109. package/executors/index.ts +8 -0
  110. package/executors/libExecutor.ts +23 -0
  111. package/executors/moduleExecutor.ts +18 -0
  112. package/executors/pkgExecutor.ts +129 -0
  113. package/executors/sysExecutor.ts +301 -0
  114. package/executors/workspaceExecutor.ts +277 -0
  115. package/frontendBuild/allRoutesBuilder.test.ts +17 -5
  116. package/frontendBuild/allRoutesBuilder.ts +24 -6
  117. package/frontendBuild/autoImportSync.test.ts +1 -1
  118. package/frontendBuild/autoImportSync.ts +1 -1
  119. package/frontendBuild/buildRouteClient.test.ts +1 -1
  120. package/frontendBuild/bundleDefine.ts +2 -0
  121. package/frontendBuild/clientBuildTypes.ts +5 -2
  122. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  123. package/frontendBuild/clientEntryDiscovery.test.ts +58 -0
  124. package/frontendBuild/clientEntryDiscovery.ts +25 -6
  125. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  126. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  127. package/frontendBuild/cssCompiler.test.ts +1 -1
  128. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  129. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  130. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  131. package/frontendBuild/fontOptimizer.test.ts +1 -1
  132. package/frontendBuild/fontPruner.test.ts +1 -1
  133. package/frontendBuild/frontendBuild.test.ts +3 -3
  134. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  135. package/frontendBuild/hmrWatcher.test.ts +1 -1
  136. package/frontendBuild/hmrWatcher.ts +22 -1
  137. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  138. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  139. package/frontendBuild/nativeCore.test.ts +148 -0
  140. package/frontendBuild/optionalPeers.test.ts +36 -8
  141. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  142. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  143. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  144. package/frontendBuild/precompressArtifacts.ts +1 -1
  145. package/frontendBuild/serverGraphFile.ts +1 -1
  146. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  147. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
  148. package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
  149. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  150. package/frontendBuild/vendorImportScanner.test.ts +25 -4
  151. package/frontendBuild/vendorImportScanner.ts +25 -10
  152. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  153. package/frontendBuild/watchRootResolver.test.ts +1 -1
  154. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  155. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  156. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  157. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  158. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  159. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  160. package/{prompter.ts → guideline/prompter.ts} +2 -3
  161. package/incrementalBuilder/buildBatch.proc.ts +14 -4
  162. package/incrementalBuilder/buildBatchProtocol.ts +2 -0
  163. package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
  164. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  165. package/incrementalBuilder/builderBoot.ts +106 -0
  166. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  167. package/incrementalBuilder/builderChannel.test.ts +1 -1
  168. package/incrementalBuilder/builderChannel.ts +11 -0
  169. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  170. package/incrementalBuilder/builderLanes.ts +157 -0
  171. package/incrementalBuilder/builderWatch.ts +213 -0
  172. package/incrementalBuilder/csrRegistry.ts +234 -0
  173. package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
  174. package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
  175. package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
  176. package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
  177. package/incrementalBuilder/ssrRegistry.ts +278 -0
  178. package/index.ts +22 -22
  179. package/integration/devStability.integration.test.ts +62 -56
  180. package/integration/devStabilityHarness.test.ts +1 -1
  181. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  182. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  183. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  184. package/lint/gritRules.test.ts +1 -1
  185. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  186. package/lint/no-import-common-err.grit +31 -0
  187. package/lint/no-init-fetch-in-client.grit +1 -1
  188. package/lint/no-web-only-api-outside-webkit.grit +3 -3
  189. package/mobile/desktopBin.test.ts +1 -1
  190. package/mobile/desktopRelease.test.ts +1 -1
  191. package/mobile/desktopServerStage.test.ts +2 -2
  192. package/mobile/desktopServerStage.ts +1 -1
  193. package/mobile/nativeApi.test.ts +1 -1
  194. package/mobile/nativeApp.test.ts +1 -1
  195. package/mobile/nativeConfig.test.ts +1 -1
  196. package/mobile/nativePluginFolders.test.ts +1 -1
  197. package/mobile/nativePublicEnv.test.ts +1 -1
  198. package/mobile/nativeWebDir.test.ts +1 -1
  199. package/mobile/serverBundleSecrets.test.ts +1 -1
  200. package/mobile/tarWriter.test.ts +1 -1
  201. package/mobile/updatePackFolder.test.ts +1 -1
  202. package/package.json +167 -3
  203. package/packageExports.test.ts +20 -2
  204. package/piDependencyPins.test.ts +1 -1
  205. package/pipeline/PipelineDefinition.ts +1 -1
  206. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  207. package/platformTest/PlatformTestRun.test.ts +1 -1
  208. package/platformTest/TestSnapshot.test.ts +1 -1
  209. package/preview/PreviewView.ts +32 -11
  210. package/preview/previewView.test.ts +76 -9
  211. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  212. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  213. package/quality/bareErrorScanner.ts +126 -0
  214. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  215. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  216. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  217. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  218. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  219. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  220. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  221. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  222. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
  223. package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
  224. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  225. package/{subspace.test.ts → subspace/subspace.test.ts} +9 -3
  226. package/{subspace.ts → subspace/subspace.ts} +5 -5
  227. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  228. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  229. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  230. package/transforms/barrelAnalyzer.ts +26 -8
  231. package/transforms/browserDirnamePlugin.test.ts +1 -1
  232. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  233. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  234. package/transforms/pureLazyMarker.test.ts +1 -1
  235. package/transforms/serverEnvPlugin.test.ts +1 -1
  236. package/transforms/serverEnvProfile.test.ts +1 -1
  237. package/transforms/sideEffectImportOrder.test.ts +1 -1
  238. package/transforms/transforms.test.ts +29 -2
  239. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  240. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  241. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  242. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  243. package/typecheck/projectTypecheck.test.ts +1 -1
  244. package/typecheck/projectTypecheck.ts +6 -2
  245. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  246. package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
  247. package/typecheck/typecheck.proc.ts +4 -3
  248. package/typecheck/typecheckFailure.ts +7 -2
  249. package/util/errorReport.ts +66 -0
  250. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  251. package/workflow/artifacts.ts +8 -7
  252. package/workflow/constantSource.ts +187 -0
  253. package/workflow/dictionarySource.ts +184 -0
  254. package/workflow/executor.ts +6 -9
  255. package/workflow/fieldExpression.ts +153 -0
  256. package/workflow/fieldLabel.ts +61 -0
  257. package/workflow/fieldOrder.ts +117 -0
  258. package/workflow/fieldType.ts +93 -0
  259. package/workflow/guardCatalog.test.ts +1 -1
  260. package/workflow/index.ts +2 -0
  261. package/workflow/keyRename.ts +1 -1
  262. package/workflow/moduleIndex.test.ts +2 -2
  263. package/workflow/moduleIndex.ts +2 -2
  264. package/workflow/modulePaths.ts +27 -0
  265. package/workflow/mutationScaffold.ts +7 -15
  266. package/workflow/mutationSource.ts +2 -1
  267. package/workflow/plainName.ts +28 -0
  268. package/workflow/plan.ts +15 -9
  269. package/workflow/primitiveReport.ts +78 -0
  270. package/workflow/rolloutGate.test.ts +1 -1
  271. package/workflow/rolloutGate.ts +1 -1
  272. package/workflow/serviceSource.ts +33 -0
  273. package/workflow/signalSource.ts +96 -0
  274. package/workflow/source.ts +50 -1105
  275. package/workflow/sourceAst.ts +30 -0
  276. package/workflow/sourceImports.ts +105 -0
  277. package/workflow/sourceText.ts +13 -0
  278. package/workflow/templateSource.ts +30 -0
  279. package/workflow/testSource.ts +31 -0
  280. package/workflow/types.ts +1 -1
  281. package/workflow/uiPolicy.ts +1 -1
  282. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  283. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  284. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  285. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  286. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  287. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  288. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  289. package/{libSource.ts → workspace/libSource.ts} +1 -1
  290. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  291. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  292. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  293. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +85 -1
  294. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +41 -6
  295. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  296. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  297. package/akanContext.ts +0 -1084
  298. package/constantFieldNames.ts +0 -18
  299. package/executors.ts +0 -1749
  300. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  301. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  302. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  303. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  304. /package/{linter.ts → lint/linter.ts} +0 -0
  305. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  306. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  307. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  308. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  309. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  310. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  311. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  312. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  313. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  314. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  315. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  316. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  317. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  318. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  319. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  320. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  321. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  322. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  323. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  324. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  325. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  326. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  327. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  328. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  329. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  330. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  331. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  332. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  333. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  334. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  335. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  336. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  337. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  338. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  339. /package/{writePath.ts → quality/writePath.ts} +0 -0
  340. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  341. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  342. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  343. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  344. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  345. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  346. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  347. /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
  348. /package/{fileSys.ts → util/fileSys.ts} +0 -0
  349. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  350. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  351. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  352. /package/{semver.ts → util/semver.ts} +0 -0
  353. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  354. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  355. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  356. /package/{spinner.ts → util/spinner.ts} +0 -0
  357. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  358. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  359. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  360. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  361. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  362. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  363. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  364. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  365. /package/{types.ts → workspace/types.ts} +0 -0
@@ -1,11 +1,13 @@
1
1
  import { existsSync } from "node:fs";
2
- import { readFile, rm, writeFile } from "node:fs/promises";
2
+ import { copyFile, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
3
4
  import path from "node:path";
4
5
  import ts from "typescript";
6
+ import { GitRevision } from "../workspace/gitRevision";
7
+ import { BareErrorScanner } from "./bareErrorScanner";
5
8
  import { ComponentSizeScanner } from "./componentSizeScanner";
6
9
  import { ComponentWriteChainScanner } from "./componentWriteChainScanner";
7
10
  import { EndpointReach } from "./endpointReach";
8
- import { GitRevision } from "./gitRevision";
9
11
  import { MaintainabilityBaseline } from "./maintainabilityBaseline";
10
12
  import { MaintainabilityLimits } from "./maintainabilityLimits";
11
13
  import { MaintainabilityReport } from "./maintainabilityReport";
@@ -97,6 +99,16 @@ export interface StoreAccessViolation {
97
99
  recorded?: number;
98
100
  }
99
101
 
102
+ export interface BareErrorViolation {
103
+ kind: "bareError";
104
+ rule: "akan.error.bare-error";
105
+ key: string;
106
+ file: string;
107
+ line: number;
108
+ lines: number[];
109
+ recorded?: number;
110
+ }
111
+
100
112
  export interface BaselineGrowth {
101
113
  kind: "baselineGrowth";
102
114
  rule: "akan.baseline.growth";
@@ -110,14 +122,25 @@ export interface BaselineGrowth {
110
122
  measured?: boolean;
111
123
  }
112
124
 
125
+ export interface StaleTotal {
126
+ kind: "staleTotal";
127
+ rule: DebtRuleId;
128
+ key: string;
129
+ file: string;
130
+ line: number;
131
+ count: number;
132
+ recorded: number;
133
+ }
134
+
113
135
  export type MaintainabilityViolation =
114
136
  | SizeViolation
115
137
  | ClassSizeViolation
116
138
  | MultiWriteViolation
117
139
  | StoreAccessViolation
118
140
  | WritePlacementViolation
119
- | LoopCallViolation;
120
- export type MaintainabilityFailure = MaintainabilityViolation | BaselineGrowth;
141
+ | LoopCallViolation
142
+ | BareErrorViolation;
143
+ export type MaintainabilityFailure = MaintainabilityViolation | BaselineGrowth | StaleTotal;
121
144
 
122
145
  export type BaselineSeed = "written" | "kept" | "removed" | "clean";
123
146
 
@@ -133,6 +156,7 @@ export class MaintainabilityContract {
133
156
  "akan.component.store-access",
134
157
  "akan.write.placement",
135
158
  "akan.service.call-in-loop",
159
+ "akan.error.bare-error",
136
160
  "akan.baseline.growth",
137
161
  ] as const;
138
162
  static readonly #measuredFiles = "{lib,ui,webkit,srvkit,common,plugin}/**/*.{ts,tsx,md}";
@@ -176,28 +200,41 @@ export class MaintainabilityContract {
176
200
  this.#readBaseline(),
177
201
  this.#readReferenceBaseline(),
178
202
  ]);
179
- const baseline =
203
+ const moves = await this.#movesSince(reference.ref);
204
+ const onDisk =
180
205
  existing === null ? new MaintainabilityBaseline() : MaintainabilityBaseline.parse(existing, this.baselinePath);
206
+ const baseline = fix ? onDisk.movedBy(moves) : onDisk;
181
207
  const tightened = baseline.tightenedBy(violations);
182
- if (fix && existing !== null) await this.#tighten(baseline, tightened);
183
- const failures: MaintainabilityFailure[] = violations
184
- .filter((violation) => !baseline.allows(violation))
185
- .map((violation) => {
186
- const recorded = baseline.recordedOf(violation);
187
- return recorded === undefined ? violation : { ...violation, recorded };
188
- });
208
+ if (fix && existing !== null) await this.#tighten(onDisk, tightened);
189
209
  //? Without fix the file on disk is what merges, so an entry it holds above the measured count is checked as written.
190
210
  const working = fix ? tightened : baseline;
191
- const source = `${reference.label}:${this.sysPath}/${MaintainabilityBaseline.fileName}`;
192
- const committed =
193
- reference.text !== null
194
- ? MaintainabilityBaseline.parse(reference.text, source, { lenient: true })
195
- : working.isEmpty
196
- ? null
197
- : await this.#measuredAt(reference.ref);
198
- if (committed === null) return failures;
199
211
  const lines = ((await this.#readBaseline()) ?? "").split(/\r?\n/);
200
- const growths = working
212
+ const failures: MaintainabilityFailure[] = [
213
+ ...working.staleTotals(violations).map(
214
+ ({ rule, count, recorded }): StaleTotal => ({
215
+ kind: "staleTotal",
216
+ rule,
217
+ key: MaintainabilityBaseline.totalKey,
218
+ file: MaintainabilityBaseline.fileName,
219
+ line: MaintainabilityContract.#lineOf(lines, rule, MaintainabilityBaseline.totalKey),
220
+ count,
221
+ recorded,
222
+ }),
223
+ ),
224
+ ...baseline.unallowed(violations).map((violation) => {
225
+ const recorded = baseline.recordedOf(violation);
226
+ return recorded === undefined ? violation : { ...violation, recorded };
227
+ }),
228
+ ];
229
+ const source = `${reference.label}:${this.sysPath}/${MaintainabilityBaseline.fileName}`;
230
+ const recorded =
231
+ reference.text !== null ? MaintainabilityBaseline.parse(reference.text, source, { lenient: true }) : null;
232
+ const unrecorded = new Set(working.rulesOutside(recorded));
233
+ const measured = unrecorded.size ? await this.#measuredAt(reference.ref) : null;
234
+ if (recorded === null && measured === null) return failures;
235
+ const committed = (recorded ?? new MaintainabilityBaseline()).withSectionsOf(measured, unrecorded).movedBy(moves);
236
+ //? Without fix the entries on disk keep their old keys, so they are compared under the moved ones the reference took.
237
+ const growths = (fix ? working : working.movedBy(moves))
201
238
  .grownFrom(committed)
202
239
  .map(
203
240
  ({ rule, ...growth }): BaselineGrowth => ({
@@ -207,7 +244,7 @@ export class MaintainabilityContract {
207
244
  line: MaintainabilityContract.#lineOf(lines, rule, growth.key),
208
245
  debtRule: rule,
209
246
  reference: reference.label,
210
- ...(reference.text === null ? { measured: true } : {}),
247
+ ...(unrecorded.has(rule) ? { measured: true } : {}),
211
248
  ...growth,
212
249
  }),
213
250
  )
@@ -234,17 +271,37 @@ export class MaintainabilityContract {
234
271
 
235
272
  async #measurePackage() {
236
273
  const files = (await this.#packageFiles()).filter(MaintainabilityLimits.isPackageSource);
274
+ const packageName = await this.#packageName();
237
275
  const violations = await Promise.all(
238
276
  files.map(async (file) => {
239
277
  const workspaceFile = `${this.sysPath}/${file}`;
240
278
  const content = await this.#read(workspaceFile);
241
- return MaintainabilityContract.#measurePackageFile(file, this.#sourceOf(workspaceFile, content).sourceFile);
279
+ return MaintainabilityContract.#measurePackageFile(
280
+ file,
281
+ this.#sourceOf(workspaceFile, content).sourceFile,
282
+ MaintainabilityLimits.holdsBareErrors(packageName, file),
283
+ );
242
284
  }),
243
285
  );
244
286
  return violations.flat();
245
287
  }
246
288
 
247
- static #measurePackageFile(file: string, sourceFile: ts.SourceFile) {
289
+ async #packageName() {
290
+ const manifest = `${this.sysPath}/package.json`;
291
+ const text = this.#tree
292
+ ? this.#tree.get(manifest)
293
+ : existsSync(path.join(this.#workspaceRoot, manifest))
294
+ ? await this.#read(manifest)
295
+ : undefined;
296
+ try {
297
+ const { name } = JSON.parse(text ?? "{}") as { name?: unknown };
298
+ return typeof name === "string" ? name : null;
299
+ } catch {
300
+ return null;
301
+ }
302
+ }
303
+
304
+ static #measurePackageFile(file: string, sourceFile: ts.SourceFile, holdsBareErrors: boolean) {
248
305
  const violations: MaintainabilityViolation[] = [];
249
306
  const maxLines = MaintainabilityLimits.packageFileMaxLines;
250
307
  const lineCount = MaintainabilityLimits.lineCountOf(sourceFile.text);
@@ -275,6 +332,16 @@ export class MaintainabilityContract {
275
332
  memberCount,
276
333
  maxMembers: MaintainabilityLimits.classMaxMembers,
277
334
  });
335
+ const bareErrors = holdsBareErrors ? new BareErrorScanner().lines(sourceFile) : [];
336
+ if (bareErrors.length)
337
+ violations.push({
338
+ kind: "bareError",
339
+ rule: "akan.error.bare-error",
340
+ key: file,
341
+ file,
342
+ line: bareErrors[0] ?? 1,
343
+ lines: bareErrors,
344
+ });
278
345
  return violations;
279
346
  }
280
347
 
@@ -426,15 +493,16 @@ export class MaintainabilityContract {
426
493
  return { ref, label: ref === "HEAD" ? ref : ref.slice(0, 12), text };
427
494
  }
428
495
 
429
- //* With no baseline file at the reference, the debt its code already holds is the floor: none for a scope new to the
430
- //* branch or one whose paid-off file was removed, and the breaches it had for a scope that adopts the gate here.
496
+ //* With no baseline file at the reference, or no section there for a rule, the debt its code already holds is the
497
+ //* floor: none for a scope new to the branch or one whose paid-off file was removed, and the breaches it had for a
498
+ //* scope that adopts the gate here or a rule this version adds.
431
499
  async #measuredAt(ref: string) {
432
500
  if ((await this.#git(["rev-parse", "--verify", "--quiet", `${ref}^{commit}`])) === null) return null;
433
501
  const roots = [this.sysPath, ...this.#libNames.map((libName) => `libs/${libName}`)];
434
502
  const contract = new MaintainabilityContract(this.#workspaceRoot, this.#scope, this.#libNames);
435
503
  contract.#tree = await new GitRevision(this.#workspaceRoot).filesAt(
436
504
  ref,
437
- (file) => /\.(tsx?|md)$/.test(file),
505
+ (file) => /\.(tsx?|md)$/.test(file) || file === `${this.sysPath}/package.json`,
438
506
  roots,
439
507
  );
440
508
  return MaintainabilityBaseline.of(await contract.measure());
@@ -455,6 +523,53 @@ export class MaintainabilityContract {
455
523
  return "HEAD";
456
524
  }
457
525
 
526
+ //? A move that also rewrote more than half the file, or left a file at the old path, reads as an add and fails as new.
527
+ async #movesSince(ref: string) {
528
+ const staged = await this.#stagedScope();
529
+ try {
530
+ const diff = ["diff", ...(staged ? ["--cached"] : []), "--relative", "--name-status", "-z", "-M", ref];
531
+ const fields = (await this.#git([...diff, "--", this.sysPath], staged?.env))?.split("\0") ?? [];
532
+ const prefix = `${this.sysPath}/`;
533
+ const moves = new Map<string, string>();
534
+ for (let idx = 0; idx < fields.length; idx += fields[idx]?.startsWith("R") ? 3 : 2) {
535
+ const [from, to] = [fields[idx + 1], fields[idx + 2]];
536
+ if (!fields[idx]?.startsWith("R") || !from?.startsWith(prefix) || !to?.startsWith(prefix)) continue;
537
+ moves.set(from.slice(prefix.length), to.slice(prefix.length));
538
+ }
539
+ return moves;
540
+ } finally {
541
+ if (staged) await rm(staged.dir, { recursive: true, force: true });
542
+ }
543
+ }
544
+
545
+ //? Git pairs moves only between staged paths, so a plain rename is staged too, in a copy of the user's index.
546
+ async #stagedScope() {
547
+ const indexPath = (await this.#git(["rev-parse", "--git-path", "index"]))?.trim();
548
+ //? Only sources: staging writes each file into .git/objects, where a local database or a log would pile up.
549
+ const untracked = (await this.#git(["ls-files", "-o", "--exclude-standard", "-z", "--", this.sysPath]))
550
+ ?.split("\0")
551
+ .filter((file) => /\.(tsx?|md)$/.test(file));
552
+ if (!indexPath || !untracked) return null;
553
+ const dir = await mkdtemp(path.join(tmpdir(), "akan-moves-")).catch(() => null);
554
+ if (!dir) return null;
555
+ const env = { GIT_INDEX_FILE: path.join(dir, "index") };
556
+ const listPath = path.join(dir, "untracked");
557
+ try {
558
+ const indexFile = path.resolve(this.#workspaceRoot, indexPath);
559
+ if (existsSync(indexFile)) await copyFile(indexFile, env.GIT_INDEX_FILE);
560
+ await writeFile(listPath, untracked.join("\0"));
561
+ const added =
562
+ (await this.#git(["add", "-u", "--", this.sysPath], env)) !== null &&
563
+ (!untracked.length ||
564
+ (await this.#git(["add", "--pathspec-from-file", listPath, "--pathspec-file-nul"], env)) !== null);
565
+ if (added) return { dir, env };
566
+ } catch {
567
+ //? A full or read-only temp dir: fall back to the moves the user's own index holds.
568
+ }
569
+ await rm(dir, { recursive: true, force: true });
570
+ return null;
571
+ }
572
+
458
573
  static #missingHistory(sysPath: string, cause: string) {
459
574
  return (
460
575
  `${sysPath}/${MaintainabilityBaseline.fileName} is compared with its copy where this branch forked from the default branch, ` +
@@ -462,9 +577,15 @@ export class MaintainabilityContract {
462
577
  );
463
578
  }
464
579
 
465
- async #git(args: string[]) {
580
+ //? GIT_OPTIONAL_LOCKS=0 keeps a read from refreshing the index under the user's own git, which would then fail on index.lock.
581
+ async #git(args: string[], env: Record<string, string> = {}) {
466
582
  try {
467
- const proc = Bun.spawn(["git", ...args], { cwd: this.#workspaceRoot, stdout: "pipe", stderr: "ignore" });
583
+ const proc = Bun.spawn(["git", ...args], {
584
+ cwd: this.#workspaceRoot,
585
+ env: { ...process.env, GIT_OPTIONAL_LOCKS: "0", ...env },
586
+ stdout: "pipe",
587
+ stderr: "ignore",
588
+ });
468
589
  const [text, exitCode] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
469
590
  return exitCode === 0 ? text : null;
470
591
  } catch {
@@ -492,6 +613,7 @@ export class MaintainabilityContract {
492
613
  lines.findIndex((line) => line.includes(`${JSON.stringify(rule)}:`)),
493
614
  0,
494
615
  );
616
+ if (key === MaintainabilityBaseline.totalKey) return from + 1;
495
617
  const idx = lines.findIndex((line, lineIdx) => lineIdx >= from && line.includes(`${JSON.stringify(key)}:`));
496
618
  return Math.max(idx + 1, 1);
497
619
  }
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
+ import { tempDirs, writeText } from "../test/testHelpers";
3
4
  import { MaintainabilityExceptionScanner } from "./maintainabilityExceptionScanner";
4
- import { tempDirs, writeText } from "./testHelpers";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-maintainability-exceptions-");
7
7
 
@@ -98,4 +98,18 @@ describe("MaintainabilityExceptionScanner", () => {
98
98
  expect(byRule("apps/demo/akan.baseline.json", "akan.size.component")?.fix).toContain("threshold is wrong");
99
99
  expect(byRule("apps/demo/akan.baseline.json", "akan.store.multi-write")?.fix).toContain("add-mutation");
100
100
  });
101
+
102
+ test("tells a bare Error entry to construct a coded error, since the rule takes no exception", async () => {
103
+ const root = await makeWorkspace({
104
+ "pkgs/akanjs/akan.baseline.json": baselineOf({ "akan.error.bare-error": { "server/host.ts": 2 } }),
105
+ });
106
+
107
+ expect(await new MaintainabilityExceptionScanner().scan(root)).toMatchObject([
108
+ {
109
+ message:
110
+ "pkgs/akanjs carries 0 reasoned exceptions and 1 adopted-debt entry for akan.error.bare-error: server/host.ts.",
111
+ fix: expect.stringContaining("construct an `AkanError` subclass"),
112
+ },
113
+ ]);
114
+ });
101
115
  });
@@ -11,6 +11,8 @@ export class MaintainabilityExceptionScanner {
11
11
  "Many reasoned exceptions under one rule mean its threshold is wrong: fix the limit in MaintainabilityLimits rather than record another. Otherwise shrink the code, and `akan lint` lowers each entry and drops it once it passes.";
12
12
  static readonly #correctnessFix =
13
13
  "A write rule takes no exception: send the writes through one store action and one endpoint (`akan workflow plan add-mutation`), and `akan lint` drops the entry.";
14
+ static readonly #bareErrorFix =
15
+ "A bare Error takes no exception: construct an `AkanError` subclass with a code, and `akan lint` lowers the entries as they go.";
14
16
 
15
17
  async scan(workspaceRoot: string): Promise<QualityWarning[]> {
16
18
  const sysPaths = await Promise.all(
@@ -81,7 +83,9 @@ export class MaintainabilityExceptionScanner {
81
83
  locations,
82
84
  fix: MaintainabilityBaseline.reasonedRules.has(rule)
83
85
  ? MaintainabilityExceptionScanner.#shapeFix
84
- : MaintainabilityExceptionScanner.#correctnessFix,
86
+ : rule === "akan.error.bare-error"
87
+ ? MaintainabilityExceptionScanner.#bareErrorFix
88
+ : MaintainabilityExceptionScanner.#correctnessFix,
85
89
  };
86
90
  }
87
91
 
@@ -25,6 +25,18 @@ export class MaintainabilityLimits {
25
25
  static readonly packageFileMaxLines = 800;
26
26
  static readonly functionMaxLines = 150;
27
27
  static readonly classMaxMembers = 60;
28
+ //? The request-path facets: a failure there reaches a caller, who branches on its code rather than its message.
29
+ static readonly bareErrorRoots: ReadonlyMap<string, readonly string[]> = new Map([
30
+ ["akanjs", ["server/", "service/", "signal/"]],
31
+ ]);
32
+
33
+ //? Rules this repository holds its own framework to: no workspace has a package they measure, so none is told of them.
34
+ static readonly repoOnlyRules: ReadonlySet<string> = new Set(["akan.error.bare-error"]);
35
+
36
+ static holdsBareErrors(pkgName: string | null, pkgRelativePath: string) {
37
+ const roots = pkgName === null ? undefined : MaintainabilityLimits.bareErrorRoots.get(pkgName);
38
+ return (roots ?? []).some((root) => pkgRelativePath.startsWith(root));
39
+ }
28
40
 
29
41
  static fileKindOf(sysRelativePath: string): FileKind | null {
30
42
  const kinds = Object.keys(MaintainabilityLimits.#maxLinesByKind) as FileKind[];
@@ -1,4 +1,5 @@
1
1
  import { AbstractDoc } from "./abstractDoc";
2
+ import { MaintainabilityBaseline } from "./maintainabilityBaseline";
2
3
  import type {
3
4
  DebtRuleId,
4
5
  MaintainabilityCommands,
@@ -7,7 +8,7 @@ import type {
7
8
  } from "./maintainabilityContract";
8
9
  import { type FileKind, MaintainabilityLimits } from "./maintainabilityLimits";
9
10
 
10
- type FixKey = FileKind | "package" | Exclude<MaintainabilityRuleId, "akan.size.file">;
11
+ type FixKey = FileKind | "package" | "staleTotal" | Exclude<MaintainabilityRuleId, "akan.size.file">;
11
12
 
12
13
  export class MaintainabilityReport {
13
14
  static readonly #clientSplitFix =
@@ -48,8 +49,12 @@ export class MaintainabilityReport {
48
49
  "A server write leaves the browser through one store action, started by one module component. Move a `fetch.<mutation>` into a store action, and hand `ui/` and `webkit/` code the write as an `onX` prop or hook argument from the module's `Zone` or `Util`: they stay free of any one model, and an agent or another screen reaches the write through the store.",
49
50
  "akan.service.call-in-loop":
50
51
  "Load the set once (`load<Model>Many(ids)`, one filter query) or write it once (`create<Model>Many(rows)`, one batch method), then loop in memory: a call per item is a round trip per item, so the endpoint slows as its input grows.",
52
+ "akan.error.bare-error":
53
+ "Construct an `AkanError` subclass from `akanjs/base` with a code the caller can branch on, and a `statusCode` when it answers a request: an existing class whose code fits, or a new one beside the code that fails; a class extending a built-in Error extends `AkanError` instead. A failure another process reported travels as itself. The package's total is what is held, so moving a bare Error between files passes and `akan lint` rewrites the entries.",
51
54
  "akan.baseline.growth":
52
55
  "Restore the entry from the default branch, then split the file or move the writes instead: `akan lint` lowers an entry as the code shrinks and never raises one.",
56
+ staleTotal:
57
+ "Run `akan verify <package>`, which lowers the section, and commit `akan.baseline.json` in this change: a recorded total above the code is room for a new failure anywhere. A bare `akan verify` covers only uncommitted files.",
53
58
  };
54
59
 
55
60
  static readonly #labels: { [key in FixKey]?: string } = {
@@ -65,7 +70,9 @@ export class MaintainabilityReport {
65
70
  "akan.component.store-access": "component or hook reaching the store often",
66
71
  "akan.write.placement": "write sent outside a store action or module component",
67
72
  "akan.service.call-in-loop": "service call per item",
73
+ "akan.error.bare-error": "bare Error",
68
74
  "akan.baseline.growth": "baseline entry",
75
+ staleTotal: "baseline total",
69
76
  };
70
77
 
71
78
  static readonly #units: { [rule in DebtRuleId]: string } = {
@@ -79,6 +86,7 @@ export class MaintainabilityReport {
79
86
  "akan.component.write-chain": "writes",
80
87
  "akan.write.placement": "writes",
81
88
  "akan.service.call-in-loop": "calls per item",
89
+ "akan.error.bare-error": "bare Errors",
82
90
  };
83
91
 
84
92
  static describe(sysPath: string, failures: MaintainabilityFailure[], commands: MaintainabilityCommands = {}) {
@@ -118,13 +126,17 @@ export class MaintainabilityReport {
118
126
  }
119
127
 
120
128
  static #problemOf(failure: MaintainabilityFailure) {
129
+ if (failure.kind === "staleTotal")
130
+ return `records ${failure.recorded} ${MaintainabilityReport.#units[failure.rule]} in all, above the ${failure.count} the code holds`;
121
131
  if (failure.kind === "baselineGrowth") {
122
132
  const entry = `entry "${failure.key}" under ${failure.debtRule}`;
123
133
  const units = MaintainabilityReport.#units[failure.debtRule];
134
+ if (failure.key === MaintainabilityBaseline.totalKey)
135
+ return `${failure.debtRule} allows ${failure.count} ${units} in all, above the ${failure.committed ?? 0} ${failure.measured ? `the code at ${failure.reference} holds with no entry for its rule recorded there` : `at ${failure.reference}`}; the baseline may only shrink`;
124
136
  if (failure.measured)
125
137
  return failure.committed === undefined
126
- ? `${entry} is debt the code at ${failure.reference} does not hold, and with no baseline there the baseline may only shrink from that code`
127
- : `${entry} allows ${failure.count} ${units}, above the ${failure.committed} the code at ${failure.reference} holds with no baseline there; the baseline may only shrink`;
138
+ ? `${entry} is debt the code at ${failure.reference} does not hold, and with no entry for its rule recorded there the baseline may only shrink from that code`
139
+ : `${entry} allows ${failure.count} ${units}, above the ${failure.committed} the code at ${failure.reference} holds with no entry for its rule recorded there; the baseline may only shrink`;
128
140
  return failure.committed === undefined
129
141
  ? `${entry} is not in the baseline at ${failure.reference}, which may only shrink`
130
142
  : `${entry} allows ${failure.count} ${units}, above the ${failure.committed} at ${failure.reference}; the baseline may only shrink`;
@@ -143,6 +155,10 @@ export class MaintainabilityReport {
143
155
  }
144
156
  if (failure.kind === "writePlacement")
145
157
  return `sends ${failure.writes.length} server write(s) from outside a store action or a module component: ${failure.writes.join(", ")}${grown}`;
158
+ if (failure.kind === "bareError") {
159
+ const plural = failure.lines.length === 1 ? "" : "s";
160
+ return `constructs or extends ${failure.lines.length} bare Error${plural}, on line${plural} ${failure.lines.join(", ")}${grown}, and the package's total grew`;
161
+ }
146
162
  if (failure.kind === "loopCall")
147
163
  return `service method ${failure.owner} calls once per item: ${failure.calls.join(", ")}${grown}`;
148
164
  if (failure.kind === "classSize")
@@ -163,6 +179,7 @@ export class MaintainabilityReport {
163
179
  }
164
180
 
165
181
  static #fixKeyOf(sysPath: string, failure: MaintainabilityFailure): FixKey {
182
+ if (failure.kind === "staleTotal") return "staleTotal";
166
183
  if (failure.rule !== "akan.size.file") return failure.rule;
167
184
  if (sysPath.startsWith("pkgs/")) return "package";
168
185
  return MaintainabilityLimits.fileKindOf(failure.file) ?? "akan.size.component";
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
+ import { tempDirs, writeText } from "../test/testHelpers";
3
4
  import { AbstractDoc } from "./abstractDoc";
4
5
  import { AkanQualityScanner, type QualityScanResult } from "./qualityScanner";
5
- import { tempDirs, writeText } from "./testHelpers";
6
6
 
7
7
  const makeTempRoot = tempDirs("akan-quality-scanner-");
8
8
 
@@ -4,6 +4,14 @@ import path from "node:path";
4
4
  import { RESERVED_ROUTE_CONFIG_EXPORTS } from "akanjs/common";
5
5
  import ignore from "ignore";
6
6
  import ts from "typescript";
7
+ import {
8
+ facetIndexShadowOf,
9
+ isAllowedLibFacetRootFile,
10
+ libFacetRootHintOf,
11
+ rootAllowedDirs,
12
+ rootAllowedFiles,
13
+ rootEntryHintOf,
14
+ } from "../workspace/workspaceLayout";
7
15
  import { AbstractDoc } from "./abstractDoc";
8
16
  import { CommentDensityScanner } from "./commentDensityScanner";
9
17
  import { DeprecatedCommentScanner } from "./deprecatedCommentScanner";
@@ -12,14 +20,6 @@ import { KindBranchScanner } from "./kindBranchScanner";
12
20
  import { MaintainabilityExceptionScanner } from "./maintainabilityExceptionScanner";
13
21
  import { fileWarning, formatSsrBalance, type SsrBalanceEntry, SsrScanner } from "./ssrScanner";
14
22
  import { TestOnlyExportScanner } from "./testOnlyExportScanner";
15
- import {
16
- facetIndexShadowOf,
17
- isAllowedLibFacetRootFile,
18
- libFacetRootHintOf,
19
- rootAllowedDirs,
20
- rootAllowedFiles,
21
- rootEntryHintOf,
22
- } from "./workspaceLayout";
23
23
 
24
24
  type QualitySeverity = "warning";
25
25
  type QualityScope = "global" | "file" | "convention" | "layout" | "ssr" | "agent" | "comment";
@@ -8,9 +8,22 @@ export interface StoreAccessCount {
8
8
  accessCount: number;
9
9
  }
10
10
 
11
+ const formSetterPrefixes = ["set", "add", "sub", "addOrSub", "upload"];
12
+ const startsUpper = (text: string) => /^[A-Z]/.test(text);
13
+
14
+ const isFormSetterName = (name: string) => {
15
+ if (!/^\w+$/.test(name)) return false;
16
+ if (name.startsWith("writeOn")) return startsUpper(name.slice("writeOn".length));
17
+ return formSetterPrefixes.some(
18
+ (prefix) =>
19
+ name.startsWith(prefix) &&
20
+ startsUpper(name.slice(prefix.length)) &&
21
+ /On[A-Z]/.test(name.slice(prefix.length + 1)),
22
+ );
23
+ };
24
+
11
25
  //? A generated form setter only binds a field to its control: a long form is a size breach, not a busy component.
12
26
  export class StoreAccessScanner {
13
- static readonly #formSetter = /^(?:(?:set|add|sub|addOrSub|upload)[A-Z]\w*On|writeOn)[A-Z]\w*$/;
14
27
  readonly #index: WritingActionIndex;
15
28
 
16
29
  constructor(index: WritingActionIndex) {
@@ -64,7 +77,7 @@ export class StoreAccessScanner {
64
77
  access.name.text === "do" &&
65
78
  ts.isPropertyAccessExpression(action) &&
66
79
  action.expression === access &&
67
- StoreAccessScanner.#formSetter.test(action.name.text) &&
80
+ isFormSetterName(action.name.text) &&
68
81
  !this.#index.isWritingAction(action.name.text)
69
82
  );
70
83
  }
@@ -1,13 +1,13 @@
1
1
  import { describe, expect, setDefaultTimeout, test } from "bun:test";
2
2
  import { mkdir, readdir, rm } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { Executor, WorkspaceExecutor } from "./executors";
5
- import { FileSys } from "./fileSys";
4
+ import { Executor, WorkspaceExecutor } from "../executors";
5
+ import { isolateEnv, tempDirs, writeText as write } from "../test/testHelpers";
6
+ import { FileSys } from "../util/fileSys";
6
7
  import { Subspace } from "./subspace";
7
8
  import { SubspaceClone } from "./subspaceClone";
8
9
  import { SubspaceConfig } from "./subspaceConfig";
9
10
  import { SubspaceReport } from "./subspaceReport";
10
- import { isolateEnv, tempDirs, writeText as write } from "./testHelpers";
11
11
 
12
12
  //? Each case drives several real git clones and pushes; on a 4-core Windows VM that alone lands at 2-5s.
13
13
  setDefaultTimeout(20_000);
@@ -486,6 +486,12 @@ describe("Subspace pull", () => {
486
486
  });
487
487
 
488
488
  describe("SubspaceConfig", () => {
489
+ test("refuses a repo that git would read as an option", () => {
490
+ expect(
491
+ () => new SubspaceConfig({ subspaces: [{ name: "a", repo: "--upload-pack=touch pwned", apps: ["one"] }] }),
492
+ ).toThrow(/reads as a git option/);
493
+ });
494
+
489
495
  test("refuses one app claimed by two subspaces", () => {
490
496
  expect(
491
497
  () =>
@@ -1,10 +1,10 @@
1
1
  import { mkdir } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { toError } from "akanjs/common";
4
- import { AppExecutor, type WorkspaceExecutor } from "./executors";
5
- import { FileSys } from "./fileSys";
6
- import { LibSource } from "./libSource";
7
- import { SlicePlanner } from "./slicePlanner";
4
+ import { AppExecutor, type WorkspaceExecutor } from "../executors";
5
+ import { FileSys } from "../util/fileSys";
6
+ import { LibSource } from "../workspace/libSource";
7
+ import { SlicePlanner } from "../workspace/slicePlanner";
8
8
  import { SubspaceClone } from "./subspaceClone";
9
9
  import type { SubspaceConfig, SubspaceDeclaration } from "./subspaceConfig";
10
10
 
@@ -146,7 +146,7 @@ export class Subspace {
146
146
  if (remotes.includes(this.#remote)) await this.#git(["remote", "set-url", this.#remote, this.#declaration.repo]);
147
147
  else await this.#git(["remote", "add", this.#remote, this.#declaration.repo]);
148
148
  try {
149
- await this.#git(["fetch", "--quiet", this.#remote, branch]);
149
+ await this.#git(["fetch", "--quiet", "--", this.#remote, branch]);
150
150
  return true;
151
151
  } catch {
152
152
  //? A subspace that has never had this branch is not an error here — `push` refuses it by name.
@@ -1,12 +1,12 @@
1
1
  import { mkdir, readdir, rename, rm } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { toError } from "akanjs/common";
4
- import { Executor, WorkspaceExecutor } from "./executors";
5
- import { FileSys } from "./fileSys";
6
- import { LibSource } from "./libSource";
7
- import { type SlicePlan, SlicePlanner } from "./slicePlanner";
4
+ import { Executor, WorkspaceExecutor } from "../executors";
5
+ import { FileSys } from "../util/fileSys";
6
+ import { LibSource } from "../workspace/libSource";
7
+ import { type SlicePlan, SlicePlanner } from "../workspace/slicePlanner";
8
+ import type { PackageJson } from "../workspace/types";
8
9
  import { SubspaceConfig, type SubspaceDeclaration } from "./subspaceConfig";
9
- import type { PackageJson } from "./types";
10
10
 
11
11
  export class SubspaceClone {
12
12
  static readonly anchorFile = "akan.subspace.json";
@@ -53,9 +53,9 @@ export class SubspaceClone {
53
53
  if (!(await FileSys.dirExists(path.join(this.#clonePath, ".git")))) {
54
54
  await rm(this.#clonePath, { recursive: true, force: true });
55
55
  await mkdir(path.dirname(this.#clonePath), { recursive: true });
56
- await this.#workspace.spawn("git", ["clone", "--quiet", this.#declaration.repo, this.#clonePath]);
56
+ await this.#workspace.spawn("git", ["clone", "--quiet", "--", this.#declaration.repo, this.#clonePath]);
57
57
  }
58
- await this.#clone.spawn("git", ["fetch", "--quiet", "origin", branch]);
58
+ await this.#clone.spawn("git", ["fetch", "--quiet", "--", "origin", branch]);
59
59
  await this.#clone.spawn("git", ["checkout", "--quiet", "-f", "-B", branch, `origin/${branch}`]);
60
60
  await this.#clone.spawn("git", ["clean", "-qfd"]);
61
61
  }
@@ -116,7 +116,7 @@ export class SubspaceClone {
116
116
  const message = `${SubspaceClone.syncSubjectPrefix}${this.#workspace.repoName}@${sha}`;
117
117
  await this.#clone.spawn("git", ["commit", "--quiet", "-m", message]);
118
118
  //* Never force: a diverged subspace holds customer commits, and `pull` is how those come back.
119
- await this.#clone.spawn("git", ["push", "--quiet", "origin", branch]);
119
+ await this.#clone.spawn("git", ["push", "--quiet", "--", "origin", branch]);
120
120
  return (await this.#clone.spawn("git", ["rev-parse", "--short", "HEAD"])).trim();
121
121
  }
122
122
 
@@ -1,5 +1,5 @@
1
1
  import type { SubspaceConfigInput, SubspaceDeclaration } from "akanjs";
2
- import type { WorkspaceExecutor } from "./executors";
2
+ import type { WorkspaceExecutor } from "../executors";
3
3
 
4
4
  export type { SubspaceConfigInput, SubspaceDeclaration };
5
5
 
@@ -32,6 +32,10 @@ export class SubspaceConfig {
32
32
  for (const subspace of this.subspaces) {
33
33
  if (!subspace.name || !subspace.repo)
34
34
  throw new Error(`${SubspaceConfig.source}: every subspace needs a name and a repo`);
35
+ if (subspace.repo.startsWith("-"))
36
+ throw new Error(
37
+ `${SubspaceConfig.source}: subspace "${subspace.name}" repo "${subspace.repo}" reads as a git option`,
38
+ );
35
39
  //? The name is the clone folder under .akan/subspace, which a fresh clone empties first.
36
40
  if (!SubspaceConfig.namePattern.test(subspace.name))
37
41
  throw new Error(