@akanjs/devkit 3.2.0-rc.9 → 3.2.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -529
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +152 -6
- package/akanApp/akanApp.host.ts +187 -1220
- package/akanApp/akanApp.host.wiring.test.ts +931 -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 +394 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +200 -0
- package/akanApp/devIdleSuspend.test.ts +221 -0
- package/akanApp/devIdleSuspend.ts +192 -0
- package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
- package/akanApp/devRecycler.test.ts +66 -0
- package/akanApp/devRecycler.ts +305 -0
- package/akanApp/devStartTimeline.test.ts +115 -0
- package/akanApp/devStartTimeline.ts +69 -0
- package/akanApp/processRss.ts +61 -0
- package/akanConfig/akanConfig.test.ts +45 -17
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiReport.test.ts +34 -3
- package/apiReport/apiReportDiff.ts +35 -1
- package/apiReport/apiReportPolicy.ts +3 -2
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +2 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +71 -8
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +60 -21
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +17 -1
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +9 -3
- package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
- package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
- package/artifact/implicitRootLayout.test.ts +71 -3
- package/artifact/implicitRootLayout.ts +9 -3
- package/artifact/implicitRootLayoutRender.test.tsx +297 -0
- package/biome.base.json +2 -1
- package/cloud/cloudApi.test.ts +1 -1
- package/cloud/configLock.test.ts +1 -1
- package/cloud/globalConfig.test.ts +1 -1
- package/cloud/globalConfig.ts +1 -1
- package/cloud/updatePackUpload.test.ts +1 -1
- package/codeAgent/agent/AkanCodeEnv.ts +1 -1
- package/codeAgent/agent/AkanCodeServices.ts +23 -0
- package/codeAgent/agent/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanCodeServices.test.ts +54 -0
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +8 -5
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +19 -1
- package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
- package/codeAgent/skills/akan-validate/SKILL.md +3 -3
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +2 -2
- package/codeAgent/tools/akanCodePlugins.test.ts +1 -1
- package/commandDecorators/command.ts +35 -6
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +107 -6
- package/commandDecorators/targetMeta.ts +2 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +70 -1
- package/commandDecorators/workspaceVersionCheck.ts +64 -14
- package/context/akanContext.ts +576 -0
- package/context/akanContextInspection.ts +296 -0
- package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
- package/{akanMcpContract.ts → context/akanMcpContract.ts} +16 -256
- package/context/doctor/agentGuideCheck.ts +81 -0
- package/context/doctor/configLeftoverCheck.ts +35 -0
- package/context/doctor/doctorFindings.ts +70 -0
- package/context/doctor/generatedFreshness.ts +56 -0
- package/context/doctor/moduleShapeCheck.ts +88 -0
- package/context/doctor/recipeDuplicateCheck.ts +42 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
- package/context/safeRead.ts +9 -0
- package/csrE2e/csrE2eHarness.fixture.ts +1 -1
- package/devkitUtils.test.ts +39 -5
- package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
- package/{apiReference.ts → docs/apiReference.ts} +2 -2
- package/docs/errorCodeReference.test.ts +282 -0
- package/docs/errorCodeReference.ts +71 -0
- package/docs/errorCodeScan.ts +551 -0
- package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
- package/executors/appExecutor.ts +463 -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} +106 -18
- package/executors/index.ts +8 -0
- package/executors/libExecutor.ts +23 -0
- package/executors/moduleExecutor.ts +18 -0
- package/executors/pkgExecutor.ts +129 -0
- package/executors/sysExecutor.ts +301 -0
- package/executors/workspaceExecutor.ts +277 -0
- package/frontendBuild/allRoutesBuilder.test.ts +1 -1
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildCacheStamp.test.ts +42 -0
- package/frontendBuild/buildCacheStamp.ts +23 -0
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCandidateCache.test.ts +70 -1
- package/frontendBuild/cssCandidateCache.ts +17 -10
- package/frontendBuild/cssCompiler.test.ts +3 -2
- package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.ts +7 -38
- package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
- package/frontendBuild/fontOptimizer.test.ts +145 -4
- package/frontendBuild/fontOptimizer.ts +103 -18
- package/frontendBuild/fontPruner.test.ts +1 -1
- package/frontendBuild/frontendBuild.test.ts +3 -3
- package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
- package/frontendBuild/hmrWatcher.test.ts +1 -1
- package/frontendBuild/hmrWatcher.ts +22 -1
- package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
- package/frontendBuild/mcpAppViewBuilder.ts +1 -1
- package/frontendBuild/nativeCore.test.ts +1 -1
- package/frontendBuild/optionalPeers.test.ts +36 -8
- package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
- package/frontendBuild/pagesBundleBuilder.ts +1 -1
- package/frontendBuild/precompressArtifacts.test.ts +1 -1
- package/frontendBuild/precompressArtifacts.ts +19 -6
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
- package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +1 -1
- package/frontendBuild/vendorNarrowing.test.ts +1 -1
- package/frontendBuild/watchRootResolver.test.ts +1 -1
- package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
- package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
- package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
- package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
- package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
- package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
- package/{prompter.ts → guideline/prompter.ts} +2 -3
- package/incrementalBuilder/buildBatch.proc.ts +16 -5
- package/incrementalBuilder/buildBatchProtocol.ts +3 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +113 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +19 -2
- 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 +16 -0
- package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +142 -7
- package/incrementalBuilder/incrementalBuilder.proc.ts +82 -823
- package/incrementalBuilder/ssrRegistry.ts +282 -0
- package/index.ts +22 -22
- package/integration/devStability.integration.test.ts +62 -56
- package/integration/devStabilityHarness.test.ts +1 -1
- package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
- package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
- package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
- package/lint/gritRules.test.ts +1 -1
- package/{linter.test.ts → lint/linter.test.ts} +1 -1
- package/lint/no-import-common-err.grit +31 -0
- package/lint/no-init-fetch-in-client.grit +1 -1
- package/mobile/desktopBin.test.ts +1 -1
- package/mobile/desktopRelease.test.ts +1 -1
- package/mobile/desktopServerStage.test.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -1
- package/mobile/nativeApi.test.ts +1 -1
- package/mobile/nativeApp.test.ts +1 -1
- package/mobile/nativeConfig.test.ts +1 -1
- package/mobile/nativePluginFolders.test.ts +1 -1
- package/mobile/nativePublicEnv.test.ts +1 -1
- package/mobile/nativePublicEnv.ts +2 -1
- package/mobile/nativeWebDir.test.ts +1 -1
- package/mobile/serverBundleSecrets.test.ts +1 -1
- package/mobile/tarWriter.test.ts +1 -1
- package/mobile/updatePackFolder.test.ts +1 -1
- package/package.json +173 -9
- package/packageExports.test.ts +20 -2
- package/piDependencyPins.test.ts +1 -1
- package/pipeline/PipelineDefinition.ts +1 -1
- package/platformTest/IdleWatchedProcess.test.ts +1 -1
- package/platformTest/LinuxDockerTarget.ts +1 -1
- package/platformTest/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/platformTest/WindowsSshTarget.ts +1 -1
- package/preview/previewView.test.ts +23 -1
- package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
- package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
- package/quality/bareErrorScanner.ts +126 -0
- package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
- package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
- package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
- package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
- package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
- package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
- package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
- package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
- package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +41 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +25 -91
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/quality/workspaceSourceFiles.ts +82 -0
- package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
- package/{subspace.ts → subspace/subspace.ts} +5 -5
- package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
- package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
- package/{testHelpers.ts → test/testHelpers.ts} +37 -1
- package/transforms/barrelAnalyzer.ts +31 -10
- package/transforms/browserDirnamePlugin.test.ts +1 -1
- package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
- package/transforms/mcpAppPageTrimmer.test.ts +1 -1
- package/transforms/pureLazyMarker.test.ts +1 -1
- package/transforms/serverEnvPlugin.test.ts +1 -1
- package/transforms/serverEnvProfile.test.ts +1 -1
- package/transforms/sideEffectImportOrder.test.ts +1 -1
- package/transforms/transforms.test.ts +52 -2
- package/transforms/tsconfigPackageResolver.test.ts +1 -1
- package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
- package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
- package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
- package/typecheck/projectTypecheck.test.ts +23 -1
- package/typecheck/projectTypecheck.ts +10 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +5 -4
- package/typecheck/typecheck.proc.ts +6 -2
- package/typecheck/typecheckFailure.ts +1 -1
- package/util/errorReport.ts +66 -0
- package/{fileSys.test.ts → util/fileSys.test.ts} +13 -0
- package/{fileSys.ts → util/fileSys.ts} +2 -2
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/constantSource.ts +187 -0
- package/workflow/dictionarySource.ts +184 -0
- package/workflow/executor.ts +6 -9
- package/workflow/fieldExpression.ts +153 -0
- package/workflow/fieldLabel.ts +61 -0
- package/workflow/fieldOrder.ts +117 -0
- package/workflow/fieldType.ts +2 -1
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/keyRename.ts +1 -1
- package/workflow/moduleIndex.test.ts +2 -2
- package/workflow/moduleIndex.ts +2 -2
- package/workflow/modulePaths.ts +27 -0
- package/workflow/mutationScaffold.ts +7 -15
- package/workflow/mutationSource.ts +2 -1
- package/workflow/plan.ts +2 -1
- package/workflow/primitiveReport.ts +78 -0
- package/workflow/rolloutGate.test.ts +1 -1
- package/workflow/rolloutGate.ts +1 -1
- package/workflow/serviceSource.ts +33 -0
- package/workflow/signalSource.ts +96 -0
- package/workflow/source.ts +50 -1100
- package/workflow/sourceAst.ts +30 -0
- package/workflow/sourceImports.ts +105 -0
- package/workflow/sourceText.ts +13 -0
- package/workflow/templateSource.ts +30 -0
- package/workflow/testSource.ts +31 -0
- package/workflow/types.ts +1 -1
- package/workflow/uiPolicy.ts +1 -1
- package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
- package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
- package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
- package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
- package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
- package/{envSeed.ts → workspace/envSeed.ts} +1 -1
- package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
- package/{libSource.ts → workspace/libSource.ts} +1 -1
- package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
- package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
- package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
- package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1083
- package/executors.ts +0 -1749
- /package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +0 -0
- /package/{akanMcpToolError.ts → context/akanMcpToolError.ts} +0 -0
- /package/{moduleFieldNames.test.ts → context/moduleFieldNames.test.ts} +0 -0
- /package/{moduleFieldNames.ts → context/moduleFieldNames.ts} +0 -0
- /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
- /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
- /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
- /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
- /package/{linter.ts → lint/linter.ts} +0 -0
- /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
- /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
- /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
- /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
- /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
- /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
- /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
- /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
- /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
- /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
- /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
- /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
- /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
- /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
- /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
- /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
- /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
- /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
- /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
- /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
- /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
- /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
- /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
- /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
- /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
- /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
- /package/{storeSource.ts → quality/storeSource.ts} +0 -0
- /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
- /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
- /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
- /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
- /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
- /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
- /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
- /package/{writePath.ts → quality/writePath.ts} +0 -0
- /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
- /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
- /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
- /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
- /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
- /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
- /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
- /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /package/{types.ts → workspace/types.ts} +0 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { describe, expect, spyOn, test } from "bun:test";
|
|
2
|
+
import { mkdir, readdir, rm, symlink } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { act, Children, createElement, Fragment, isValidElement, type ReactElement, type ReactNode } from "react";
|
|
6
|
+
import { renderToReadableStream } from "react-dom/server.edge";
|
|
7
|
+
import { createFromNodeStream } from "react-server-dom-webpack/client.node";
|
|
8
|
+
import { PagesBundleBuilder } from "../frontendBuild/pagesBundleBuilder";
|
|
9
|
+
import { tempDirs, writeText as write } from "../test/testHelpers";
|
|
10
|
+
import { resolveSsrPageEntries } from "./implicitRootLayout";
|
|
11
|
+
|
|
12
|
+
Object.assign(process.env, {
|
|
13
|
+
AKAN_PUBLIC_APP_NAME: "demo",
|
|
14
|
+
AKAN_PUBLIC_REPO_NAME: "demo",
|
|
15
|
+
AKAN_PUBLIC_SERVE_DOMAIN: "localhost",
|
|
16
|
+
AKAN_PUBLIC_ENV: "testing",
|
|
17
|
+
AKAN_PUBLIC_OPERATION_MODE: "cloud",
|
|
18
|
+
});
|
|
19
|
+
const akanjsRoot = path.resolve(import.meta.dir, "../../../akanjs");
|
|
20
|
+
process.env.AKAN_RSC_WORKER_PATH = path.join(akanjsRoot, "server/rscWorker.tsx");
|
|
21
|
+
const { RscWorker } = await import("akanjs/server/rscWorkerHost.ts");
|
|
22
|
+
const { SsrFromRscRenderer } = await import("akanjs/server/ssrFromRscRenderer.tsx");
|
|
23
|
+
const { resetEnvCache } = await import("akanjs/base");
|
|
24
|
+
const { Logger } = await import("akanjs/common");
|
|
25
|
+
const { makePageProto, registerClientRuntime, router } = await import("akanjs/client");
|
|
26
|
+
//? What the app's client bundle registers in a browser; the hydrated System.Provider reads it.
|
|
27
|
+
const socket = { connect: () => undefined, connectOnUse: () => undefined };
|
|
28
|
+
registerClientRuntime({ ...makePageProto({ en: {} }), fetch: { instance: socket } } as never);
|
|
29
|
+
|
|
30
|
+
const makeTempRoot = tempDirs("akan-root-level-render-");
|
|
31
|
+
const boundedLayout = "<RouteLevelBoundary>{layout}</RouteLevelBoundary>";
|
|
32
|
+
const pageSource = 'import { page } from "akanjs/client";\nexport default page().render(() => <p>page</p>);\n';
|
|
33
|
+
const idsLayoutSource = `import { rootLayout } from "akanjs/client";
|
|
34
|
+
import { UsesId } from "../usesId";
|
|
35
|
+
export default rootLayout().render(({ children }) => <section id="user"><UsesId />{children}</section>);
|
|
36
|
+
`;
|
|
37
|
+
//? Throws only once the test has read the shell's body, so the boundary streams pending whatever the payload's size.
|
|
38
|
+
const lateLayoutSource = `import { rootLayout } from "akanjs/client";
|
|
39
|
+
export default rootLayout()
|
|
40
|
+
.loading(() => <i>root loading</i>)
|
|
41
|
+
.render(async () => {
|
|
42
|
+
while (!(await Bun.file(process.env.AKAN_TEST_SHELL_READ ?? "").exists())) await Bun.sleep(5);
|
|
43
|
+
throw new Error("root layout broke");
|
|
44
|
+
});
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const linkPackage = async (root: string, name: string, dir: string) => {
|
|
48
|
+
await mkdir(path.dirname(path.join(root, "node_modules", name)), { recursive: true });
|
|
49
|
+
await symlink(dir, path.join(root, "node_modules", name));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const writeApp = async (routes: Record<string, string>) => {
|
|
53
|
+
const root = await makeTempRoot();
|
|
54
|
+
const appDir = path.join(root, "apps/demo");
|
|
55
|
+
await linkPackage(root, "akanjs", akanjsRoot);
|
|
56
|
+
for (const name of ["react", "react-dom", "react-server-dom-webpack"])
|
|
57
|
+
await linkPackage(root, name, path.dirname(Bun.resolveSync(`${name}/package.json`, akanjsRoot)));
|
|
58
|
+
await write(
|
|
59
|
+
path.join(root, "tsconfig.json"),
|
|
60
|
+
JSON.stringify({ compilerOptions: { paths: { "@apps/*": ["./apps/*"] } } }),
|
|
61
|
+
);
|
|
62
|
+
await write(path.join(appDir, "env/env.client.ts"), "export const env = {};\n");
|
|
63
|
+
await write(path.join(appDir, "lib/dict.ts"), "export const getAllDictionary = () => ({});\n");
|
|
64
|
+
//? With lib/st.ts present the generated layout imports both, and the worker's System.Provider reads this runtime.
|
|
65
|
+
await write(
|
|
66
|
+
path.join(appDir, "lib/useClient.ts"),
|
|
67
|
+
'import { makePageProto, registerClientRuntime } from "akanjs/client";\nregisterClientRuntime(makePageProto({}) as never);\n',
|
|
68
|
+
);
|
|
69
|
+
await write(path.join(appDir, "lib/st.ts"), "export {};\n");
|
|
70
|
+
await write(
|
|
71
|
+
path.join(appDir, "page/usesId.tsx"),
|
|
72
|
+
'"use client";\nimport { useId } from "react";\nexport const UsesId = () => <b id={useId()}>uses id</b>;\n',
|
|
73
|
+
);
|
|
74
|
+
for (const [file, source] of Object.entries(routes)) await write(path.join(appDir, "page", file), source);
|
|
75
|
+
return { root, appDir, pageKeys: Object.keys(routes).map((file) => `./${file}`) };
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//? Each client reference's stub names its workspace-relative path in the error it throws when called on the server.
|
|
79
|
+
const clientReferenceIds = async (serverDir: string) => {
|
|
80
|
+
const ids = new Set<string>();
|
|
81
|
+
for (const file of await readdir(serverDir, { recursive: true })) {
|
|
82
|
+
if (!file.endsWith(".js")) continue;
|
|
83
|
+
const source = await Bun.file(path.join(serverDir, file)).text();
|
|
84
|
+
for (const [, id] of source.matchAll(/Attempted to call '[^']+' from '([^']+)' on the server/g))
|
|
85
|
+
if (id) ids.add(id);
|
|
86
|
+
}
|
|
87
|
+
return [...ids];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const ssrManifest: { moduleLoading: null; moduleMap: Record<string, unknown> } = { moduleLoading: null, moduleMap: {} };
|
|
91
|
+
|
|
92
|
+
const readHtml = async (stream: ReadableStream<Uint8Array>, onBody: () => Promise<unknown>) => {
|
|
93
|
+
const reader = stream.getReader();
|
|
94
|
+
const decoder = new TextDecoder();
|
|
95
|
+
let html = "";
|
|
96
|
+
let bodyRead = false;
|
|
97
|
+
for (;;) {
|
|
98
|
+
const { value, done } = await reader.read();
|
|
99
|
+
if (done) return html + decoder.decode();
|
|
100
|
+
html += decoder.decode(value, { stream: true });
|
|
101
|
+
if (bodyRead || !html.includes("<body")) continue;
|
|
102
|
+
bodyRead = true;
|
|
103
|
+
await onBody();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
interface Rendered {
|
|
108
|
+
html: string;
|
|
109
|
+
status: number;
|
|
110
|
+
payload: Uint8Array;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const withBuiltPages = async (
|
|
114
|
+
{ routes, unbounded }: { routes: Record<string, string>; unbounded?: string },
|
|
115
|
+
run: (render: (route: string) => Promise<Rendered>) => Promise<void>,
|
|
116
|
+
) => {
|
|
117
|
+
const { root, appDir, pageKeys } = await writeApp(routes);
|
|
118
|
+
const app = {
|
|
119
|
+
name: "demo",
|
|
120
|
+
cwdPath: appDir,
|
|
121
|
+
dist: { cwdPath: path.join(root, "dist/apps/demo") },
|
|
122
|
+
workspace: { workspaceRoot: root },
|
|
123
|
+
getConfig: async () => ({ basePaths: [], barrelImports: [], externalLibs: [] }),
|
|
124
|
+
getTsConfig: async () => ({ compilerOptions: { paths: { "@apps/*": ["./apps/*"] } } }),
|
|
125
|
+
getPublicEnv: () => ({}),
|
|
126
|
+
verbose: () => undefined,
|
|
127
|
+
};
|
|
128
|
+
const entries = await resolveSsrPageEntries({ appCwdPath: appDir, appName: "demo", pageKeys });
|
|
129
|
+
if (unbounded) {
|
|
130
|
+
const generated = entries.find((entry) => entry.key === `./${unbounded}/__root_layout.tsx`);
|
|
131
|
+
if (!generated) throw new Error(`no generated root layout for ${unbounded}`);
|
|
132
|
+
const source = await Bun.file(generated.moduleAbsPath).text();
|
|
133
|
+
expect(source).toContain(boundedLayout);
|
|
134
|
+
await Bun.write(generated.moduleAbsPath, source.replace(boundedLayout, "layout"));
|
|
135
|
+
}
|
|
136
|
+
const { bundlePath } = await new PagesBundleBuilder(app as never, "build", entries).build();
|
|
137
|
+
const ids = await clientReferenceIds(path.dirname(bundlePath));
|
|
138
|
+
ssrManifest.moduleMap = Object.fromEntries(
|
|
139
|
+
ids.map((id) => {
|
|
140
|
+
const file = path.resolve(root, id);
|
|
141
|
+
return [id, { "*": { id: file, chunks: [file, file], name: "*" } }];
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
const shellRead = path.join(root, "shell-read");
|
|
145
|
+
process.env.AKAN_TEST_SHELL_READ = shellRead;
|
|
146
|
+
const rsc = new RscWorker({
|
|
147
|
+
pagesBundlePath: bundlePath,
|
|
148
|
+
pagesBundleBuildId: 1,
|
|
149
|
+
rscRuntimeClientManifest: Object.fromEntries(ids.map((id) => [id, { id, chunks: [], name: "" }])),
|
|
150
|
+
} as never);
|
|
151
|
+
try {
|
|
152
|
+
await rsc.ready;
|
|
153
|
+
await run(async (route) => {
|
|
154
|
+
const request = new Request(`http://localhost/en/${route}`);
|
|
155
|
+
const result = await rsc.renderWithMeta(request);
|
|
156
|
+
if (result.type !== "stream") throw new Error(`expected a rendered page, got ${result.type}`);
|
|
157
|
+
const [rscStream, payloadStream] = result.stream.tee();
|
|
158
|
+
const payload = new Response(payloadStream).arrayBuffer();
|
|
159
|
+
payload.catch(() => undefined);
|
|
160
|
+
const stream = await new SsrFromRscRenderer().render({
|
|
161
|
+
request,
|
|
162
|
+
rscStream,
|
|
163
|
+
ssrManifest,
|
|
164
|
+
lateControl: result.lateControl,
|
|
165
|
+
} as never);
|
|
166
|
+
const html = await readHtml(stream, () => Bun.write(shellRead, ""));
|
|
167
|
+
await rm(shellRead, { force: true });
|
|
168
|
+
return { html, status: result.status ?? 200, payload: new Uint8Array(await payload) };
|
|
169
|
+
});
|
|
170
|
+
} finally {
|
|
171
|
+
rsc.kill();
|
|
172
|
+
delete process.env.AKAN_TEST_SHELL_READ;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const bodyOf = async (payload: Uint8Array): Promise<ReactNode> => {
|
|
177
|
+
const html = await createFromNodeStream<ReactElement<{ children: ReactNode }>>(
|
|
178
|
+
Readable.from([payload]),
|
|
179
|
+
ssrManifest as never,
|
|
180
|
+
);
|
|
181
|
+
const body = Children.toArray(html.props.children).find(
|
|
182
|
+
(child): child is ReactElement<{ children: ReactNode }> => isValidElement(child) && child.type === "body",
|
|
183
|
+
);
|
|
184
|
+
return createElement(Fragment, null, body?.props.children);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const markupOf = async (node: ReactNode) => {
|
|
188
|
+
const stream = await renderToReadableStream(node, { onError: () => undefined });
|
|
189
|
+
await stream.allReady;
|
|
190
|
+
return await new Response(stream).text();
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const hydrated = async (
|
|
194
|
+
payload: Uint8Array,
|
|
195
|
+
keptSelectors: string[],
|
|
196
|
+
run: (container: HTMLElement, uncaught: unknown[], recoverable: unknown[]) => void | Promise<void>,
|
|
197
|
+
) => {
|
|
198
|
+
const markup = await markupOf(await bodyOf(payload));
|
|
199
|
+
const { GlobalRegistrator } = await import("@happy-dom/global-registrator");
|
|
200
|
+
GlobalRegistrator.register({ url: "http://localhost/en/" });
|
|
201
|
+
//? getEnv() caches its side, and the SSR render above ran with no window.
|
|
202
|
+
resetEnvCache();
|
|
203
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
204
|
+
const { hydrateRoot } = await import("react-dom/client");
|
|
205
|
+
const container = document.createElement("div");
|
|
206
|
+
container.innerHTML = markup;
|
|
207
|
+
document.body.appendChild(container);
|
|
208
|
+
const uncaught: unknown[] = [];
|
|
209
|
+
const recoverable: unknown[] = [];
|
|
210
|
+
const kept = keptSelectors.map((selector) => [selector, container.querySelector(selector)] as const);
|
|
211
|
+
//? React's dev check tags a context with the last renderer to provide it, and Fizz rendered these in this process.
|
|
212
|
+
const logged = console.error;
|
|
213
|
+
const quiet = spyOn(console, "error").mockImplementation((...args: unknown[]) => {
|
|
214
|
+
if (!String(args[0]).startsWith("Detected multiple renderers concurrently")) logged(...args);
|
|
215
|
+
});
|
|
216
|
+
let root: ReturnType<typeof hydrateRoot> | undefined;
|
|
217
|
+
try {
|
|
218
|
+
const tree = await bodyOf(payload);
|
|
219
|
+
await act(async () => {
|
|
220
|
+
root = hydrateRoot(container, tree, {
|
|
221
|
+
onUncaughtError: (error) => void uncaught.push(error),
|
|
222
|
+
onCaughtError: () => undefined,
|
|
223
|
+
onRecoverableError: (error) => void recoverable.push(error),
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
await act(async () => {});
|
|
227
|
+
for (const [selector, node] of kept) expect(container.querySelector(selector)).toBe(node);
|
|
228
|
+
await run(container, uncaught, recoverable);
|
|
229
|
+
} finally {
|
|
230
|
+
await act(async () => {
|
|
231
|
+
root?.unmount();
|
|
232
|
+
});
|
|
233
|
+
quiet.mockRestore();
|
|
234
|
+
await GlobalRegistrator.unregister();
|
|
235
|
+
resetEnvCache();
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const withLoggedErrors = async (run: () => Promise<void>) => {
|
|
240
|
+
const logged = spyOn(Logger.prototype, "error").mockImplementation(() => undefined);
|
|
241
|
+
try {
|
|
242
|
+
await run();
|
|
243
|
+
} finally {
|
|
244
|
+
logged.mockRestore();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
describe("The generated System root layout, built and rendered", () => {
|
|
249
|
+
test("draws a late root failure's notice inside System.Provider, whose bridge started the router its retry calls", async () => {
|
|
250
|
+
const refreshes: string[] = [];
|
|
251
|
+
globalThis.__AKAN_RSC_REFRESH__ = async () => void refreshes.push("refresh");
|
|
252
|
+
try {
|
|
253
|
+
await withLoggedErrors(async () => {
|
|
254
|
+
const routes = { "(late)/_layout.tsx": lateLayoutSource, "(late)/late.tsx": pageSource };
|
|
255
|
+
await withBuiltPages({ routes }, async (render) => {
|
|
256
|
+
const late = await render("late");
|
|
257
|
+
expect(late.status).toBe(200);
|
|
258
|
+
expect(late.html).toContain('<body><!--$?--><template id="B:0"></template><i>root loading</i><!--/$-->');
|
|
259
|
+
expect(late.html).toContain('$RX("B:0"');
|
|
260
|
+
|
|
261
|
+
//? Only the hydrated ClientSsrBridge can start it: the server's own init ran in the worker.
|
|
262
|
+
expect(router.isInitialized).toBe(false);
|
|
263
|
+
await hydrated(late.payload, [], async (container, uncaught) => {
|
|
264
|
+
expect(uncaught).toEqual([]);
|
|
265
|
+
const notice = container.querySelector("#pageContent > [role='alert']");
|
|
266
|
+
expect(notice).not.toBeNull();
|
|
267
|
+
await act(async () => notice?.querySelector("button")?.click());
|
|
268
|
+
expect(refreshes).toEqual(["refresh"]);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
} finally {
|
|
273
|
+
globalThis.__AKAN_RSC_REFRESH__ = undefined;
|
|
274
|
+
}
|
|
275
|
+
}, 30_000);
|
|
276
|
+
|
|
277
|
+
test("keeps the markup and useId values the template had without the boundary, and hydrates them in place", async () => {
|
|
278
|
+
const routes = {
|
|
279
|
+
"(ids)/_layout.tsx": idsLayoutSource,
|
|
280
|
+
"(ids)/ids.tsx": pageSource,
|
|
281
|
+
"(bare)/_layout.tsx": idsLayoutSource,
|
|
282
|
+
"(bare)/bar.tsx": pageSource,
|
|
283
|
+
};
|
|
284
|
+
await withBuiltPages({ routes, unbounded: "(bare)" }, async (render) => {
|
|
285
|
+
const beforeScripts = (html: string) => html.slice(html.indexOf("<body>"), html.indexOf("<script"));
|
|
286
|
+
const bounded = await render("ids");
|
|
287
|
+
const bare = beforeScripts((await render("bar")).html);
|
|
288
|
+
expect(beforeScripts(bounded.html)).toContain('<section id="user"><b id="_R_');
|
|
289
|
+
expect(beforeScripts(bounded.html).replace('data-firstpath="ids"', 'data-firstpath="bar"')).toBe(bare);
|
|
290
|
+
|
|
291
|
+
await hydrated(bounded.payload, ["#pageContent", "#user", "#user b"], (container, uncaught, recoverable) => {
|
|
292
|
+
expect(container.querySelector("#user b")?.id).toStartWith("_R_");
|
|
293
|
+
expect({ uncaught, recoverable }).toEqual({ uncaught: [], recoverable: [] });
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
}, 30_000);
|
|
297
|
+
});
|
package/biome.base.json
CHANGED
|
@@ -227,7 +227,8 @@
|
|
|
227
227
|
],
|
|
228
228
|
"plugins": [
|
|
229
229
|
"./node_modules/@akanjs/devkit/lint/no-document-cookie.grit",
|
|
230
|
-
"./node_modules/@akanjs/devkit/lint/no-web-storage.grit"
|
|
230
|
+
"./node_modules/@akanjs/devkit/lint/no-web-storage.grit",
|
|
231
|
+
"./node_modules/@akanjs/devkit/lint/no-import-common-err.grit"
|
|
231
232
|
]
|
|
232
233
|
},
|
|
233
234
|
{
|
package/cloud/cloudApi.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, rm } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import dayjs from "dayjs";
|
|
5
5
|
import type { Workspace } from "../commandDecorators";
|
|
6
|
-
import { tempDirs, writeJson, writeText } from "../testHelpers";
|
|
6
|
+
import { tempDirs, writeJson, writeText } from "../test/testHelpers";
|
|
7
7
|
import { CloudApi } from "./cloudApi";
|
|
8
8
|
|
|
9
9
|
// The cloud rotates a refresh token on every use and treats a second use as theft, revoking every session.
|
package/cloud/configLock.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { tempDirs } from "../testHelpers";
|
|
4
|
+
import { tempDirs } from "../test/testHelpers";
|
|
5
5
|
import { ConfigLock } from "./configLock";
|
|
6
6
|
|
|
7
7
|
const makeRoot = tempDirs("akan-config-lock-");
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import { mkdir, stat } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import dayjs from "dayjs";
|
|
5
|
-
import { tempDirs } from "../testHelpers";
|
|
5
|
+
import { tempDirs } from "../test/testHelpers";
|
|
6
6
|
import { GlobalConfig } from "./globalConfig";
|
|
7
7
|
|
|
8
8
|
const tempHome = tempDirs("akan-global-config-");
|
package/cloud/globalConfig.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { trimTrailingSlashes } from "akanjs/common";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
|
-
import { FileSys } from "../fileSys";
|
|
4
|
+
import { FileSys } from "../util/fileSys";
|
|
5
5
|
import { ConfigLock } from "./configLock";
|
|
6
6
|
import {
|
|
7
7
|
type AccessToken,
|
|
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { truncate, writeFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import type { Workspace } from "../commandDecorators";
|
|
6
|
-
import { tempDirs } from "../testHelpers";
|
|
6
|
+
import { tempDirs } from "../test/testHelpers";
|
|
7
7
|
import { CloudApi } from "./cloudApi";
|
|
8
8
|
import { UpdatePackUpload } from "./updatePackUpload";
|
|
9
9
|
|
|
@@ -12,6 +12,11 @@ import type { CodeAgentProxy } from "./CodeAgentProxy";
|
|
|
12
12
|
import { CodeSessionIndex } from "./CodeSessionIndex";
|
|
13
13
|
import { WorkspaceTrust } from "./WorkspaceTrust";
|
|
14
14
|
|
|
15
|
+
type PrepareRequest = (
|
|
16
|
+
model: unknown,
|
|
17
|
+
options?: Record<string, unknown>,
|
|
18
|
+
) => Promise<{ model: { compat?: Record<string, unknown> } }>;
|
|
19
|
+
|
|
15
20
|
export interface AkanCodeServicesOptions {
|
|
16
21
|
workspaceRoot: string;
|
|
17
22
|
cwd: string;
|
|
@@ -30,6 +35,8 @@ export class AkanCodeServices {
|
|
|
30
35
|
enableAnalytics: false,
|
|
31
36
|
quietStartup: true,
|
|
32
37
|
compaction: { reserveTokens: AkanCodeCompaction.reserveFloor },
|
|
38
|
+
// pi 1.5 defaults to "idle", which sends billed cache refreshes for up to 30 minutes between turns.
|
|
39
|
+
cacheWarming: "streaming",
|
|
33
40
|
});
|
|
34
41
|
}
|
|
35
42
|
|
|
@@ -43,11 +50,27 @@ export class AkanCodeServices {
|
|
|
43
50
|
: akanCodePaths.authFile(),
|
|
44
51
|
modelsPath: akanCodePaths.modelsFile(),
|
|
45
52
|
});
|
|
53
|
+
AkanCodeServices.#holdMessageThreadsOff(runtime);
|
|
46
54
|
if (proxy) await proxy.apply(runtime);
|
|
47
55
|
else await AkanEnvKeys.apply(runtime, workspaceRoot);
|
|
48
56
|
return runtime;
|
|
49
57
|
}
|
|
50
58
|
|
|
59
|
+
// pi 1.5 turned Anthropic message threads on for api.anthropic.com; a models.json `compat` that names it still wins.
|
|
60
|
+
static #holdMessageThreadsOff(runtime: ModelRuntime) {
|
|
61
|
+
const target = runtime as unknown as { prepareRequest?: PrepareRequest };
|
|
62
|
+
const original = target.prepareRequest?.bind(runtime);
|
|
63
|
+
if (!original) throw new Error("The model runtime no longer exposes prepareRequest; update AkanCodeServices");
|
|
64
|
+
target.prepareRequest = async (model, options) => {
|
|
65
|
+
const prepared = await original(model, options);
|
|
66
|
+
if (prepared.model.compat?.supportsMessageThreads !== undefined) return prepared;
|
|
67
|
+
return {
|
|
68
|
+
...prepared,
|
|
69
|
+
model: { ...prepared.model, compat: { ...prepared.model.compat, supportsMessageThreads: false } },
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
51
74
|
static sessions(workspaceRoot: string, cwd: string, profile: CodeAgentProfile, resume?: string) {
|
|
52
75
|
//* `remote` has no store of its own yet, so it keeps a file session: a pod worker's suspended asks need it.
|
|
53
76
|
if (profile.session.store === "memory") return SessionManager.inMemory(cwd);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { FileSys } from "../../fileSys";
|
|
4
|
+
import { FileSys } from "../../util/fileSys";
|
|
5
5
|
import { AkanCodeEnv } from "./AkanCodeEnv";
|
|
6
6
|
|
|
7
7
|
// Two candidates: the CLI bundle flattens entry chunks into the package root, where `skills/` is a sibling.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import type { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import { AkanCodeServices } from "./AkanCodeServices";
|
|
7
|
+
import { akanCodePaths } from "./akanCodePaths";
|
|
8
|
+
|
|
9
|
+
const saved: Record<string, string | undefined> = {};
|
|
10
|
+
let home = "";
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
home = mkdtempSync(path.join(tmpdir(), "akan-code-services-test-"));
|
|
14
|
+
for (const key of ["AKAN_CODE_HOME", "ANTHROPIC_API_KEY"]) saved[key] = process.env[key];
|
|
15
|
+
process.env.AKAN_CODE_HOME = home;
|
|
16
|
+
process.env.ANTHROPIC_API_KEY = "test-key-never-sent";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
rmSync(home, { recursive: true, force: true });
|
|
21
|
+
for (const [key, value] of Object.entries(saved)) {
|
|
22
|
+
if (value === undefined) delete process.env[key];
|
|
23
|
+
else process.env[key] = value;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const threadsOf = async (runtime: ModelRuntime) => {
|
|
28
|
+
const model = runtime.getModels("anthropic")[0];
|
|
29
|
+
if (!model) throw new Error("pi lists no anthropic model");
|
|
30
|
+
expect(model.baseUrl).toContain("api.anthropic.com");
|
|
31
|
+
const prepare = (runtime as unknown as { prepareRequest: (model: unknown, options: object) => Promise<unknown> })
|
|
32
|
+
.prepareRequest;
|
|
33
|
+
const prepared = (await prepare.call(runtime, model, {})) as { model: { compat?: Record<string, unknown> } };
|
|
34
|
+
return prepared.model.compat?.supportsMessageThreads;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe("AkanCodeServices holds the defaults akan code had on pi 1.3.0", () => {
|
|
38
|
+
test("prompt caches are warmed only while a turn streams, never in the idle time between turns", () => {
|
|
39
|
+
expect(AkanCodeServices.settings().getCacheWarmingMode()).toBe("streaming");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("an Anthropic request carries the whole conversation instead of continuing a server-side thread", async () => {
|
|
43
|
+
expect(await threadsOf(await AkanCodeServices.runtime(home))).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("models.json can still turn Anthropic message threads on", async () => {
|
|
47
|
+
mkdirSync(path.dirname(akanCodePaths.modelsFile()), { recursive: true });
|
|
48
|
+
writeFileSync(
|
|
49
|
+
akanCodePaths.modelsFile(),
|
|
50
|
+
JSON.stringify({ providers: { anthropic: { compat: { supportsMessageThreads: true } } } }),
|
|
51
|
+
);
|
|
52
|
+
expect(await threadsOf(await AkanCodeServices.runtime(home))).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -41,7 +41,7 @@ export const akanSystemPrompt = (profile: CodeAgentProfile) => {
|
|
|
41
41
|
"## How to answer",
|
|
42
42
|
"",
|
|
43
43
|
"- Answer in as few words as carry the answer. A short question gets one sentence with no heading.",
|
|
44
|
-
"- Do not open with what you are about to do, and do not
|
|
44
|
+
"- Do not open with what you are about to do, and do not retell the tool calls at the end; they are already on the user's screen. A turn that changed files closes with those files and what `akan_verify` said.",
|
|
45
45
|
"- Skip headings, bold labels and bullet lists unless the answer is genuinely a list. Prose is shorter.",
|
|
46
46
|
"- State a file as `path:line`. Do not paste a file back that the user can open.",
|
|
47
47
|
"- Say what you could not do, and why, in one line. Do not offer alternatives nobody asked for.",
|
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import type { ExtensionAPI, InlineExtension } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { type CodeAgentEvent, type CodeAgentProfile, codeAgentPresets } from "akanjs/common";
|
|
6
6
|
import { WorkspaceExecutor } from "../../executors";
|
|
7
|
-
import { isolateEnv, tempDirs } from "../../testHelpers";
|
|
7
|
+
import { isolateEnv, tempDirs } from "../../test/testHelpers";
|
|
8
8
|
import { AkanCodePlugins } from "../tools/AkanCodePlugins";
|
|
9
9
|
import { akanCodeDefaultModel, type CodeAgentModelRef } from "./akanCodeModel";
|
|
10
10
|
import { akanCodePaths } from "./akanCodePaths";
|
|
@@ -16,11 +16,14 @@ the server errors logged meanwhile, console errors and warnings, and layout smel
|
|
|
16
16
|
running one.
|
|
17
17
|
- Paths are comma-separated (`akan preview <app> /board,/board/new`) and get the default locale when they lack
|
|
18
18
|
one, unless the app sets `localePrefix: "as-needed"` and `--csr` is off. What the server answers outside a
|
|
19
|
-
locale opens as written: a `/_akan` route such as Studio
|
|
20
|
-
API prefix, `/__csr`, `/__rsc`, `/.well-known`,
|
|
21
|
-
`/robots.txt`, `/sitemap.xml`, `manifest.webmanifest` and a file in
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
locale opens as written, with no locale and no CSR boot query: a `/_akan` route such as Studio
|
|
20
|
+
(`/_akan/studio?view=runtime`), a route under the API prefix, `/__csr`, `/__rsc`, `/.well-known`,
|
|
21
|
+
`/openapi.json`, `/mcp`, `/favicon.ico`, `/robots.txt`, `/sitemap.xml`, `manifest.webmanifest` and a file in
|
|
22
|
+
the app's `public/`; `--csr` prints a note naming them. `/mcp` answers only `POST`, so preview cannot check it
|
|
23
|
+
(it fails with 405); the `akan-mcp` exposure test does. A full URL (`http://localhost:<port>/oauth/token`)
|
|
24
|
+
opens its path and query the same way, always on the app's dev server, with a note when it names another
|
|
25
|
+
server: use it for an endpoint mounted outside the API prefix. A page `--changed` finds opens as a page even at
|
|
26
|
+
a server route's path, under the same locale rule, and `/en` and `/en/` open once.
|
|
24
27
|
`--changed` adds the pages your uncommitted page and layout edits reach. A dynamic route needs a concrete
|
|
25
28
|
path (`/memo/1`); `akan context --app <app>` lists every route with its params and search names.
|
|
26
29
|
- The viewport is a 390x844 phone; `--desktop` is 1280x800. `--csr` loads each page in the CSR boot the native
|
|
@@ -15,6 +15,8 @@ This is the common failure. Import `Err` from the source matching the **runtime
|
|
|
15
15
|
- server code: `import { Err } from "../dict"`
|
|
16
16
|
- UI: `from "@libs/<lib>/client"` or `from "@apps/<app>/client"`
|
|
17
17
|
|
|
18
|
+
Never `from "akanjs/common"` (`no-import-common-err.grit`): that `Err` takes any string, so a mistyped key compiles.
|
|
19
|
+
|
|
18
20
|
## Where the rule does not apply
|
|
19
21
|
|
|
20
22
|
The lint rule exempts tests, `*.constant.ts`, `common/**`, and `env/**`. The last two have **no legal `Err`
|
|
@@ -38,3 +40,8 @@ discards what the endpoint chose to say, and a bare `Error` is generalized to "I
|
|
|
38
40
|
way out.
|
|
39
41
|
|
|
40
42
|
Korean `.error()` messages end in `다.`.
|
|
43
|
+
|
|
44
|
+
**The framework's own failures carry a code.** A `NoDocumentError`, an `Exception` status class or another
|
|
45
|
+
`AkanError` names its kind in `code`; branch on that with `AkanError.is(error, "<code>")`, never on its message.
|
|
46
|
+
|
|
47
|
+
Every code, its status and whether the caller's JSON carries it: `get_guideline` with `errorCodes`.
|
|
@@ -13,7 +13,7 @@ an endpoint with a real guard is published, one with none is refused, and so is
|
|
|
13
13
|
|
|
14
14
|
- `mcp: false` on an endpoint, or a `slice()` `mcp` map mirroring `guards`, keeps a perfectly guarded step (a UI
|
|
15
15
|
state-machine step a model would only call by mistake) off the shelf. It is an opt-out; everything else still
|
|
16
|
-
publishes.
|
|
16
|
+
publishes. `mcp: "agent"` keeps an entry off `/mcp` but listed to `AgentToolsRole` and `agentService.loop`.
|
|
17
17
|
- `guards: [Every, Person]` reserves an act for a person; `.with(AgentCall)` narrows what an agent's call may do.
|
|
18
18
|
- A guard's `static scope` decides whether a listing can hide the entry: `"account"` guards are evaluated per
|
|
19
19
|
caller, `"resource"` guards stay visible and stop the call.
|
|
@@ -32,6 +32,24 @@ an endpoint with a real guard is published, one with none is refused, and so is
|
|
|
32
32
|
- `page().app(name, description, load)` publishes one component a host draws in the chat, as a read-only tool
|
|
33
33
|
whose `load` may only query.
|
|
34
34
|
|
|
35
|
+
## Calling it from the server
|
|
36
|
+
|
|
37
|
+
- `plug(AgentToolsRole)` gives a service `listAs(account, { allow })` / `callAs(account, call)`: the same catalogue
|
|
38
|
+
and refusals in-process plus the `mcp: "agent"` entries, batch servers included. Pass only an account the server resolved, never client input.
|
|
39
|
+
- `this.agentService.loop({ account | principal, allow, messages, approve, untrusted, onMessage, meta, budget })`
|
|
40
|
+
runs a model over those tools until it answers; `option.setAgentAccountResolver` resolves a stored `principal`
|
|
41
|
+
before every round. Each round is metered as its own turn with `turn.loop` and `turn.meta`. With no `untrusted`,
|
|
42
|
+
everything a tool returns counts as untrusted: a run with no `approve` then writes only before its first result,
|
|
43
|
+
so pass `approve`, or `untrusted` to name the results that carry another party's text. `toolkits` holds named
|
|
44
|
+
groups of `allow` back until the model calls `openToolkit`; `clientTools` (from `AgentClientTools` on an open page)
|
|
45
|
+
parks a call as `awaiting { client: true }` for the page to run; `ask: true` lists `askUser`, which parks as
|
|
46
|
+
`awaiting { question: true }`. Resume either with `answer: { id, result | error }`, never by appending a
|
|
47
|
+
client's result to `messages`, and never take `messages` from a request: store what `onMessage` hands out.
|
|
48
|
+
- `remotes: this.remoteService.sources(account, [{ name, url, description }])` (`libs/shared`, `remote.enabled`) lets
|
|
49
|
+
the loop call another server's `/mcp` as the user: each is a toolkit, tools read `<name>.<tool>`, a missing
|
|
50
|
+
connection parks as `awaiting { connect: name }` for `<Remote.Util.Connect>`, and every remote result taints the run.
|
|
51
|
+
Once connected, resume with the stored messages; when the user declines, resume with `answer: { id, error }`.
|
|
52
|
+
|
|
35
53
|
## Verify
|
|
36
54
|
|
|
37
55
|
- One exposure test per app in `srvkit/mcpExposure.signal.test.ts`: list the tools with a user token, pin the names
|
|
@@ -16,7 +16,7 @@ Everything else is pages, sections, and props.
|
|
|
16
16
|
- A page or section whose content you can write as static JSX or props is not an entity. "A self-intro page
|
|
17
17
|
with two detail pages" is pages only — no `profile` module.
|
|
18
18
|
- Never invent a supporting entity (profile, category, tag, author, like) to round out a design. If one looks
|
|
19
|
-
genuinely necessary, say
|
|
19
|
+
genuinely necessary, build the request without it and say in your reply why it may be needed; the user decides.
|
|
20
20
|
- "… plus a comment zone that saves to a database" is exactly one new module: `comment`.
|
|
21
21
|
- Check what exists first (`list_modules`) and extend it when it already fits — `add-field` / `add-slice` /
|
|
22
22
|
`create-ui` beat a whole new module.
|
|
@@ -7,9 +7,9 @@ description: "Run the akan check loop after editing and fix each failure class t
|
|
|
7
7
|
|
|
8
8
|
## One call does the whole chain
|
|
9
9
|
|
|
10
|
-
`akan verify` (the `akan_verify` tool in akan code) syncs, lints with fixes, typechecks,
|
|
11
|
-
changed app, and runs the SSR check for a `.tsx` change — over everything the working tree has changed, in one
|
|
12
|
-
process. It prints one line when it passes and one line per problem when it fails. **Run it after editing,
|
|
10
|
+
`akan verify` (the `akan_verify` tool in akan code) syncs, lints with fixes, typechecks, builds each
|
|
11
|
+
changed app's server and SSR routes, and runs the SSR check for a `.tsx` change — over everything the working tree has changed, in one
|
|
12
|
+
process. A changed lib also typechecks every app and lib that uses it, so an error can name a file you did not edit. It prints one line when it passes and one line per problem when it fails. **Run it after editing,
|
|
13
13
|
before you say you are done.** In akan code it also runs itself at the end of a turn that changed source.
|
|
14
14
|
|
|
15
15
|
Never run `akan lint`, `akan typecheck` and `akan build` in turn: that is the same work three times over, at
|
|
@@ -65,7 +65,7 @@ export class AkanToolPack {
|
|
|
65
65
|
name: AkanToolPack.verifyToolName,
|
|
66
66
|
label: "akan verify",
|
|
67
67
|
description:
|
|
68
|
-
"Run `akan verify` over everything the working tree has changed: sync, lint (with fixes), typecheck, a
|
|
68
|
+
"Run `akan verify` over everything the working tree has changed: sync, lint (with fixes), typecheck, a build of each changed app's server and SSR routes, and the SSR check for .tsx changes, in one call. It prints one line when it passes and one line per problem when it fails. Call this after editing, before you finish; never run lint, typecheck or build separately.",
|
|
69
69
|
promptSnippet: "akan_verify: sync, lint, typecheck and build what the working tree changed, in one call",
|
|
70
70
|
parameters: Type.Object({}),
|
|
71
71
|
execute: async () => {
|
|
@@ -77,7 +77,7 @@ export class AkanToolPack {
|
|
|
77
77
|
|
|
78
78
|
static async #guidelineNames() {
|
|
79
79
|
try {
|
|
80
|
-
const { Prompter } = await import("../../prompter");
|
|
80
|
+
const { Prompter } = await import("../../guideline/prompter");
|
|
81
81
|
return await Prompter.listGuidelines();
|
|
82
82
|
} catch {
|
|
83
83
|
return [];
|
|
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { codeAgentPresets } from "akanjs/common";
|
|
6
|
-
import { makeCliTempWorkspace, tempRoots, writeText } from "../../testHelpers";
|
|
6
|
+
import { makeCliTempWorkspace, tempRoots, writeText } from "../../test/testHelpers";
|
|
7
7
|
import { CodeAgent, type CodeAgentOptions } from "../agent/CodeAgent";
|
|
8
8
|
import { SubagentPool } from "../agent/SubagentPool";
|
|
9
9
|
import { WorkspaceTrust } from "../agent/WorkspaceTrust";
|