@akanjs/devkit 3.2.0-rc.2 → 3.2.0-rc.20
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 +315 -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 +10 -1
- 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} +33 -263
- 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 +58 -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 -11
- package/preview/previewView.test.ts +76 -9
- 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} +9 -3
- 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 +26 -8
- 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 +29 -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 +2 -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 +28 -0
- package/workflow/plan.ts +15 -9
- 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} +85 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +41 -6
- 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
|
@@ -153,25 +153,10 @@ export class SsrBaseArtifactBuilder {
|
|
|
153
153
|
const rscClientUrl = clientBundle.entryUrlsByAbsPath.get(rscClientEntry) ?? "";
|
|
154
154
|
const rscRuntimeSsrManifest = {
|
|
155
155
|
moduleLoading: null,
|
|
156
|
-
moduleMap:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
!ssrOutput ||
|
|
162
|
-
key !== `${clientBundle.clientReferenceIdByAbsPath.get(rscSegmentOutletEntry)}#${row.name}`
|
|
163
|
-
) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
return [
|
|
167
|
-
row.id,
|
|
168
|
-
{ [row.name]: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: row.name, async: true } },
|
|
169
|
-
];
|
|
170
|
-
})
|
|
171
|
-
.filter(
|
|
172
|
-
(entry): entry is [string, Record<string, { id: string; chunks: string[]; name: string; async: true }>] =>
|
|
173
|
-
Boolean(entry),
|
|
174
|
-
),
|
|
156
|
+
moduleMap: SsrBaseArtifactBuilder.outletModuleMap(
|
|
157
|
+
clientBundle.manifest,
|
|
158
|
+
clientBundle.clientReferenceIdByAbsPath.get(rscSegmentOutletEntry),
|
|
159
|
+
ssrBundle.entryOutputAbsByAbsPath.get(rscSegmentOutletEntry),
|
|
175
160
|
),
|
|
176
161
|
};
|
|
177
162
|
const vendorMap = Object.fromEntries(
|
|
@@ -190,6 +175,25 @@ export class SsrBaseArtifactBuilder {
|
|
|
190
175
|
},
|
|
191
176
|
};
|
|
192
177
|
}
|
|
178
|
+
|
|
179
|
+
/** Every export of the outlet module shares one client id, so each joins that id's row instead of replacing it. */
|
|
180
|
+
static outletModuleMap(
|
|
181
|
+
manifest: NonNullable<BaseBuildArtifact["rscRuntimeClientManifest"]>,
|
|
182
|
+
outletReferenceId: string | undefined,
|
|
183
|
+
ssrOutput: string | undefined,
|
|
184
|
+
) {
|
|
185
|
+
const moduleMap: Record<string, Record<string, { id: string; chunks: string[]; name: string; async: true }>> = {};
|
|
186
|
+
if (!ssrOutput || !outletReferenceId) return moduleMap;
|
|
187
|
+
for (const [key, row] of Object.entries(manifest)) {
|
|
188
|
+
if (key !== `${outletReferenceId}#${row.name}`) continue;
|
|
189
|
+
moduleMap[row.id] = {
|
|
190
|
+
...moduleMap[row.id],
|
|
191
|
+
[row.name]: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: row.name, async: true },
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return moduleMap;
|
|
195
|
+
}
|
|
196
|
+
|
|
193
197
|
async #resolveAkanServerPath() {
|
|
194
198
|
const candidates: string[] = [];
|
|
195
199
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
3
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
4
4
|
import { SsrDevBundler } from "./ssrDevBundler";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-ssr-dev-bundler-");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
3
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
4
4
|
import { VendorImportScanner } from "./vendorImportScanner";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-vendor-imports-");
|
|
@@ -50,22 +50,43 @@ describe("VendorImportScanner", () => {
|
|
|
50
50
|
expect(used["akanjs/store"]).toEqual([]);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
test("reads the import at the end of a minified body too long for the call stack to walk", () => {
|
|
54
|
+
const body = Array.from({ length: 40_000 }, (_, i) => `a${i % 26}(${i})`).join(",");
|
|
55
|
+
|
|
56
|
+
const used = scan(`import{st}from"akanjs/store";function f(){${body},import("akanjs/fetch")}`);
|
|
57
|
+
|
|
58
|
+
expect(used).toEqual({ "akanjs/store": ["st"], "akanjs/common": [], "tailwind-merge": [] });
|
|
59
|
+
});
|
|
60
|
+
|
|
53
61
|
test("collects across every .js file of a directory", async () => {
|
|
54
62
|
const dir = await makeTempRoot();
|
|
55
63
|
await write(path.join(dir, "entry-a.js"), 'import{st}from"akanjs/store";');
|
|
56
64
|
await write(path.join(dir, "chunks/lazy.js"), 'import{RootStore}from"akanjs/store";');
|
|
57
65
|
await write(path.join(dir, "chunks/lazy.js.map"), 'import{ignored}from"akanjs/store";');
|
|
58
66
|
|
|
59
|
-
const used = await VendorImportScanner.exportsUsedIn(dir, ["akanjs/store"]);
|
|
67
|
+
const used = await VendorImportScanner.exportsUsedIn(dir, ["akanjs/store"], ["/_akan/client/entry-a.js"]);
|
|
60
68
|
|
|
61
69
|
expect(used).toEqual({ "akanjs/store": ["RootStore", "st"] });
|
|
62
70
|
});
|
|
63
71
|
|
|
64
|
-
test("reads a client output directory a build never wrote as importing nothing", async () => {
|
|
72
|
+
test("reads a client output directory a build never wrote as importing nothing when the routes have no client entry", async () => {
|
|
65
73
|
const dir = await makeTempRoot();
|
|
66
74
|
|
|
67
|
-
expect(await VendorImportScanner.exportsUsedIn(path.join(dir, "client"), ["akanjs/store"])).toEqual({
|
|
75
|
+
expect(await VendorImportScanner.exportsUsedIn(path.join(dir, "client"), ["akanjs/store"], [])).toEqual({
|
|
68
76
|
"akanjs/store": [],
|
|
69
77
|
});
|
|
70
78
|
});
|
|
79
|
+
|
|
80
|
+
test("fails, naming the entry, when a route client entry is not in the directory it scans", async () => {
|
|
81
|
+
const dir = await makeTempRoot();
|
|
82
|
+
await write(path.join(dir, "chunks/shared.js"), 'import{st}from"akanjs/store";');
|
|
83
|
+
const entries = ["/_akan/client/page-a1.js", "/_akan/client/page-a1.js", "/_akan/client/chunks/shared.js"];
|
|
84
|
+
|
|
85
|
+
await expect(VendorImportScanner.exportsUsedIn(dir, ["akanjs/store"], entries)).rejects.toThrow(
|
|
86
|
+
`no file under ${dir} for the route client entries /_akan/client/page-a1.js`,
|
|
87
|
+
);
|
|
88
|
+
await expect(
|
|
89
|
+
VendorImportScanner.exportsUsedIn(path.join(dir, "missing"), ["akanjs/store"], ["/_akan/client/page-a1.js"]),
|
|
90
|
+
).rejects.toThrow("/_akan/client/page-a1.js");
|
|
91
|
+
});
|
|
71
92
|
});
|
|
@@ -12,25 +12,40 @@ export class VendorImportScanner {
|
|
|
12
12
|
for (const specifier of specifiers) this.#names.set(specifier, new Set());
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
static async exportsUsedIn(
|
|
16
|
+
dir: string,
|
|
17
|
+
specifiers: readonly string[],
|
|
18
|
+
entryUrls: readonly string[],
|
|
19
|
+
): Promise<Record<string, string[]>> {
|
|
17
20
|
const scanner = new VendorImportScanner(specifiers);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const scanned: string[] = [];
|
|
22
|
+
if (fs.existsSync(dir))
|
|
23
|
+
for await (const relative of new Bun.Glob("**/*.js").scan({ cwd: dir })) {
|
|
24
|
+
scanner.scan(await Bun.file(path.join(dir, relative)).text(), relative);
|
|
25
|
+
scanned.push(`/${relative.split(path.sep).join("/")}`);
|
|
26
|
+
}
|
|
27
|
+
const unread = [...new Set(entryUrls)].filter((url) => !scanned.some((relative) => url.endsWith(relative)));
|
|
28
|
+
if (unread.length > 0) {
|
|
29
|
+
const named = `${unread.slice(0, 3).join(", ")}${unread.length > 3 ? `, and ${unread.length - 3} more` : ""}`;
|
|
30
|
+
throw new Error(
|
|
31
|
+
`[VendorImportScanner] no file under ${dir} for the route client entries ${named}; narrowing the vendor entries without them would drop names those pages import`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
21
34
|
return scanner.usedExports();
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
scan(source: string, fileName = "chunk.js"): this {
|
|
25
38
|
if (![...this.#specifiers].some((specifier) => source.includes(specifier))) return this;
|
|
26
|
-
|
|
27
|
-
const
|
|
39
|
+
//? A stack, not recursion: minified code folds a long body into one comma chain, deeper than the call stack.
|
|
40
|
+
const stack: ts.Node[] = [ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, false, ts.ScriptKind.JS)];
|
|
41
|
+
for (let node = stack.pop(); node; node = stack.pop()) {
|
|
28
42
|
if (ts.isImportDeclaration(node)) this.#readImport(node);
|
|
29
43
|
else if (ts.isExportDeclaration(node)) this.#readExport(node);
|
|
30
44
|
else if (ts.isCallExpression(node)) this.#readCall(node);
|
|
31
|
-
ts.forEachChild(node,
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
ts.forEachChild(node, (child) => {
|
|
46
|
+
stack.push(child);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
34
49
|
return this;
|
|
35
50
|
}
|
|
36
51
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs, writeText as write } from "../testHelpers";
|
|
4
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
5
5
|
import { ClientEntriesBundler } from "./clientEntriesBundler";
|
|
6
6
|
import { VendorNarrowing } from "./vendorNarrowing";
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import type { App } from "../commandDecorators";
|
|
5
|
-
import { tempDirs } from "../testHelpers";
|
|
5
|
+
import { tempDirs } from "../test/testHelpers";
|
|
6
6
|
import { WatchRootResolver } from "./watchRootResolver";
|
|
7
7
|
|
|
8
8
|
const tempRoot = tempDirs("akan-watch-roots-");
|
|
@@ -49,7 +49,7 @@ describe("AgentAssets", () => {
|
|
|
49
49
|
test("names no rule or skill file that a new workspace's .gitignore would keep out of git", async () => {
|
|
50
50
|
const assets = [...(await AgentAssets.rules()), ...(await AgentAssets.skills())];
|
|
51
51
|
const root = await fsPromise.mkdtemp(path.join(os.tmpdir(), "akan-agent-ignore-"));
|
|
52
|
-
const template = path.join(import.meta.dir, "
|
|
52
|
+
const template = path.join(import.meta.dir, "../../cli/templates/workspaceRoot/.gitignore.template");
|
|
53
53
|
await fsPromise.copyFile(template, path.join(root, ".gitignore"));
|
|
54
54
|
Bun.spawnSync(["git", "init", "-q"], { cwd: root });
|
|
55
55
|
const proc = Bun.spawn(["git", "check-ignore", "--no-index", "--stdin"], {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fsPromise from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { akanCodePaths } from "
|
|
3
|
+
import { akanCodePaths } from "../codeAgent/agent/akanCodePaths";
|
|
4
4
|
import { type ConventionRule, ConventionSet } from "./conventionSet";
|
|
5
5
|
import { Prompter } from "./prompter";
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ export class AgentAssets {
|
|
|
45
45
|
"modelUtil",
|
|
46
46
|
"framework",
|
|
47
47
|
],
|
|
48
|
-
"akan-err": [],
|
|
48
|
+
"akan-err": ["errorCodes"],
|
|
49
49
|
"akan-deps": [],
|
|
50
50
|
"akan-debug": [],
|
|
51
51
|
"akan-page": ["pageRule", "akanApi"],
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import type { RecipeInfo } from "../context/recipeScanner";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
3
5
|
import {
|
|
4
6
|
AGENT_BLOCK_END,
|
|
5
7
|
AGENT_BLOCK_START,
|
|
@@ -11,8 +13,6 @@ import {
|
|
|
11
13
|
renderScopeClaudeMd,
|
|
12
14
|
upsertAgentBlock,
|
|
13
15
|
} from "./agentsIndex";
|
|
14
|
-
import type { RecipeInfo } from "./recipeScanner";
|
|
15
|
-
import { tempDirs, writeText } from "./testHelpers";
|
|
16
16
|
|
|
17
17
|
const button: RecipeInfo = {
|
|
18
18
|
name: "buttonRecipe",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { RecipeInfo, RecipeSource } from "
|
|
1
|
+
import type { RecipeInfo, RecipeSource } from "../context/recipeScanner";
|
|
2
2
|
|
|
3
3
|
// Lazy: recipeScanner loads `typescript` (~65MB) and this module sits in the CLI entry graph (entryModuleGraph test).
|
|
4
|
-
let recipeScannerLoad: Promise<typeof import("
|
|
5
|
-
const loadRecipeScanner = () => (recipeScannerLoad ??= import("
|
|
4
|
+
let recipeScannerLoad: Promise<typeof import("../context/recipeScanner")> | null = null;
|
|
5
|
+
const loadRecipeScanner = () => (recipeScannerLoad ??= import("../context/recipeScanner"));
|
|
6
6
|
|
|
7
7
|
//* Split by ownership (root: framework recipes; each app/lib: what it may import), so always-loaded context does not
|
|
8
8
|
//* grow with the app count and no unimportable neighbour recipe is listed.
|
|
@@ -23,13 +23,16 @@ export const extractBlockVersion = (content: string): string | null =>
|
|
|
23
23
|
/** The running `@akanjs/devkit` version; null when its package.json is unreadable, which must not fail a doctor run. */
|
|
24
24
|
export const readDevkitVersion = async (): Promise<string | null> => {
|
|
25
25
|
const { readFile } = await import("node:fs/promises");
|
|
26
|
-
const { getDirname } = await import("
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const { getDirname } = await import("../util/fileSys");
|
|
27
|
+
const dirname = getDirname(import.meta.url);
|
|
28
|
+
for (const candidate of [`${dirname}/package.json`, `${dirname}/../package.json`]) {
|
|
29
|
+
try {
|
|
30
|
+
return (JSON.parse(await readFile(candidate, "utf-8")) as { version?: string }).version ?? null;
|
|
31
|
+
} catch {
|
|
32
|
+
//? The bundled CLI sits beside its own package.json; devkit's source sits one folder below its own.
|
|
33
|
+
}
|
|
32
34
|
}
|
|
35
|
+
return null;
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
export interface AgentsIndexScope {
|
|
@@ -45,7 +48,7 @@ export const upsertAgentBlock = (existing: string, block: string): string => {
|
|
|
45
48
|
if (startIndex >= 0 && endIndex > startIndex) {
|
|
46
49
|
return `${existing.slice(0, startIndex)}${managed}${existing.slice(endIndex + AGENT_BLOCK_END.length)}`;
|
|
47
50
|
}
|
|
48
|
-
return `${existing.
|
|
51
|
+
return `${existing.trimEnd()}\n\n${managed}\n`;
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
/** The content between the akan:agent markers, or null when the file carries no managed block. */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import fsPromise from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { MaintainabilityContract } from "../quality/maintainabilityContract";
|
|
5
|
+
import { MaintainabilityLimits } from "../quality/maintainabilityLimits";
|
|
4
6
|
import { ConventionSet } from "./conventionSet";
|
|
5
|
-
import { MaintainabilityContract } from "./maintainabilityContract";
|
|
6
7
|
import { Prompter } from "./prompter";
|
|
7
8
|
|
|
8
9
|
describe("ConventionSet", () => {
|
|
@@ -49,17 +50,19 @@ describe("ConventionSet", () => {
|
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
test("names only checks that exist, and names every lint plugin and maintainability gate
|
|
53
|
+
test("names only checks that exist, and names every lint plugin and maintainability gate a workspace runs", async () => {
|
|
53
54
|
const set = await Prompter.getConventionSet();
|
|
54
55
|
const named = new Set(
|
|
55
56
|
[set.core, ...set.rules.map((rule) => rule.body)].flatMap((text) =>
|
|
56
57
|
[...text.matchAll(/`([^`\s]+)`/g)].map((match) => match[1] ?? ""),
|
|
57
58
|
),
|
|
58
59
|
);
|
|
59
|
-
const plugins = (await fsPromise.readdir(path.join(import.meta.dir, "lint")))
|
|
60
|
+
const plugins = (await fsPromise.readdir(path.join(import.meta.dir, "../lint")))
|
|
60
61
|
.filter((file) => file.endsWith(".grit"))
|
|
61
62
|
.map((file) => file.slice(0, -".grit".length));
|
|
62
|
-
const gates: readonly string[] = MaintainabilityContract.ruleIds
|
|
63
|
+
const gates: readonly string[] = MaintainabilityContract.ruleIds.filter(
|
|
64
|
+
(id) => !MaintainabilityLimits.repoOnlyRules.has(id),
|
|
65
|
+
);
|
|
63
66
|
const gateAreas = new Set(gates.map((id) => id.split(".").slice(0, 2).join(".")));
|
|
64
67
|
const isPluginName = (name: string) => /^non?-[a-z]+(-[a-z]+)+$/.test(name);
|
|
65
68
|
const isGateName = (name: string) =>
|
|
@@ -29,7 +29,7 @@ export class ConventionSet {
|
|
|
29
29
|
const match: RegExpExecArray | null = /^---\n([\s\S]*?)\n---\n/.exec(text);
|
|
30
30
|
if (!match) throw new Error(`Convention rule ${name} has no frontmatter`);
|
|
31
31
|
const front = match[1] ?? "";
|
|
32
|
-
const described: RegExpExecArray | null = /^description
|
|
32
|
+
const described: RegExpExecArray | null = /^description:(.*)$/m.exec(front);
|
|
33
33
|
const description = described?.[1]?.trim() ?? "";
|
|
34
34
|
const paths = [...front.matchAll(/^\s+-\s+"([^"]+)"$/gm)].map((entry) => entry[1] ?? "");
|
|
35
35
|
if (!description || paths.length === 0) throw new Error(`Convention rule ${name} needs a description and paths`);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fsPromise from "node:fs/promises";
|
|
2
2
|
import { input, select } from "@inquirer/prompts";
|
|
3
|
-
|
|
3
|
+
import { getDirname } from "../util/fileSys";
|
|
4
4
|
import { ConventionSet } from "./conventionSet";
|
|
5
|
-
import { getDirname } from "./fileSys";
|
|
6
5
|
|
|
7
6
|
interface FileUpdateRequestProps {
|
|
8
7
|
context: string;
|
|
@@ -11,7 +10,7 @@ interface FileUpdateRequestProps {
|
|
|
11
10
|
export class Prompter {
|
|
12
11
|
static async #getGuidelineRoot() {
|
|
13
12
|
const dirname = getDirname(import.meta.url);
|
|
14
|
-
const candidates = [`${dirname}/guidelines`, `${dirname}
|
|
13
|
+
const candidates = [`${dirname}/guidelines`, `${dirname}/../../cli/guidelines`];
|
|
15
14
|
for (const candidate of candidates) {
|
|
16
15
|
try {
|
|
17
16
|
await fsPromise.access(candidate);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { ApplicationBuildReporter } from "@akanjs/devkit/applicationBuildReporter";
|
|
2
|
+
import { ApplicationBuildReporter } from "@akanjs/devkit/app/applicationBuildReporter";
|
|
3
3
|
import { resolveSsrPageEntriesForApp } from "@akanjs/devkit/artifact/implicitRootLayout";
|
|
4
4
|
import { computeRouteSeedIndex, saveRouteSeedIndex } from "@akanjs/devkit/artifact/routeSeedIndex";
|
|
5
5
|
import type { App } from "@akanjs/devkit/commandDecorators";
|
|
@@ -47,7 +47,7 @@ class BuildBatch {
|
|
|
47
47
|
return this.#result;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// A bare `process.send` is safe only because
|
|
50
|
+
// A bare `process.send` is safe only because `main` exits once the runner has read the result sent after it;
|
|
51
51
|
// an explicit `process.exit` after an emit would silently drop payloads (route through BuilderChannel then).
|
|
52
52
|
#emit(message: BuilderMessage): void {
|
|
53
53
|
process.send?.(message);
|
|
@@ -294,6 +294,16 @@ class BuildBatch {
|
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
// Bounded, so a runner that never releases this process cannot keep the bundler arenas alive.
|
|
298
|
+
static #report(result: BuildBatchResult): Promise<void> {
|
|
299
|
+
if (!process.send) return Promise.resolve();
|
|
300
|
+
return new Promise((resolve) => {
|
|
301
|
+
process.once("disconnect", () => resolve());
|
|
302
|
+
process.send?.({ type: "build-batch-result", data: result });
|
|
303
|
+
setTimeout(() => process.disconnect?.(), 5_000).unref();
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
297
307
|
static async main(): Promise<void> {
|
|
298
308
|
const raw = process.argv[2];
|
|
299
309
|
if (!raw) throw new Error("[build-batch] missing request argument");
|
|
@@ -312,12 +322,12 @@ class BuildBatch {
|
|
|
312
322
|
// Seeded, not rediscovered: route discovery would be the largest cost of spawning this process.
|
|
313
323
|
if (request.pageKeys) app.setPageKeys(request.pageKeys);
|
|
314
324
|
//? Exits with the builder that spawned it (a kill, a crash, a restart for a metadata save): left running, it would
|
|
315
|
-
//? write a registry its replacement is rebuilding. Removed before
|
|
325
|
+
//? write a registry its replacement is rebuilding. Removed before reporting, as the runner's release is a disconnect.
|
|
316
326
|
const orphaned = () => process.exit(1);
|
|
317
327
|
process.on("disconnect", orphaned);
|
|
318
328
|
const result = await new BuildBatch(request, app).run();
|
|
319
|
-
process.send?.({ type: "build-batch-result", data: result });
|
|
320
329
|
process.off("disconnect", orphaned);
|
|
330
|
+
await BuildBatch.#report(result);
|
|
321
331
|
}
|
|
322
332
|
}
|
|
323
333
|
|
|
@@ -22,6 +22,8 @@ export interface BuildBatchRequest {
|
|
|
22
22
|
trace?: HmrTrace;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export type BatchWork = Pick<BuildBatchRequest, "generation" | "needs" | "changedFiles" | "trace">;
|
|
26
|
+
|
|
25
27
|
export type PagesBatchCssAssets = CssPayload["cssAssets"];
|
|
26
28
|
|
|
27
29
|
// Browser payloads stream as each need finishes; only state the next batch needs travels back here.
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
|
-
import { createTempApp, tempRoots, writeText } from "../testHelpers";
|
|
4
|
+
import { createTempApp, tempRoots, writeText } from "../test/testHelpers";
|
|
5
|
+
import type { BuildBatchMessage, BuildBatchRequest, BuildBatchResult } from "./buildBatchProtocol";
|
|
4
6
|
import { BuildBatchRunner } from "./buildBatchRunner";
|
|
5
7
|
|
|
6
8
|
const track = tempRoots();
|
|
9
|
+
const isAlive = (pid: number) => {
|
|
10
|
+
try {
|
|
11
|
+
process.kill(pid, 0);
|
|
12
|
+
return true;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
7
17
|
|
|
8
18
|
describe("BuildBatchRunner", () => {
|
|
9
19
|
test("reports a boot build the bundler refuses with where each reason sits in the workspace", async () => {
|
|
@@ -62,4 +72,101 @@ setTimeout(() => process.exit(1), 50);
|
|
|
62
72
|
expect(result.errors.css).toBe("css broke");
|
|
63
73
|
expect(result.errors.pages).toContain("exited with code 1");
|
|
64
74
|
}, 30_000);
|
|
75
|
+
|
|
76
|
+
test("releases a worker as soon as its result arrives, so one that holds its exit for that is not left waiting", async () => {
|
|
77
|
+
const { root } = track(await createTempApp("demo"));
|
|
78
|
+
const appDir = path.join(root, "apps/demo");
|
|
79
|
+
const released = path.join(root, "released");
|
|
80
|
+
await writeText(
|
|
81
|
+
path.join(root, "pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts"),
|
|
82
|
+
`import fs from "node:fs";
|
|
83
|
+
const { generation } = JSON.parse(process.argv[2]);
|
|
84
|
+
process.once("disconnect", () => fs.writeFileSync(${JSON.stringify(released)}, ""));
|
|
85
|
+
process.send({ type: "build-batch-result", data: { generation, errors: {} } });
|
|
86
|
+
setTimeout(() => process.exit(1), 2_000).unref();
|
|
87
|
+
`,
|
|
88
|
+
);
|
|
89
|
+
const result = await new BuildBatchRunner({ workspaceRoot: root, cwd: appDir }).run({
|
|
90
|
+
appName: "demo",
|
|
91
|
+
workspaceRoot: root,
|
|
92
|
+
repoName: "repo",
|
|
93
|
+
generation: 3,
|
|
94
|
+
needs: ["pages"],
|
|
95
|
+
changedFiles: [],
|
|
96
|
+
pageKeys: null,
|
|
97
|
+
optimizedFonts: null,
|
|
98
|
+
cssAssets: null,
|
|
99
|
+
artifactDir: path.join(appDir, ".akan/artifact"),
|
|
100
|
+
});
|
|
101
|
+
expect(result).toEqual({ generation: 3, errors: {} });
|
|
102
|
+
const deadline = Date.now() + 1_500;
|
|
103
|
+
while (!(await Bun.file(released).exists()) && Date.now() < deadline) await Bun.sleep(20);
|
|
104
|
+
expect(await Bun.file(released).exists()).toBe(true);
|
|
105
|
+
}, 30_000);
|
|
106
|
+
|
|
107
|
+
test("returns a result as it arrives from a worker the release never reaches, then kills that worker", async () => {
|
|
108
|
+
const { root } = track(await createTempApp("demo"));
|
|
109
|
+
const appDir = path.join(root, "apps/demo");
|
|
110
|
+
const sent = path.join(root, "sent");
|
|
111
|
+
await writeText(
|
|
112
|
+
path.join(root, "pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts"),
|
|
113
|
+
`import fs from "node:fs";
|
|
114
|
+
const { generation } = JSON.parse(process.argv[2]);
|
|
115
|
+
fs.writeFileSync(${JSON.stringify(sent)}, String(process.pid));
|
|
116
|
+
process.send({ type: "build-batch-result", data: { generation, errors: {} } });
|
|
117
|
+
setTimeout(() => process.exit(0), 5_000);
|
|
118
|
+
`,
|
|
119
|
+
);
|
|
120
|
+
const result = await new BuildBatchRunner({ workspaceRoot: root, cwd: appDir }).run({
|
|
121
|
+
appName: "demo",
|
|
122
|
+
workspaceRoot: root,
|
|
123
|
+
repoName: "repo",
|
|
124
|
+
generation: 5,
|
|
125
|
+
needs: ["pages"],
|
|
126
|
+
changedFiles: [],
|
|
127
|
+
pageKeys: null,
|
|
128
|
+
optimizedFonts: null,
|
|
129
|
+
cssAssets: null,
|
|
130
|
+
artifactDir: path.join(appDir, ".akan/artifact"),
|
|
131
|
+
});
|
|
132
|
+
//? Read before any await: the kill timer cannot fire until this turn's microtasks are done.
|
|
133
|
+
const pid = Number(readFileSync(sent, "utf8"));
|
|
134
|
+
const upAtReturn = isAlive(pid);
|
|
135
|
+
expect(result).toEqual({ generation: 5, errors: {} });
|
|
136
|
+
expect(upAtReturn).toBe(true);
|
|
137
|
+
const deadline = Date.now() + 3_000;
|
|
138
|
+
while (isAlive(pid) && Date.now() < deadline) await Bun.sleep(20);
|
|
139
|
+
expect(isAlive(pid)).toBe(false);
|
|
140
|
+
}, 30_000);
|
|
141
|
+
|
|
142
|
+
test("the build worker stays up after reporting its result until its runner releases it", async () => {
|
|
143
|
+
const { root } = track(await createTempApp("demo", path.join(import.meta.dir, "..", "local")));
|
|
144
|
+
const appDir = path.join(root, "apps/demo");
|
|
145
|
+
const request = {
|
|
146
|
+
appName: "demo",
|
|
147
|
+
workspaceRoot: root,
|
|
148
|
+
repoName: "repo",
|
|
149
|
+
generation: 4,
|
|
150
|
+
needs: [],
|
|
151
|
+
changedFiles: [],
|
|
152
|
+
pageKeys: [],
|
|
153
|
+
optimizedFonts: null,
|
|
154
|
+
cssAssets: null,
|
|
155
|
+
artifactDir: path.join(appDir, ".akan/artifact"),
|
|
156
|
+
} satisfies BuildBatchRequest;
|
|
157
|
+
const { promise: reported, resolve: report } = Promise.withResolvers<BuildBatchResult>();
|
|
158
|
+
const worker = Bun.spawn(["bun", path.join(import.meta.dir, "buildBatch.proc.ts"), JSON.stringify(request)], {
|
|
159
|
+
cwd: appDir,
|
|
160
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
161
|
+
serialization: "advanced",
|
|
162
|
+
ipc: (message: BuildBatchMessage) => {
|
|
163
|
+
if (message.type === "build-batch-result") report(message.data);
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
expect(await reported).toEqual({ generation: 4, errors: {} });
|
|
167
|
+
const unreleased = await Promise.race([worker.exited.then(() => "exited"), Bun.sleep(300).then(() => "running")]);
|
|
168
|
+
worker.disconnect();
|
|
169
|
+
expect(unreleased).toBe("running");
|
|
170
|
+
expect(await worker.exited).toBe(0);
|
|
171
|
+
}, 30_000);
|
|
65
172
|
});
|
|
@@ -7,6 +7,7 @@ import type { BuildBatchMessage, BuildBatchRequest, BuildBatchResult } from "./b
|
|
|
7
7
|
// their own work (the slow lane, the css queue, the SSR registry's boot build beside them), so a few can overlap.
|
|
8
8
|
// A worker that dies without reporting must not take the watcher down; its needs come back as errors.
|
|
9
9
|
export class BuildBatchRunner {
|
|
10
|
+
static readonly #exitGraceMs = 500;
|
|
10
11
|
#logger = new Logger("BuildBatchRunner");
|
|
11
12
|
#entry: string | null = null;
|
|
12
13
|
#workspaceRoot: string;
|
|
@@ -39,6 +40,7 @@ export class BuildBatchRunner {
|
|
|
39
40
|
const started = Date.now();
|
|
40
41
|
const entry = await this.#resolveEntry();
|
|
41
42
|
let result: BuildBatchResult | null = null;
|
|
43
|
+
const resultArrived = Promise.withResolvers<null>();
|
|
42
44
|
const reported = new Map<string, string | undefined>();
|
|
43
45
|
const payload = request.trace ? { ...request, trace: { ...request.trace, spawnAt: Date.now() } } : request;
|
|
44
46
|
// argv rather than IPC, so the worker starts on its first tick instead of waiting for a handshake.
|
|
@@ -47,16 +49,27 @@ export class BuildBatchRunner {
|
|
|
47
49
|
env: process.env,
|
|
48
50
|
stdio: ["ignore", "inherit", "inherit"],
|
|
49
51
|
serialization: "advanced",
|
|
50
|
-
ipc: (message: BuildBatchMessage | BuilderMessage) => {
|
|
52
|
+
ipc: (message: BuildBatchMessage | BuilderMessage, worker) => {
|
|
51
53
|
if (!message || typeof message !== "object") return;
|
|
52
|
-
if (message.type === "build-batch-result")
|
|
53
|
-
|
|
54
|
+
if (message.type === "build-batch-result") {
|
|
55
|
+
result = message.data;
|
|
56
|
+
// On Bun 1.4 a worker that exits within ms of spawning can lose everything it sent: it exits on this release.
|
|
57
|
+
worker.disconnect();
|
|
58
|
+
//? Bun on Windows may never deliver that release; the worker would hold its arenas for its own 5 s bound.
|
|
59
|
+
const lingering = setTimeout(() => {
|
|
60
|
+
this.#logger.verbose(`[build-batch] worker still up ${BuildBatchRunner.#exitGraceMs}ms after its result`);
|
|
61
|
+
worker.kill("SIGKILL");
|
|
62
|
+
}, BuildBatchRunner.#exitGraceMs);
|
|
63
|
+
void worker.exited.then(() => clearTimeout(lingering));
|
|
64
|
+
resultArrived.resolve(null);
|
|
65
|
+
} else {
|
|
54
66
|
if (message.type === "build-status") reported.set(message.data.phase, message.data.message);
|
|
55
67
|
onMessage(message);
|
|
56
68
|
}
|
|
57
69
|
},
|
|
58
70
|
});
|
|
59
|
-
|
|
71
|
+
//? On the result, not the exit: a worker the release never reaches would make each batch wait for the kill.
|
|
72
|
+
const exitCode = await Promise.race([proc.exited, resultArrived.promise]);
|
|
60
73
|
if (result) {
|
|
61
74
|
this.#logger.verbose(
|
|
62
75
|
`[build-batch] generation=${request.generation} needs=${request.needs.join(",")} done in ${Date.now() - started}ms`,
|