@akanjs/devkit 3.2.0-rc.2 → 3.2.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +350 -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 +13 -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} +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
package/workflow/sourceAst.ts
CHANGED
|
@@ -10,3 +10,33 @@ export const {
|
|
|
10
10
|
firstObjectReturnedByArrow,
|
|
11
11
|
heritageCall,
|
|
12
12
|
} = createAst(ts);
|
|
13
|
+
|
|
14
|
+
export const hasParseDiagnostics = (source: ts.SourceFile) =>
|
|
15
|
+
((source as ts.SourceFile & { parseDiagnostics?: readonly ts.Diagnostic[] }).parseDiagnostics ?? []).length > 0;
|
|
16
|
+
|
|
17
|
+
export const hasSourceParseErrors = (content: string, fileName = "source.ts") =>
|
|
18
|
+
hasParseDiagnostics(sourceFileFor(fileName, content));
|
|
19
|
+
|
|
20
|
+
export const findClassDeclaration = (source: ts.SourceFile, className: string): ts.ClassDeclaration | null => {
|
|
21
|
+
let found: ts.ClassDeclaration | null = null;
|
|
22
|
+
const visit = (node: ts.Node) => {
|
|
23
|
+
if (found) return;
|
|
24
|
+
if (ts.isClassDeclaration(node) && node.name?.text === className) {
|
|
25
|
+
found = node;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
ts.forEachChild(node, visit);
|
|
29
|
+
};
|
|
30
|
+
ts.forEachChild(source, visit);
|
|
31
|
+
return found;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const firstHeritageCall = (node: ts.ClassDeclaration): ts.CallExpression | null => {
|
|
35
|
+
const expression = (node.heritageClauses?.flatMap((clause) => [...clause.types]) ?? [])[0]?.expression;
|
|
36
|
+
return expression && ts.isCallExpression(expression) ? expression : null;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const factoryArrowOf = (call: ts.CallExpression): ts.ArrowFunction | ts.FunctionExpression | null => {
|
|
40
|
+
const arg = call.arguments.find((argument) => ts.isArrowFunction(argument) || ts.isFunctionExpression(argument));
|
|
41
|
+
return arg && (ts.isArrowFunction(arg) || ts.isFunctionExpression(arg)) ? arg : null;
|
|
42
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { sourceFileFor } from "./sourceAst";
|
|
3
|
+
import { lineEndAt, lineStartAt, spliceText } from "./sourceText";
|
|
4
|
+
|
|
5
|
+
//? Biome's organizeImports order: case-insensitive, an uppercase name before its lowercase twin.
|
|
6
|
+
const importOrder = (a: string, b: string) => {
|
|
7
|
+
const [lowerA, lowerB] = [a.toLowerCase(), b.toLowerCase()];
|
|
8
|
+
if (lowerA !== lowerB) return lowerA < lowerB ? -1 : 1;
|
|
9
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const ensureNamedImport = (content: string, moduleSpecifier: string, name: string) => {
|
|
13
|
+
const source = sourceFileFor("source.ts", content);
|
|
14
|
+
const namedImport = findNamedImport(source, moduleSpecifier, { valueOnly: true });
|
|
15
|
+
if (!namedImport) return ensureImportDeclaration(content, moduleSpecifier, `{ ${name} }`);
|
|
16
|
+
if (namedImport.names.includes(name)) return content;
|
|
17
|
+
const nextElements = [...namedImport.elements, { name, text: name }].sort((a, b) => importOrder(a.name, b.name));
|
|
18
|
+
return spliceText(
|
|
19
|
+
content,
|
|
20
|
+
namedImport.namedBindingsStart,
|
|
21
|
+
namedImport.namedBindingsEnd,
|
|
22
|
+
`{ ${nextElements.map((element) => element.text).join(", ")} }`,
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const ensureImportDeclaration = (content: string, moduleSpecifier: string, clause: string) => {
|
|
27
|
+
const line = `import ${clause} from "${moduleSpecifier}";`;
|
|
28
|
+
if (content.includes(line)) return content;
|
|
29
|
+
const source = sourceFileFor("source.ts", content);
|
|
30
|
+
const imports = source.statements
|
|
31
|
+
.filter((statement): statement is ts.ImportDeclaration => ts.isImportDeclaration(statement))
|
|
32
|
+
.flatMap((statement) =>
|
|
33
|
+
ts.isStringLiteral(statement.moduleSpecifier)
|
|
34
|
+
? [{ specifier: statement.moduleSpecifier.text, start: statement.getStart(source), end: statement.getEnd() }]
|
|
35
|
+
: [],
|
|
36
|
+
);
|
|
37
|
+
const isRelative = (specifier: string) => specifier.startsWith(".");
|
|
38
|
+
const peers = imports.filter((entry) => isRelative(entry.specifier) === isRelative(moduleSpecifier));
|
|
39
|
+
const before = peers.find((entry) => importOrder(entry.specifier, moduleSpecifier) > 0);
|
|
40
|
+
if (before) {
|
|
41
|
+
const insertAt = lineStartAt(content, before.start);
|
|
42
|
+
return spliceText(content, insertAt, insertAt, `${line}\n`);
|
|
43
|
+
}
|
|
44
|
+
const after = peers.at(-1) ?? (isRelative(moduleSpecifier) ? imports.at(-1) : undefined);
|
|
45
|
+
if (after) {
|
|
46
|
+
const insertAt = lineEndAt(content, after.end);
|
|
47
|
+
return spliceText(content, insertAt, insertAt, peers.length ? `${line}\n` : `\n${line}\n`);
|
|
48
|
+
}
|
|
49
|
+
const insertAt = imports[0] ? lineStartAt(content, imports[0].start) : 0;
|
|
50
|
+
return spliceText(content, insertAt, insertAt, `${line}\n\n`);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const ensureBaseImport = (content: string, name: string) => ensureNamedImport(content, "akanjs/base", name);
|
|
54
|
+
|
|
55
|
+
interface NamedImportLocator {
|
|
56
|
+
names: string[];
|
|
57
|
+
elements: { name: string; text: string }[];
|
|
58
|
+
namedBindingsStart: number;
|
|
59
|
+
namedBindingsEnd: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const findNamedImport = (
|
|
63
|
+
source: ts.SourceFile,
|
|
64
|
+
moduleSpecifier: string,
|
|
65
|
+
{ valueOnly = false }: { valueOnly?: boolean } = {},
|
|
66
|
+
): NamedImportLocator | null => {
|
|
67
|
+
for (const statement of source.statements) {
|
|
68
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
69
|
+
if (statement.moduleSpecifier.text !== moduleSpecifier) continue;
|
|
70
|
+
if (valueOnly && statement.importClause?.isTypeOnly) continue;
|
|
71
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
72
|
+
if (!namedBindings || !ts.isNamedImports(namedBindings)) continue;
|
|
73
|
+
return {
|
|
74
|
+
names: namedBindings.elements.map((element) => element.name.text),
|
|
75
|
+
elements: namedBindings.elements.map((element) => ({ name: element.name.text, text: element.getText(source) })),
|
|
76
|
+
namedBindingsStart: namedBindings.getStart(source),
|
|
77
|
+
namedBindingsEnd: namedBindings.getEnd(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const ensureEnumImport = (content: string) => {
|
|
84
|
+
if (content.includes("enumOf")) return content;
|
|
85
|
+
const baseImport = /import \{ ([^{}]+) \} from "akanjs\/base";/.exec(content);
|
|
86
|
+
if (baseImport) {
|
|
87
|
+
const names = baseImport[1]?.split(",").map((name) => name.trim()) ?? [];
|
|
88
|
+
return content.replace(baseImport[0], `import { ${[...names, "enumOf"].sort().join(", ")} } from "akanjs/base";`);
|
|
89
|
+
}
|
|
90
|
+
return `import { enumOf } from "akanjs/base";\n${content}`;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const ensureConstantTypeImport = (content: string, constantPath: string, typeName: string) => {
|
|
94
|
+
if (new RegExp(`import type \\{[^}]*\\b${typeName}\\b[^}]*\\} from "${constantPath}";`).test(content)) return content;
|
|
95
|
+
const importPattern = new RegExp(`import type \\{ ([^}]+) \\} from "${constantPath}";`);
|
|
96
|
+
const existingImport = content.match(importPattern);
|
|
97
|
+
if (existingImport !== null) {
|
|
98
|
+
const names = existingImport[1]?.split(",").map((name) => name.trim()) ?? [];
|
|
99
|
+
return content.replace(
|
|
100
|
+
existingImport[0],
|
|
101
|
+
`import type { ${[...names, typeName].sort().join(", ")} } from "${constantPath}";`,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return `import type { ${typeName} } from "${constantPath}";\n${content}`;
|
|
105
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const spliceText = (content: string, start: number, end: number, replacement: string) =>
|
|
2
|
+
`${content.slice(0, start)}${replacement}${content.slice(end)}`;
|
|
3
|
+
|
|
4
|
+
export const lineStartAt = (content: string, position: number) =>
|
|
5
|
+
content.lastIndexOf("\n", Math.max(0, position - 1)) + 1;
|
|
6
|
+
|
|
7
|
+
export const lineEndAt = (content: string, position: number) => {
|
|
8
|
+
const end = content.indexOf("\n", position);
|
|
9
|
+
return end < 0 ? content.length : end + 1;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const lineIndentAt = (content: string, position: number) =>
|
|
13
|
+
/^[ \t]*/.exec(content.slice(lineStartAt(content, position)))?.[0] ?? "";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { moduleComponentName } from "./modulePaths";
|
|
2
|
+
|
|
3
|
+
export const insertTemplateField = ({
|
|
4
|
+
content,
|
|
5
|
+
moduleName,
|
|
6
|
+
moduleClassName,
|
|
7
|
+
fieldName,
|
|
8
|
+
component,
|
|
9
|
+
}: {
|
|
10
|
+
content: string;
|
|
11
|
+
moduleName: string;
|
|
12
|
+
moduleClassName: string;
|
|
13
|
+
fieldName: string;
|
|
14
|
+
component: "Field.Text" | "Field.Number" | "Field.Date";
|
|
15
|
+
}) => {
|
|
16
|
+
if (content.includes(`l("${moduleName}.${fieldName}")`) || content.includes(`.${fieldName}`)) return content;
|
|
17
|
+
const layoutEndIndex = content.indexOf(" </Layout.Template>");
|
|
18
|
+
if (layoutEndIndex < 0) return null;
|
|
19
|
+
const formName = `${moduleName}Form`;
|
|
20
|
+
if (!content.includes(`const ${formName} = st.use.${moduleName}Form();`)) return null;
|
|
21
|
+
const fieldSetter = `st.do.set${moduleComponentName(fieldName)}On${moduleClassName}`;
|
|
22
|
+
const fieldBlock = ` <${component}
|
|
23
|
+
label={l("${moduleName}.${fieldName}")}
|
|
24
|
+
desc={l("${moduleName}.${fieldName}.desc")}
|
|
25
|
+
value={${formName}.${fieldName}}
|
|
26
|
+
onChange={${fieldSetter}}
|
|
27
|
+
/>
|
|
28
|
+
`;
|
|
29
|
+
return `${content.slice(0, layoutEndIndex)}${fieldBlock}${content.slice(layoutEndIndex)}`;
|
|
30
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { expressionName, factoryArrowOf, sourceFileFor } from "./sourceAst";
|
|
3
|
+
import { ensureNamedImport, findNamedImport } from "./sourceImports";
|
|
4
|
+
import { lineIndentAt, lineStartAt, spliceText } from "./sourceText";
|
|
5
|
+
|
|
6
|
+
export const appendTopLevelTestCases = (
|
|
7
|
+
content: string,
|
|
8
|
+
describeTitle: string,
|
|
9
|
+
render: (itName: string, indent: string) => string[],
|
|
10
|
+
) => {
|
|
11
|
+
const bunImport = findNamedImport(sourceFileFor("test.ts", content), "bun:test", { valueOnly: true });
|
|
12
|
+
const itName = !bunImport?.names.includes("it") && bunImport?.names.includes("test") ? "test" : "it";
|
|
13
|
+
const imported = ensureNamedImport(content, "bun:test", itName);
|
|
14
|
+
const source = sourceFileFor("test.ts", imported);
|
|
15
|
+
const body = source.statements.flatMap((statement) => {
|
|
16
|
+
if (!ts.isExpressionStatement(statement) || !ts.isCallExpression(statement.expression)) return [];
|
|
17
|
+
if (expressionName(statement.expression.expression) !== "describe") return [];
|
|
18
|
+
const callback = factoryArrowOf(statement.expression);
|
|
19
|
+
return callback && ts.isBlock(callback.body) ? [callback.body] : [];
|
|
20
|
+
})[0];
|
|
21
|
+
if (!body) {
|
|
22
|
+
const block = [`describe(${JSON.stringify(describeTitle)}, () => {`, ...render(itName, " "), "});", ""];
|
|
23
|
+
return `${ensureNamedImport(imported, "bun:test", "describe").trimEnd()}\n\n${block.join("\n")}`;
|
|
24
|
+
}
|
|
25
|
+
const firstStatement = body.statements[0];
|
|
26
|
+
const indent = firstStatement
|
|
27
|
+
? lineIndentAt(imported, firstStatement.getStart(source))
|
|
28
|
+
: `${lineIndentAt(imported, body.getStart(source))} `;
|
|
29
|
+
const insertAt = lineStartAt(imported, body.getEnd() - 1);
|
|
30
|
+
return spliceText(imported, insertAt, insertAt, `${render(itName, indent).join("\n")}\n`);
|
|
31
|
+
};
|
package/workflow/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Sys, Workspace } from "../commandDecorators";
|
|
2
|
-
import type { FieldDefaultValue } from "./
|
|
2
|
+
import type { FieldDefaultValue } from "./fieldExpression";
|
|
3
3
|
|
|
4
4
|
export type WorkflowInputType = "string" | "string-list" | "surface-mode" | "boolean";
|
|
5
5
|
export type WorkflowSurfaceMode = "infer" | "include" | "skip";
|
package/workflow/uiPolicy.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFile, stat, utimes, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { tempDirs } from "../test/testHelpers";
|
|
4
5
|
import { CodegenLock } from "./codegenLock";
|
|
5
|
-
import { tempDirs } from "./testHelpers";
|
|
6
6
|
|
|
7
7
|
const makeRoot = tempDirs("akan-codegen-lock-");
|
|
8
8
|
const seedHolder = async (root: string, holder: unknown) => {
|
|
@@ -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 { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
4
|
-
import { tempDirs, writeText } from "./testHelpers";
|
|
5
5
|
import type { PackageJson } from "./types";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-devkit-depscan-");
|
|
@@ -2,8 +2,8 @@ import { builtinModules } from "node:module";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import ignore from "ignore";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
-
import type { App, Lib, Pkg } from "
|
|
6
|
-
import { FileSys } from "
|
|
5
|
+
import type { App, Lib, Pkg } from "../commandDecorators";
|
|
6
|
+
import { FileSys } from "../util/fileSys";
|
|
7
7
|
import type { PackageJson, TsConfigJson } from "./types";
|
|
8
8
|
|
|
9
9
|
const testFileRegex = /\.(?:test|spec)\.[cm]?[tj]sx?$/;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
4
5
|
import { EnvSeed } from "./envSeed";
|
|
5
|
-
import { tempDirs, writeText } from "./testHelpers";
|
|
6
6
|
|
|
7
7
|
const makeEnvDir = tempDirs("akan-env-seed-");
|
|
8
|
-
const templates = path.resolve(import.meta.dir, "
|
|
8
|
+
const templates = path.resolve(import.meta.dir, "../../cli/templates");
|
|
9
9
|
const template = async (file: string) => await readFile(path.join(templates, file), "utf8");
|
|
10
10
|
|
|
11
11
|
const selector = (side: "server" | "client", names: string[]) =>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { Executor, LibExecutor, WorkspaceExecutor } from "
|
|
3
|
+
import { Executor, LibExecutor, WorkspaceExecutor } from "../executors";
|
|
4
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
4
5
|
import { formatLibStatuses, LibSource } from "./libSource";
|
|
5
|
-
import { tempDirs, writeText as write } from "./testHelpers";
|
|
6
6
|
|
|
7
7
|
const makeTempRoot = tempDirs("akan-libsource-");
|
|
8
8
|
|
|
@@ -8,9 +8,10 @@ import type {
|
|
|
8
8
|
LibScanResult,
|
|
9
9
|
PkgScanResult,
|
|
10
10
|
ScanResult,
|
|
11
|
-
} from "
|
|
12
|
-
import { AkanAppConfig } from "
|
|
13
|
-
import { AppExecutor, LibExecutor, PkgExecutor
|
|
11
|
+
} from "../akanConfig";
|
|
12
|
+
import { AkanAppConfig } from "../akanConfig";
|
|
13
|
+
import type { AppExecutor, LibExecutor, PkgExecutor } from "../executors";
|
|
14
|
+
import { WorkspaceExecutor } from "../executors/workspaceExecutor";
|
|
14
15
|
import {
|
|
15
16
|
barrelFacetDirs,
|
|
16
17
|
facetIndexShadowOf,
|
|
@@ -23,6 +24,9 @@ import {
|
|
|
23
24
|
rootEntryHintOf,
|
|
24
25
|
} from "./workspaceLayout";
|
|
25
26
|
|
|
27
|
+
//? Imported on use: sysExecutor.ts imports this file, so a static import would load a SysExecutor subclass first.
|
|
28
|
+
const loadLibExecutor = () => import("../executors/libExecutor");
|
|
29
|
+
|
|
26
30
|
const scalarFileTypes = ["constant", "dictionary", "document", "template", "unit", "util", "view", "zone"] as const;
|
|
27
31
|
type ScalarFileType = (typeof scalarFileTypes)[number];
|
|
28
32
|
const serviceFileTypes = [
|
|
@@ -315,11 +319,11 @@ export class AppInfo extends ScanInfo {
|
|
|
315
319
|
const existingAppInfo = AppInfo.appInfos.get(exec.name);
|
|
316
320
|
if (existingAppInfo && !options.refresh) return existingAppInfo;
|
|
317
321
|
const scanResult = await ScanInfo.getScanResult(exec);
|
|
318
|
-
|
|
322
|
+
const libModule = await loadLibExecutor();
|
|
319
323
|
await Promise.all(
|
|
320
324
|
scanResult.libDeps.map(async (libName) => {
|
|
321
325
|
LibInfo.loadedLibs.add(libName);
|
|
322
|
-
const libExecutor = LibExecutor.from(exec, libName);
|
|
326
|
+
const libExecutor = libModule.LibExecutor.from(exec, libName);
|
|
323
327
|
LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
|
|
324
328
|
}),
|
|
325
329
|
);
|
|
@@ -368,11 +372,12 @@ export class AppInfo extends ScanInfo {
|
|
|
368
372
|
}
|
|
369
373
|
|
|
370
374
|
static async #getAllLibDeps(exec: AppExecutor, libDeps: string[], libSet = new Set<string>()) {
|
|
375
|
+
const libModule = await loadLibExecutor();
|
|
371
376
|
await Promise.all(
|
|
372
377
|
libDeps.map(async (libName) => {
|
|
373
378
|
if (libSet.has(libName)) return;
|
|
374
379
|
libSet.add(libName);
|
|
375
|
-
const libExecutor = LibExecutor.from(exec, libName);
|
|
380
|
+
const libExecutor = libModule.LibExecutor.from(exec, libName);
|
|
376
381
|
const libInfo = await LibInfo.fromExecutor(libExecutor);
|
|
377
382
|
const libScanResult = libInfo.getScanResult();
|
|
378
383
|
if (libScanResult.libDeps.length > 0) await AppInfo.#getAllLibDeps(exec, libScanResult.libDeps, libSet);
|
|
@@ -412,12 +417,13 @@ export class LibInfo extends ScanInfo {
|
|
|
412
417
|
if (existingLibInfo && !refresh) return existingLibInfo;
|
|
413
418
|
|
|
414
419
|
const scanResult = await ScanInfo.getScanResult(exec);
|
|
420
|
+
const libModule = await loadLibExecutor();
|
|
415
421
|
await Promise.all(
|
|
416
422
|
scanResult.libDeps
|
|
417
423
|
.filter((libName) => !LibInfo.loadedLibs.has(libName))
|
|
418
424
|
.map(async (libName) => {
|
|
419
425
|
LibInfo.loadedLibs.add(libName);
|
|
420
|
-
const libExecutor = LibExecutor.from(exec, libName);
|
|
426
|
+
const libExecutor = libModule.LibExecutor.from(exec, libName);
|
|
421
427
|
LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
|
|
422
428
|
}),
|
|
423
429
|
);
|
|
@@ -512,11 +518,16 @@ export class WorkspaceInfo {
|
|
|
512
518
|
if (existingWorkspaceInfo && !options.refresh) return existingWorkspaceInfo;
|
|
513
519
|
|
|
514
520
|
const [appNames, libNames, pkgNames] = await Promise.all([exec.getApps(), exec.getLibs(), exec.getPkgs()]);
|
|
521
|
+
const [appModule, libModule, pkgModule] = await Promise.all([
|
|
522
|
+
import("../executors/appExecutor"),
|
|
523
|
+
loadLibExecutor(),
|
|
524
|
+
import("../executors/pkgExecutor"),
|
|
525
|
+
]);
|
|
515
526
|
// TODO: prevent duplicate scan by resolving the dependency graph
|
|
516
527
|
const [appInfos, libInfos, pkgInfos] = await Promise.all([
|
|
517
|
-
Promise.all(appNames.map(async (appName) => await AppExecutor.from(exec, appName).scan())),
|
|
518
|
-
Promise.all(libNames.map(async (libName) => await LibExecutor.from(exec, libName).scan())),
|
|
519
|
-
Promise.all(pkgNames.map(async (pkgName) => await PkgExecutor.from(exec, pkgName).scan())),
|
|
528
|
+
Promise.all(appNames.map(async (appName) => await appModule.AppExecutor.from(exec, appName).scan())),
|
|
529
|
+
Promise.all(libNames.map(async (libName) => await libModule.LibExecutor.from(exec, libName).scan())),
|
|
530
|
+
Promise.all(pkgNames.map(async (pkgName) => await pkgModule.PkgExecutor.from(exec, pkgName).scan())),
|
|
520
531
|
]);
|
|
521
532
|
const workspaceInfo = new WorkspaceInfo(
|
|
522
533
|
new Map(appInfos.map((app) => [app.exec.name, app as AppInfo])),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { mkdir, rm } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { AppExecutor, Executor, WorkspaceExecutor } from "
|
|
4
|
+
import { AppExecutor, Executor, WorkspaceExecutor } from "../executors";
|
|
5
|
+
import { isolateEnv, tempDirs, writeText as write } from "../test/testHelpers";
|
|
5
6
|
import { formatSlicePlan, SlicePlanner } from "./slicePlanner";
|
|
6
|
-
import { isolateEnv, tempDirs, writeText as write } from "./testHelpers";
|
|
7
7
|
import type { PackageJson } from "./types";
|
|
8
8
|
|
|
9
9
|
isolateEnv({ AKAN_PUBLIC_REPO_NAME: "workspace", AKAN_PUBLIC_SERVE_DOMAIN: "example.com", AKAN_PUBLIC_ENV: "local" });
|
|
@@ -3,7 +3,8 @@ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import type { AkanChangeMap, AkanGraphEdge, AkanGraphNode } from "@akanjs/language";
|
|
6
|
-
import
|
|
6
|
+
import { AkanGraphDiff } from "@akanjs/language";
|
|
7
|
+
import type { Workspace } from "../commandDecorators";
|
|
7
8
|
import { WorkspaceGraph } from "./workspaceGraph";
|
|
8
9
|
|
|
9
10
|
const roots: string[] = [];
|
|
@@ -186,6 +187,89 @@ describe("WorkspaceGraph.scope", () => {
|
|
|
186
187
|
expect(scoped.nodes.map(({ id }) => id)).toEqual([guard, own]);
|
|
187
188
|
expect(scoped.edges).toEqual([edge(own, guard)]);
|
|
188
189
|
});
|
|
190
|
+
|
|
191
|
+
it("follows a role the scope's method calls to the implementation its app binds", () => {
|
|
192
|
+
const role = "adaptor::LlmAdaptorRole";
|
|
193
|
+
const binds = (to: string, label: string): AkanGraphEdge => ({ ...edge(role, to), kind: "binds", label });
|
|
194
|
+
const graph = {
|
|
195
|
+
version: 1 as const,
|
|
196
|
+
nodes: [
|
|
197
|
+
{ ...node("method:apps/sceny:plan.draft", "apps/sceny"), module: "plan" },
|
|
198
|
+
{ ...node("method:apps/angelo:chat.reply", "apps/angelo"), module: "chat" },
|
|
199
|
+
{ ...node("method:libs/genai:prompt.run", "libs/genai"), module: "prompt" },
|
|
200
|
+
node(role, null),
|
|
201
|
+
node("adaptor::AnthropicLlm", null),
|
|
202
|
+
node("adaptor:apps/angelo:ChatCompletionsLlm", "apps/angelo"),
|
|
203
|
+
node("adaptor:libs/genai:GenaiLlm", "libs/genai"),
|
|
204
|
+
],
|
|
205
|
+
edges: [
|
|
206
|
+
edge("method:apps/sceny:plan.draft", role),
|
|
207
|
+
edge("method:apps/angelo:chat.reply", role),
|
|
208
|
+
edge("method:libs/genai:prompt.run", role),
|
|
209
|
+
binds("adaptor::AnthropicLlm", "apps/sceny"),
|
|
210
|
+
binds("adaptor:apps/angelo:ChatCompletionsLlm", "apps/angelo"),
|
|
211
|
+
binds("adaptor:libs/genai:GenaiLlm", "libs/genai"),
|
|
212
|
+
],
|
|
213
|
+
};
|
|
214
|
+
const bound = (scope: { app?: string; module?: string }) =>
|
|
215
|
+
WorkspaceGraph.scope(graph, scope)
|
|
216
|
+
.edges.filter(({ kind }) => kind === "binds")
|
|
217
|
+
.map(({ to, label }) => `${label} ${to}`);
|
|
218
|
+
expect(bound({ app: "sceny" })).toEqual(["apps/sceny adaptor::AnthropicLlm"]);
|
|
219
|
+
expect(WorkspaceGraph.scope(graph, { app: "sceny" }).nodes.map(({ id }) => id)).toContain("adaptor::AnthropicLlm");
|
|
220
|
+
expect(bound({ app: "angelo" })).toEqual(["apps/angelo adaptor:apps/angelo:ChatCompletionsLlm"]);
|
|
221
|
+
expect(bound({ app: "genai" })).toEqual([
|
|
222
|
+
"apps/sceny adaptor::AnthropicLlm",
|
|
223
|
+
"apps/angelo adaptor:apps/angelo:ChatCompletionsLlm",
|
|
224
|
+
"libs/genai adaptor:libs/genai:GenaiLlm",
|
|
225
|
+
]);
|
|
226
|
+
expect(bound({ module: "plan" })).toHaveLength(3);
|
|
227
|
+
expect(
|
|
228
|
+
WorkspaceGraph.visibleTo(graph, "sceny")
|
|
229
|
+
.edges.filter(({ kind }) => kind === "binds")
|
|
230
|
+
.map(({ label }) => label),
|
|
231
|
+
).toEqual(["apps/sceny"]);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("scopes a Change Map to the binding the app runs, whether or not that binding changed", () => {
|
|
235
|
+
const role = "adaptor::LlmAdaptorRole";
|
|
236
|
+
const versioned = (id: string, owner: string | null, digest: string, module: string | null = null) => ({
|
|
237
|
+
...node(id, owner),
|
|
238
|
+
module,
|
|
239
|
+
digest,
|
|
240
|
+
at: { file: `${owner ?? "akanjs"}/x.ts`, line: 1, column: 1 },
|
|
241
|
+
});
|
|
242
|
+
const binds = (to: string, label: string): AkanGraphEdge => ({ ...edge(role, to), kind: "binds", label });
|
|
243
|
+
const graphOf = (ownBinding: boolean, method: string, lib: string) => ({
|
|
244
|
+
version: 1 as const,
|
|
245
|
+
nodes: [
|
|
246
|
+
versioned("method:apps/sceny:plan.draft", "apps/sceny", method, "plan"),
|
|
247
|
+
node(role, null),
|
|
248
|
+
node("adaptor::AnthropicLlm", null),
|
|
249
|
+
versioned("adaptor:libs/genai:GenaiLlm", "libs/genai", lib),
|
|
250
|
+
],
|
|
251
|
+
edges: [
|
|
252
|
+
edge("method:apps/sceny:plan.draft", role),
|
|
253
|
+
...(ownBinding ? [binds("adaptor::AnthropicLlm", "apps/sceny")] : []),
|
|
254
|
+
binds("adaptor:libs/genai:GenaiLlm", "libs/genai"),
|
|
255
|
+
],
|
|
256
|
+
});
|
|
257
|
+
const scopedBinds = (base: ReturnType<typeof graphOf>, head: ReturnType<typeof graphOf>) => {
|
|
258
|
+
const changes = { ...AkanGraphDiff.between(base, head), since: "0123456789ab", unmapped: [] };
|
|
259
|
+
const answer = WorkspaceGraph.answerChanges(changes, { app: "sceny" });
|
|
260
|
+
if (!("edges" in answer)) throw new Error("expected an answer");
|
|
261
|
+
return answer.edges
|
|
262
|
+
.filter(({ kind }) => kind === "binds")
|
|
263
|
+
.map(({ label, to, change }) => `${change ?? "unchanged"} ${label} ${to}`);
|
|
264
|
+
};
|
|
265
|
+
expect(scopedBinds(graphOf(true, "1", "1"), graphOf(true, "2", "2"))).toEqual([
|
|
266
|
+
"unchanged apps/sceny adaptor::AnthropicLlm",
|
|
267
|
+
]);
|
|
268
|
+
expect(scopedBinds(graphOf(true, "1", "1"), graphOf(false, "1", "2"))).toEqual([
|
|
269
|
+
"unchanged libs/genai adaptor:libs/genai:GenaiLlm",
|
|
270
|
+
"removed apps/sceny adaptor::AnthropicLlm",
|
|
271
|
+
]);
|
|
272
|
+
});
|
|
189
273
|
});
|
|
190
274
|
|
|
191
275
|
describe("WorkspaceGraph.changesAt", () => {
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type AkanChangeMap,
|
|
5
|
+
type AkanGraph,
|
|
6
|
+
AkanGraphDiff,
|
|
7
|
+
type AkanGraphEdge,
|
|
8
|
+
type AkanGraphNode,
|
|
9
|
+
AkanIndex,
|
|
10
|
+
} from "@akanjs/language";
|
|
4
11
|
import ts from "typescript";
|
|
5
|
-
import type { Workspace } from "
|
|
12
|
+
import type { Workspace } from "../commandDecorators";
|
|
6
13
|
import { GitRevision } from "./gitRevision";
|
|
7
14
|
|
|
8
15
|
export interface GraphScope {
|
|
@@ -109,9 +116,30 @@ export class WorkspaceGraph {
|
|
|
109
116
|
//? A lib's guard is linked from every app's endpoints; through it, a scope would reach all of them.
|
|
110
117
|
const guards = new Set(graph.nodes.filter((node) => node.kind === "guard").map((node) => node.id));
|
|
111
118
|
const reaches = (id: string) => seeds.has(id) && !guards.has(id);
|
|
112
|
-
const edges = graph.edges.filter((edge) => reaches(edge.from) || reaches(edge.to));
|
|
113
|
-
const
|
|
114
|
-
|
|
119
|
+
const edges = graph.edges.filter((edge) => edge.kind !== "binds" && (reaches(edge.from) || reaches(edge.to)));
|
|
120
|
+
const kept = new Set([...seeds, ...edges.flatMap((edge) => [edge.from, edge.to])]);
|
|
121
|
+
const isLib =
|
|
122
|
+
!!app &&
|
|
123
|
+
graph.nodes.some((node) => node.owner === `libs/${app}`) &&
|
|
124
|
+
!graph.nodes.some((node) => node.owner === `apps/${app}`);
|
|
125
|
+
const applicable = WorkspaceGraph.#bindingsOf(graph, app && !isLib ? `apps/${app}` : null);
|
|
126
|
+
const isOwn = (edge: AkanGraphEdge) => !module && !!owners?.has(edge.label ?? "");
|
|
127
|
+
const roles = new Set(
|
|
128
|
+
applicable.filter((edge) => isOwn(edge) || kept.has(edge.from) || reaches(edge.to)).map((edge) => edge.from),
|
|
129
|
+
);
|
|
130
|
+
const bindings = applicable.filter((edge) => roles.has(edge.from));
|
|
131
|
+
const ids = new Set([...kept, ...bindings.flatMap((edge) => [edge.from, edge.to])]);
|
|
132
|
+
return { version: 1, nodes: graph.nodes.filter((node) => ids.has(node.id)), edges: [...edges, ...bindings] };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//? An app runs a role as its own `applyAdaptor` binds it, else as a lib's does; a lib's code runs under every app's.
|
|
136
|
+
static #bindingsOf(graph: AkanGraph, appOwner: string | null) {
|
|
137
|
+
const binds = graph.edges.filter((edge) => edge.kind === "binds");
|
|
138
|
+
if (!appOwner) return binds;
|
|
139
|
+
const own = new Set(
|
|
140
|
+
binds.filter((edge) => edge.label === appOwner && edge.change !== "removed").map((edge) => edge.from),
|
|
141
|
+
);
|
|
142
|
+
return binds.filter((edge) => edge.label === appOwner || (!edge.label?.startsWith("apps/") && !own.has(edge.from)));
|
|
115
143
|
}
|
|
116
144
|
|
|
117
145
|
//? Pages are many and most only wrap one another, so a graph too large to answer whole drops the pages that neither
|
|
@@ -141,7 +169,14 @@ export class WorkspaceGraph {
|
|
|
141
169
|
const isVisible = ({ owner }: AkanGraphNode) => !owner || owner === appOwner || owner.startsWith("libs/");
|
|
142
170
|
const nodes = graph.nodes.filter(isVisible);
|
|
143
171
|
const ids = new Set(nodes.map((node) => node.id));
|
|
144
|
-
|
|
172
|
+
const bindings = new Set(WorkspaceGraph.#bindingsOf(graph, appOwner));
|
|
173
|
+
return {
|
|
174
|
+
version: 1,
|
|
175
|
+
nodes,
|
|
176
|
+
edges: graph.edges.filter(
|
|
177
|
+
(edge) => ids.has(edge.from) && ids.has(edge.to) && (edge.kind !== "binds" || bindings.has(edge)),
|
|
178
|
+
),
|
|
179
|
+
};
|
|
145
180
|
}
|
|
146
181
|
|
|
147
182
|
static changesVisibleTo(changes: AkanChangeMap, app: string): AkanChangeMap {
|
|
@@ -140,7 +140,7 @@ describe("module test target", () => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
const templatesDir = path.join(import.meta.dir, "..", "cli", "templates");
|
|
143
|
+
const templatesDir = path.join(import.meta.dir, "..", "..", "cli", "templates");
|
|
144
144
|
|
|
145
145
|
type TsConfig = { references?: { path: string }[] };
|
|
146
146
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// The one source of the app/lib root allowlists (sync, doctor and quality scan read it); mirror a change into the
|
|
2
2
|
// root AGENTS.md list.
|
|
3
3
|
|
|
4
|
+
import { barrelFacetDirs } from "akanjs/common";
|
|
5
|
+
|
|
4
6
|
export type SysType = "app" | "lib";
|
|
5
7
|
|
|
6
8
|
export const appRootAllowedFiles = new Set([
|
|
@@ -98,7 +100,7 @@ export const moduleTestHint =
|
|
|
98
100
|
"a module test is named after the one module file it covers (<model>.<role>.test.ts); add a describe block to " +
|
|
99
101
|
"that file's suite instead, or move a suite that drives several modules into srvkit/";
|
|
100
102
|
|
|
101
|
-
export
|
|
103
|
+
export { barrelFacetDirs };
|
|
102
104
|
|
|
103
105
|
//* Bun resolves a folder import to `index.tsx`, `index.jsx` or `index.mts` ahead of `index.ts`, and TypeScript to
|
|
104
106
|
//* `index.ts` first, so one of these beside the generated barrel typechecks every name the barrel adds and serves none.
|