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