@akanjs/devkit 3.2.0-rc.3 → 3.2.0-rc.30
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.
- package/CHANGELOG.md +367 -11
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +257 -1
- package/akanApp/akanApp.host.ts +146 -1223
- package/akanApp/akanApp.host.wiring.test.ts +727 -0
- package/akanApp/builderGap.ts +68 -0
- package/akanApp/builderRequestRelay.test.ts +93 -0
- package/akanApp/builderRequestRelay.ts +100 -0
- package/akanApp/builderRssRecycler.ts +182 -0
- package/akanApp/devBackend.ts +392 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +196 -0
- package/akanApp/devHostPolicy.test.ts +11 -11
- package/akanApp/devHostPolicy.ts +2 -4
- package/akanApp/devIdleSuspend.test.ts +221 -0
- package/akanApp/devIdleSuspend.ts +192 -0
- package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
- package/akanApp/devRecycler.test.ts +66 -0
- package/akanApp/devRecycler.ts +305 -0
- package/akanApp/processRss.ts +61 -0
- package/akanConfig/akanConfig.test.ts +24 -1
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiDeclarationPrinter.ts +120 -0
- package/apiReport/apiReport.test.ts +526 -0
- package/apiReport/apiReport.ts +232 -0
- package/apiReport/apiReportDiff.ts +160 -0
- package/apiReport/apiReportPolicy.ts +65 -0
- package/apiReport/apiTargets.ts +311 -0
- package/apiReport/changesetBump.ts +19 -0
- package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
- package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
- package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
- package/artifact/implicitRootLayout.test.ts +71 -3
- package/artifact/implicitRootLayout.ts +21 -4
- package/artifact/implicitRootLayoutRender.test.tsx +297 -0
- package/biome.base.json +2 -1
- package/cloud/cloudApi.test.ts +1 -1
- package/cloud/configLock.test.ts +1 -1
- package/cloud/globalConfig.test.ts +1 -1
- package/cloud/globalConfig.ts +1 -1
- package/cloud/updatePackUpload.test.ts +1 -1
- package/codeAgent/agent/AkanCodeEnv.ts +1 -1
- package/codeAgent/agent/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +10 -3
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +14 -2
- package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
- package/codeAgent/skills/akan-transport/SKILL.md +2 -0
- package/codeAgent/skills/akan-validate/SKILL.md +1 -0
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +1 -1
- package/codeAgent/tools/McpClient.ts +28 -6
- package/codeAgent/tools/McpToolPack.ts +1 -1
- package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
- package/commandDecorators/argMeta.ts +4 -0
- package/commandDecorators/cliError.ts +72 -0
- package/commandDecorators/command.ts +165 -91
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +191 -16
- package/commandDecorators/exitCodeError.ts +6 -7
- package/commandDecorators/index.ts +1 -0
- package/commandDecorators/targetMeta.ts +1 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
- package/commandDecorators/workspaceVersionCheck.ts +1 -1
- package/context/akanContext.ts +576 -0
- package/context/akanContextInspection.ts +296 -0
- package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
- package/{akanMcpContract.ts → context/akanMcpContract.ts} +32 -262
- package/context/akanMcpToolError.ts +16 -0
- package/context/doctor/agentGuideCheck.ts +81 -0
- package/context/doctor/configLeftoverCheck.ts +35 -0
- package/context/doctor/doctorFindings.ts +70 -0
- package/context/doctor/generatedFreshness.ts +56 -0
- package/context/doctor/moduleShapeCheck.ts +88 -0
- package/context/doctor/recipeDuplicateCheck.ts +39 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
- package/context/moduleFieldNames.ts +25 -0
- package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
- package/context/safeRead.ts +9 -0
- package/csrE2e/csrE2eHarness.fixture.ts +1 -1
- package/devkitUtils.test.ts +39 -5
- package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
- package/{apiReference.ts → docs/apiReference.ts} +2 -2
- package/docs/errorCodeReference.test.ts +282 -0
- package/docs/errorCodeReference.ts +71 -0
- package/docs/errorCodeScan.ts +551 -0
- package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
- package/executors/appExecutor.ts +448 -0
- package/executors/commandExecutionError.ts +53 -0
- package/executors/executor.ts +527 -0
- package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
- package/{executors.test.ts → executors/executors.test.ts} +76 -15
- package/executors/index.ts +8 -0
- package/executors/libExecutor.ts +23 -0
- package/executors/moduleExecutor.ts +18 -0
- package/executors/pkgExecutor.ts +129 -0
- package/executors/sysExecutor.ts +301 -0
- package/executors/workspaceExecutor.ts +277 -0
- package/frontendBuild/allRoutesBuilder.test.ts +17 -5
- package/frontendBuild/allRoutesBuilder.ts +24 -6
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/bundleDefine.ts +2 -0
- package/frontendBuild/clientBuildTypes.ts +5 -2
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +28 -0
- package/frontendBuild/clientEntryDiscovery.ts +25 -6
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCompiler.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.ts +7 -38
- package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
- package/frontendBuild/fontOptimizer.test.ts +1 -1
- package/frontendBuild/fontPruner.test.ts +1 -1
- package/frontendBuild/frontendBuild.test.ts +3 -3
- package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
- package/frontendBuild/hmrWatcher.test.ts +1 -1
- package/frontendBuild/hmrWatcher.ts +22 -1
- package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
- package/frontendBuild/mcpAppViewBuilder.ts +1 -1
- package/frontendBuild/nativeCore.test.ts +148 -0
- package/frontendBuild/optionalPeers.test.ts +36 -8
- package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
- package/frontendBuild/pagesBundleBuilder.ts +1 -1
- package/frontendBuild/precompressArtifacts.test.ts +1 -1
- package/frontendBuild/precompressArtifacts.ts +1 -1
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +25 -4
- package/frontendBuild/vendorImportScanner.ts +25 -10
- package/frontendBuild/vendorNarrowing.test.ts +1 -1
- package/frontendBuild/watchRootResolver.test.ts +1 -1
- package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
- package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
- package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
- package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
- package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
- package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
- package/{prompter.ts → guideline/prompter.ts} +2 -3
- package/incrementalBuilder/buildBatch.proc.ts +14 -4
- package/incrementalBuilder/buildBatchProtocol.ts +2 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +106 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +11 -0
- package/incrementalBuilder/builderGraphPayloads.ts +3 -3
- package/incrementalBuilder/builderLanes.ts +157 -0
- package/incrementalBuilder/builderWatch.ts +213 -0
- package/incrementalBuilder/csrRegistry.ts +234 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
- package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
- package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
- package/incrementalBuilder/ssrRegistry.ts +278 -0
- package/index.ts +22 -22
- package/integration/devStability.integration.test.ts +62 -56
- package/integration/devStabilityHarness.test.ts +1 -1
- package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
- package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
- package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
- package/lint/gritRules.test.ts +1 -1
- package/{linter.test.ts → lint/linter.test.ts} +1 -1
- package/lint/no-import-common-err.grit +31 -0
- package/lint/no-init-fetch-in-client.grit +1 -1
- package/lint/no-web-only-api-outside-webkit.grit +3 -3
- package/mobile/desktopBin.test.ts +1 -1
- package/mobile/desktopRelease.test.ts +1 -1
- package/mobile/desktopServerStage.test.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -1
- package/mobile/nativeApi.test.ts +1 -1
- package/mobile/nativeApp.test.ts +1 -1
- package/mobile/nativeConfig.test.ts +1 -1
- package/mobile/nativePluginFolders.test.ts +1 -1
- package/mobile/nativePublicEnv.test.ts +1 -1
- package/mobile/nativeWebDir.test.ts +1 -1
- package/mobile/serverBundleSecrets.test.ts +1 -1
- package/mobile/tarWriter.test.ts +1 -1
- package/mobile/updatePackFolder.test.ts +1 -1
- package/package.json +167 -3
- package/packageExports.test.ts +20 -2
- package/piDependencyPins.test.ts +1 -1
- package/pipeline/PipelineDefinition.ts +1 -1
- package/platformTest/IdleWatchedProcess.test.ts +1 -1
- package/platformTest/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/preview/PreviewView.ts +32 -13
- package/preview/previewView.test.ts +33 -3
- package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
- package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
- package/quality/bareErrorScanner.ts +126 -0
- package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
- package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
- package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
- package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
- package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
- package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
- package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
- package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
- package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
- package/{subspace.ts → subspace/subspace.ts} +5 -5
- package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
- package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
- package/{testHelpers.ts → test/testHelpers.ts} +37 -1
- package/transforms/barrelAnalyzer.ts +31 -10
- package/transforms/browserDirnamePlugin.test.ts +1 -1
- package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
- package/transforms/mcpAppPageTrimmer.test.ts +1 -1
- package/transforms/pureLazyMarker.test.ts +1 -1
- package/transforms/serverEnvPlugin.test.ts +1 -1
- package/transforms/serverEnvProfile.test.ts +1 -1
- package/transforms/sideEffectImportOrder.test.ts +1 -1
- package/transforms/transforms.test.ts +52 -2
- package/transforms/tsconfigPackageResolver.test.ts +1 -1
- package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
- package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
- package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
- package/typecheck/projectTypecheck.test.ts +1 -1
- package/typecheck/projectTypecheck.ts +6 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
- package/typecheck/typecheck.proc.ts +4 -3
- package/typecheck/typecheckFailure.ts +7 -2
- package/util/errorReport.ts +66 -0
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/artifacts.ts +8 -7
- package/workflow/constantSource.ts +187 -0
- package/workflow/dictionarySource.ts +184 -0
- package/workflow/executor.ts +6 -9
- package/workflow/fieldExpression.ts +153 -0
- package/workflow/fieldLabel.ts +61 -0
- package/workflow/fieldOrder.ts +117 -0
- package/workflow/fieldType.ts +93 -0
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/index.ts +1 -0
- package/workflow/keyRename.ts +1 -1
- package/workflow/moduleIndex.test.ts +2 -2
- package/workflow/moduleIndex.ts +2 -2
- package/workflow/modulePaths.ts +27 -0
- package/workflow/mutationScaffold.ts +7 -15
- package/workflow/mutationSource.ts +2 -1
- package/workflow/plainName.ts +16 -3
- package/workflow/plan.ts +14 -2
- package/workflow/primitiveReport.ts +78 -0
- package/workflow/rolloutGate.test.ts +1 -1
- package/workflow/rolloutGate.ts +1 -1
- package/workflow/serviceSource.ts +33 -0
- package/workflow/signalSource.ts +96 -0
- package/workflow/source.ts +50 -1105
- package/workflow/sourceAst.ts +30 -0
- package/workflow/sourceImports.ts +105 -0
- package/workflow/sourceText.ts +13 -0
- package/workflow/templateSource.ts +30 -0
- package/workflow/testSource.ts +31 -0
- package/workflow/types.ts +1 -1
- package/workflow/uiPolicy.ts +1 -1
- package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
- package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
- package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
- package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
- package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
- package/{envSeed.ts → workspace/envSeed.ts} +1 -1
- package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
- package/{libSource.ts → workspace/libSource.ts} +1 -1
- package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
- package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
- package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
- package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1084
- package/constantFieldNames.ts +0 -18
- package/executors.ts +0 -1749
- /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
- /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
- /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
- /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
- /package/{linter.ts → lint/linter.ts} +0 -0
- /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
- /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
- /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
- /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
- /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
- /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
- /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
- /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
- /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
- /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
- /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
- /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
- /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
- /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
- /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
- /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
- /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
- /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
- /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
- /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
- /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
- /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
- /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
- /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
- /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
- /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
- /package/{storeSource.ts → quality/storeSource.ts} +0 -0
- /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
- /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
- /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
- /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
- /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
- /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
- /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
- /package/{writePath.ts → quality/writePath.ts} +0 -0
- /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
- /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
- /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
- /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
- /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
- /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
- /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
- /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
- /package/{fileSys.ts → util/fileSys.ts} +0 -0
- /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /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
|
-
|
|
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
|
|
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(
|
|
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
|
|
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
|
-
...(
|
|
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(
|
|
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
|
-
|
|
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,
|
|
430
|
-
//* branch or one whose paid-off file was removed, and the breaches it had for a
|
|
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
|
-
|
|
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], {
|
|
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
|
}
|
package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts}
RENAMED
|
@@ -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
|
-
:
|
|
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
|
|
127
|
-
: `${entry} allows ${failure.count} ${units}, above the ${failure.committed} the code at ${failure.reference} holds with no
|
|
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
|
-
|
|
80
|
+
isFormSetterName(action.name.text) &&
|
|
68
81
|
!this.#index.isWritingAction(action.name.text)
|
|
69
82
|
);
|
|
70
83
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { describe, expect, setDefaultTimeout, test } from "bun:test";
|
|
1
|
+
import { describe, expect, setDefaultTimeout, spyOn, 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 "
|
|
5
|
-
import {
|
|
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);
|
|
@@ -214,6 +214,21 @@ describe("Subspace push", () => {
|
|
|
214
214
|
expect(await FileSys.fileExists(path.join(subspaceRoot, "libs/moved-kit/common/renamed.ts"))).toBe(true);
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
+
test("puts `--` before every repo and remote it hands git, so none reads as an option", async () => {
|
|
218
|
+
const { bareRoot, clonePath, subspace } = await makeMirror("dash-served", "dash-private", "dash-kit");
|
|
219
|
+
const spawn = spyOn(Executor.prototype, "spawn");
|
|
220
|
+
try {
|
|
221
|
+
expect((await subspace.push("develop", { verify: false })).outcome).toBe("pushed");
|
|
222
|
+
const gitArgs = spawn.mock.calls.filter(([command]) => command === "git").map(([, args]) => args);
|
|
223
|
+
expect(gitArgs).toContainEqual(["fetch", "--quiet", "--", "subspace-acme", "develop"]);
|
|
224
|
+
expect(gitArgs).toContainEqual(["clone", "--quiet", "--", bareRoot, clonePath]);
|
|
225
|
+
expect(gitArgs).toContainEqual(["fetch", "--quiet", "--", "origin", "develop"]);
|
|
226
|
+
expect(gitArgs).toContainEqual(["push", "--quiet", "--", "origin", "develop"]);
|
|
227
|
+
} finally {
|
|
228
|
+
spawn.mockRestore();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
217
232
|
test("is idempotent — a second push with no workspace change is skipped", async () => {
|
|
218
233
|
const { subspace } = await makeMirror("idem-served", "idem-private", "idem-kit");
|
|
219
234
|
expect((await subspace.push("develop", { verify: false })).outcome).toBe("pushed");
|
|
@@ -486,6 +501,12 @@ describe("Subspace pull", () => {
|
|
|
486
501
|
});
|
|
487
502
|
|
|
488
503
|
describe("SubspaceConfig", () => {
|
|
504
|
+
test("refuses a repo that git would read as an option", () => {
|
|
505
|
+
expect(
|
|
506
|
+
() => new SubspaceConfig({ subspaces: [{ name: "a", repo: "--upload-pack=touch pwned", apps: ["one"] }] }),
|
|
507
|
+
).toThrow(/reads as a git option/);
|
|
508
|
+
});
|
|
509
|
+
|
|
489
510
|
test("refuses one app claimed by two subspaces", () => {
|
|
490
511
|
expect(
|
|
491
512
|
() =>
|
|
@@ -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 "
|
|
5
|
-
import { FileSys } from "
|
|
6
|
-
import { LibSource } from "
|
|
7
|
-
import { SlicePlanner } from "
|
|
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 "
|
|
5
|
-
import { FileSys } from "
|
|
6
|
-
import { LibSource } from "
|
|
7
|
-
import { type SlicePlan, SlicePlanner } from "
|
|
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 "
|
|
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(
|