@agimon-ai/po 0.0.0-alpha.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/LICENSE +21 -0
- package/README.md +755 -0
- package/assets/banner.png +0 -0
- package/assets/banner.svg +25 -0
- package/assets/favicon.svg +15 -0
- package/assets/logo-light.png +0 -0
- package/assets/logo-light.svg +25 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +25 -0
- package/assets/mascot.png +0 -0
- package/assets/mascot.svg +25 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/antigravity.cjs +5 -0
- package/dist/antigravity.d.mts +2 -0
- package/dist/antigravity.mjs +2 -0
- package/dist/apiContracts.cjs +11 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +52 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +7 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/baseCommand.cjs +3 -0
- package/dist/baseCommand.d.mts +2 -0
- package/dist/baseCommand.mjs +2 -0
- package/dist/bin/cli.cjs +24 -0
- package/dist/bin/cli.cjs.map +1 -0
- package/dist/bin/cli.d.mts +1 -0
- package/dist/bin/cli.mjs +25 -0
- package/dist/bin/cli.mjs.map +1 -0
- package/dist/bin/doomRunner.cjs +33 -0
- package/dist/bin/doomRunner.cjs.map +1 -0
- package/dist/bin/doomRunner.d.mts +4 -0
- package/dist/bin/doomRunner.d.mts.map +1 -0
- package/dist/bin/doomRunner.mjs +32 -0
- package/dist/bin/doomRunner.mjs.map +1 -0
- package/dist/bin/serve.cjs +30 -0
- package/dist/bin/serve.cjs.map +1 -0
- package/dist/bin/serve.d.mts +1 -0
- package/dist/bin/serve.mjs +31 -0
- package/dist/bin/serve.mjs.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.cjs +342 -0
- package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.d.mts +85 -0
- package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -0
- package/dist/builders/cli/extensionAssembler/index.mjs +335 -0
- package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -0
- package/dist/catalog/index.json +430 -0
- package/dist/cli.cjs +28 -0
- package/dist/cli.d.mts +11 -0
- package/dist/cli.mjs +11 -0
- package/dist/cliApp.cjs +6 -0
- package/dist/cliApp.d.mts +2 -0
- package/dist/cliApp.mjs +2 -0
- package/dist/codex.cjs +8 -0
- package/dist/codex.d.mts +2 -0
- package/dist/codex.mjs +2 -0
- package/dist/commands.cjs +18 -0
- package/dist/commands.d.mts +9 -0
- package/dist/commands.mjs +9 -0
- package/dist/compatibility.cjs +27 -0
- package/dist/compatibility.d.mts +6 -0
- package/dist/compatibility.mjs +6 -0
- package/dist/compatibilityCommand.cjs +4 -0
- package/dist/compatibilityCommand.d.mts +2 -0
- package/dist/compatibilityCommand.mjs +2 -0
- package/dist/compatibilityContext.cjs +3 -0
- package/dist/compatibilityContext.d.mts +2 -0
- package/dist/compatibilityContext.mjs +2 -0
- package/dist/compatibilityOptions.cjs +5 -0
- package/dist/compatibilityOptions.d.mts +2 -0
- package/dist/compatibilityOptions.mjs +2 -0
- package/dist/config.cjs +163 -0
- package/dist/config.d.mts +7 -0
- package/dist/config.mjs +7 -0
- package/dist/doctorCommand.cjs +5 -0
- package/dist/doctorCommand.d.mts +2 -0
- package/dist/doctorCommand.mjs +2 -0
- package/dist/emitMcpCommand.cjs +4 -0
- package/dist/emitMcpCommand.d.mts +2 -0
- package/dist/emitMcpCommand.mjs +2 -0
- package/dist/explainCommand.cjs +5 -0
- package/dist/explainCommand.d.mts +2 -0
- package/dist/explainCommand.mjs +2 -0
- package/dist/extensions/server.cjs +39 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +34 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/harnessContext.cjs +5 -0
- package/dist/harnessContext.d.mts +2 -0
- package/dist/harnessContext.mjs +2 -0
- package/dist/harnessState.cjs +19 -0
- package/dist/harnessState.d.mts +2 -0
- package/dist/harnessState.mjs +2 -0
- package/dist/help.cjs +12 -0
- package/dist/help.d.mts +6 -0
- package/dist/help.mjs +6 -0
- package/dist/index.cjs +306 -0
- package/dist/index.d.mts +40 -0
- package/dist/index.mjs +37 -0
- package/dist/initCommand.cjs +4 -0
- package/dist/initCommand.d.mts +2 -0
- package/dist/initCommand.mjs +2 -0
- package/dist/matrixOptions.cjs +28 -0
- package/dist/matrixOptions.d.mts +2 -0
- package/dist/matrixOptions.mjs +2 -0
- package/dist/matrixSwitcher.cjs +11 -0
- package/dist/matrixSwitcher.d.mts +3 -0
- package/dist/matrixSwitcher.mjs +3 -0
- package/dist/mcpFilter.cjs +9 -0
- package/dist/mcpFilter.d.mts +1 -0
- package/dist/mcpFilter.mjs +2 -0
- package/dist/options.cjs +3 -0
- package/dist/options.d.mts +2 -0
- package/dist/options.mjs +2 -0
- package/dist/process.cjs +12 -0
- package/dist/process.d.mts +2 -0
- package/dist/process.mjs +2 -0
- package/dist/projectTrust.cjs +6 -0
- package/dist/projectTrust.d.mts +2 -0
- package/dist/projectTrust.mjs +2 -0
- package/dist/repository.cjs +5 -0
- package/dist/repository.d.mts +2 -0
- package/dist/repository.mjs +2 -0
- package/dist/resourceCollector.cjs +9 -0
- package/dist/resourceCollector.d.mts +1 -0
- package/dist/resourceCollector.mjs +2 -0
- package/dist/router.cjs +6 -0
- package/dist/router.d.mts +2 -0
- package/dist/router.mjs +2 -0
- package/dist/services.cjs +97 -0
- package/dist/services.d.mts +12 -0
- package/dist/services.mjs +12 -0
- package/dist/shared.cjs +18 -0
- package/dist/shared.d.mts +2 -0
- package/dist/shared.mjs +2 -0
- package/dist/src/bin/agentDirectory.cjs +27 -0
- package/dist/src/bin/agentDirectory.cjs.map +1 -0
- package/dist/src/bin/agentDirectory.mjs +26 -0
- package/dist/src/bin/agentDirectory.mjs.map +1 -0
- package/dist/src/builders/apiContractExport/index.cjs +126 -0
- package/dist/src/builders/apiContractExport/index.cjs.map +1 -0
- package/dist/src/builders/apiContractExport/index.mjs +123 -0
- package/dist/src/builders/apiContractExport/index.mjs.map +1 -0
- package/dist/src/builders/cli/entryResolution.cjs +39 -0
- package/dist/src/builders/cli/entryResolution.cjs.map +1 -0
- package/dist/src/builders/cli/entryResolution.mjs +35 -0
- package/dist/src/builders/cli/entryResolution.mjs.map +1 -0
- package/dist/src/builders/cli/harnessContext.cjs +175 -0
- package/dist/src/builders/cli/harnessContext.cjs.map +1 -0
- package/dist/src/builders/cli/harnessContext.d.mts +48 -0
- package/dist/src/builders/cli/harnessContext.d.mts.map +1 -0
- package/dist/src/builders/cli/harnessContext.mjs +167 -0
- package/dist/src/builders/cli/harnessContext.mjs.map +1 -0
- package/dist/src/builders/cli/sessionComposition.cjs +27 -0
- package/dist/src/builders/cli/sessionComposition.cjs.map +1 -0
- package/dist/src/builders/cli/sessionComposition.mjs +26 -0
- package/dist/src/builders/cli/sessionComposition.mjs.map +1 -0
- package/dist/src/builders/hooks/index.cjs +238 -0
- package/dist/src/builders/hooks/index.cjs.map +1 -0
- package/dist/src/builders/hooks/index.mjs +231 -0
- package/dist/src/builders/hooks/index.mjs.map +1 -0
- package/dist/src/builders/native/index.cjs +176 -0
- package/dist/src/builders/native/index.cjs.map +1 -0
- package/dist/src/builders/native/index.d.mts +36 -0
- package/dist/src/builders/native/index.d.mts.map +1 -0
- package/dist/src/builders/native/index.mjs +170 -0
- package/dist/src/builders/native/index.mjs.map +1 -0
- package/dist/src/builders/server/backgroundSync.cjs +333 -0
- package/dist/src/builders/server/backgroundSync.cjs.map +1 -0
- package/dist/src/builders/server/backgroundSync.mjs +320 -0
- package/dist/src/builders/server/backgroundSync.mjs.map +1 -0
- package/dist/src/builders/server/computerUseBinding.cjs +273 -0
- package/dist/src/builders/server/computerUseBinding.cjs.map +1 -0
- package/dist/src/builders/server/computerUseBinding.mjs +269 -0
- package/dist/src/builders/server/computerUseBinding.mjs.map +1 -0
- package/dist/src/builders/server/computerUseRecordings.cjs +188 -0
- package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -0
- package/dist/src/builders/server/computerUseRecordings.mjs +184 -0
- package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -0
- package/dist/src/builders/server/defaultWorkspace.cjs +38 -0
- package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -0
- package/dist/src/builders/server/defaultWorkspace.mjs +35 -0
- package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -0
- package/dist/src/builders/server/idleRestart.cjs +149 -0
- package/dist/src/builders/server/idleRestart.cjs.map +1 -0
- package/dist/src/builders/server/idleRestart.mjs +136 -0
- package/dist/src/builders/server/idleRestart.mjs.map +1 -0
- package/dist/src/builders/server/index.cjs +63 -0
- package/dist/src/builders/server/index.cjs.map +1 -0
- package/dist/src/builders/server/index.mjs +60 -0
- package/dist/src/builders/server/index.mjs.map +1 -0
- package/dist/src/builders/server/logSink.cjs +57 -0
- package/dist/src/builders/server/logSink.cjs.map +1 -0
- package/dist/src/builders/server/logSink.mjs +57 -0
- package/dist/src/builders/server/logSink.mjs.map +1 -0
- package/dist/src/builders/server/mcpApp.cjs +152 -0
- package/dist/src/builders/server/mcpApp.cjs.map +1 -0
- package/dist/src/builders/server/mcpApp.d.mts +18 -0
- package/dist/src/builders/server/mcpApp.d.mts.map +1 -0
- package/dist/src/builders/server/mcpApp.mjs +147 -0
- package/dist/src/builders/server/mcpApp.mjs.map +1 -0
- package/dist/src/builders/server/mcpAppBuild.cjs +111 -0
- package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -0
- package/dist/src/builders/server/mcpAppBuild.d.mts +24 -0
- package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -0
- package/dist/src/builders/server/mcpAppBuild.mjs +105 -0
- package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -0
- package/dist/src/builders/server/mcpBundle.cjs +87 -0
- package/dist/src/builders/server/mcpBundle.cjs.map +1 -0
- package/dist/src/builders/server/mcpBundle.d.mts +23 -0
- package/dist/src/builders/server/mcpBundle.d.mts.map +1 -0
- package/dist/src/builders/server/mcpBundle.mjs +84 -0
- package/dist/src/builders/server/mcpBundle.mjs.map +1 -0
- package/dist/src/builders/server/packageReloadCheck.cjs +62 -0
- package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -0
- package/dist/src/builders/server/packageReloadCheck.mjs +61 -0
- package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -0
- package/dist/src/builders/server/packageUrl.cjs +210 -0
- package/dist/src/builders/server/packageUrl.cjs.map +1 -0
- package/dist/src/builders/server/packageUrl.mjs +203 -0
- package/dist/src/builders/server/packageUrl.mjs.map +1 -0
- package/dist/src/builders/server/runtime.cjs +1428 -0
- package/dist/src/builders/server/runtime.cjs.map +1 -0
- package/dist/src/builders/server/runtime.mjs +1420 -0
- package/dist/src/builders/server/runtime.mjs.map +1 -0
- package/dist/src/builders/server/runtimeResources.cjs +72 -0
- package/dist/src/builders/server/runtimeResources.cjs.map +1 -0
- package/dist/src/builders/server/runtimeResources.mjs +71 -0
- package/dist/src/builders/server/runtimeResources.mjs.map +1 -0
- package/dist/src/builders/server/selectionStatus.cjs +12 -0
- package/dist/src/builders/server/selectionStatus.cjs.map +1 -0
- package/dist/src/builders/server/selectionStatus.mjs +12 -0
- package/dist/src/builders/server/selectionStatus.mjs.map +1 -0
- package/dist/src/builders/server/sessionArguments.cjs +63 -0
- package/dist/src/builders/server/sessionArguments.cjs.map +1 -0
- package/dist/src/builders/server/sessionArguments.mjs +62 -0
- package/dist/src/builders/server/sessionArguments.mjs.map +1 -0
- package/dist/src/builders/server/shutdown.cjs +16 -0
- package/dist/src/builders/server/shutdown.cjs.map +1 -0
- package/dist/src/builders/server/shutdown.mjs +16 -0
- package/dist/src/builders/server/shutdown.mjs.map +1 -0
- package/dist/src/builders/server/webTemplateDecision.cjs +34 -0
- package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -0
- package/dist/src/builders/server/webTemplateDecision.mjs +32 -0
- package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -0
- package/dist/src/builders/server/workspaceCheckout.cjs +31 -0
- package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -0
- package/dist/src/builders/server/workspaceCheckout.mjs +29 -0
- package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -0
- package/dist/src/builders/web/bundle.cjs +225 -0
- package/dist/src/builders/web/bundle.cjs.map +1 -0
- package/dist/src/builders/web/bundle.d.mts +65 -0
- package/dist/src/builders/web/bundle.d.mts.map +1 -0
- package/dist/src/builders/web/bundle.mjs +221 -0
- package/dist/src/builders/web/bundle.mjs.map +1 -0
- package/dist/src/builders/web/bundleAssetPolicy.cjs +96 -0
- package/dist/src/builders/web/bundleAssetPolicy.cjs.map +1 -0
- package/dist/src/builders/web/bundleAssetPolicy.d.mts +22 -0
- package/dist/src/builders/web/bundleAssetPolicy.d.mts.map +1 -0
- package/dist/src/builders/web/bundleAssetPolicy.mjs +95 -0
- package/dist/src/builders/web/bundleAssetPolicy.mjs.map +1 -0
- package/dist/src/builders/web/index.cjs +361 -0
- package/dist/src/builders/web/index.cjs.map +1 -0
- package/dist/src/builders/web/index.d.mts +109 -0
- package/dist/src/builders/web/index.d.mts.map +1 -0
- package/dist/src/builders/web/index.mjs +342 -0
- package/dist/src/builders/web/index.mjs.map +1 -0
- package/dist/src/builders/web/webDevRoots.cjs +27 -0
- package/dist/src/builders/web/webDevRoots.cjs.map +1 -0
- package/dist/src/builders/web/webDevRoots.d.mts +22 -0
- package/dist/src/builders/web/webDevRoots.d.mts.map +1 -0
- package/dist/src/builders/web/webDevRoots.mjs +25 -0
- package/dist/src/builders/web/webDevRoots.mjs.map +1 -0
- package/dist/src/builders/web/webPluginGenerate.cjs +188 -0
- package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -0
- package/dist/src/builders/web/webPluginGenerate.d.mts +56 -0
- package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginGenerate.mjs +178 -0
- package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -0
- package/dist/src/builders/web/webPluginManifest.cjs +128 -0
- package/dist/src/builders/web/webPluginManifest.cjs.map +1 -0
- package/dist/src/builders/web/webPluginManifest.d.mts +64 -0
- package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginManifest.mjs +118 -0
- package/dist/src/builders/web/webPluginManifest.mjs.map +1 -0
- package/dist/src/builders/web/webPluginScan.cjs +57 -0
- package/dist/src/builders/web/webPluginScan.cjs.map +1 -0
- package/dist/src/builders/web/webPluginScan.d.mts +19 -0
- package/dist/src/builders/web/webPluginScan.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginScan.mjs +54 -0
- package/dist/src/builders/web/webPluginScan.mjs.map +1 -0
- package/dist/src/builders/web/webPluginVite.cjs +255 -0
- package/dist/src/builders/web/webPluginVite.cjs.map +1 -0
- package/dist/src/builders/web/webPluginVite.d.mts +64 -0
- package/dist/src/builders/web/webPluginVite.d.mts.map +1 -0
- package/dist/src/builders/web/webPluginVite.mjs +242 -0
- package/dist/src/builders/web/webPluginVite.mjs.map +1 -0
- package/dist/src/cli/cliApp.cjs +187 -0
- package/dist/src/cli/cliApp.cjs.map +1 -0
- package/dist/src/cli/cliApp.d.mts +32 -0
- package/dist/src/cli/cliApp.d.mts.map +1 -0
- package/dist/src/cli/cliApp.mjs +184 -0
- package/dist/src/cli/cliApp.mjs.map +1 -0
- package/dist/src/cli/commands/api-export/index.cjs +66 -0
- package/dist/src/cli/commands/api-export/index.cjs.map +1 -0
- package/dist/src/cli/commands/api-export/index.mjs +62 -0
- package/dist/src/cli/commands/api-export/index.mjs.map +1 -0
- package/dist/src/cli/commands/baseCommand.cjs +16 -0
- package/dist/src/cli/commands/baseCommand.cjs.map +1 -0
- package/dist/src/cli/commands/baseCommand.d.mts +24 -0
- package/dist/src/cli/commands/baseCommand.d.mts.map +1 -0
- package/dist/src/cli/commands/baseCommand.mjs +16 -0
- package/dist/src/cli/commands/baseCommand.mjs.map +1 -0
- package/dist/src/cli/commands/compat/context.cjs +115 -0
- package/dist/src/cli/commands/compat/context.cjs.map +1 -0
- package/dist/src/cli/commands/compat/context.d.mts +22 -0
- package/dist/src/cli/commands/compat/context.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/context.mjs +110 -0
- package/dist/src/cli/commands/compat/context.mjs.map +1 -0
- package/dist/src/cli/commands/compat/help.cjs +26 -0
- package/dist/src/cli/commands/compat/help.cjs.map +1 -0
- package/dist/src/cli/commands/compat/help.d.mts +4 -0
- package/dist/src/cli/commands/compat/help.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/help.mjs +25 -0
- package/dist/src/cli/commands/compat/help.mjs.map +1 -0
- package/dist/src/cli/commands/compat/index.cjs +73 -0
- package/dist/src/cli/commands/compat/index.cjs.map +1 -0
- package/dist/src/cli/commands/compat/index.d.mts +14 -0
- package/dist/src/cli/commands/compat/index.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/index.mjs +70 -0
- package/dist/src/cli/commands/compat/index.mjs.map +1 -0
- package/dist/src/cli/commands/compat/options.cjs +88 -0
- package/dist/src/cli/commands/compat/options.cjs.map +1 -0
- package/dist/src/cli/commands/compat/options.d.mts +15 -0
- package/dist/src/cli/commands/compat/options.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/options.mjs +86 -0
- package/dist/src/cli/commands/compat/options.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/antigravity.cjs +294 -0
- package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/antigravity.d.mts +9 -0
- package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/antigravity.mjs +289 -0
- package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/codex.cjs +178 -0
- package/dist/src/cli/commands/compat/providers/codex.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/codex.d.mts +17 -0
- package/dist/src/cli/commands/compat/providers/codex.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/codex.mjs +170 -0
- package/dist/src/cli/commands/compat/providers/codex.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/index.cjs +65 -0
- package/dist/src/cli/commands/compat/providers/index.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/index.d.mts +15 -0
- package/dist/src/cli/commands/compat/providers/index.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/index.mjs +45 -0
- package/dist/src/cli/commands/compat/providers/index.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/process.cjs +172 -0
- package/dist/src/cli/commands/compat/providers/process.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/process.d.mts +33 -0
- package/dist/src/cli/commands/compat/providers/process.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/process.mjs +159 -0
- package/dist/src/cli/commands/compat/providers/process.mjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/shared.cjs +76 -0
- package/dist/src/cli/commands/compat/providers/shared.cjs.map +1 -0
- package/dist/src/cli/commands/compat/providers/shared.d.mts +40 -0
- package/dist/src/cli/commands/compat/providers/shared.d.mts.map +1 -0
- package/dist/src/cli/commands/compat/providers/shared.mjs +61 -0
- package/dist/src/cli/commands/compat/providers/shared.mjs.map +1 -0
- package/dist/src/cli/commands/compat/types.d.mts +31 -0
- package/dist/src/cli/commands/compat/types.d.mts.map +1 -0
- package/dist/src/cli/commands/doctor/help.cjs +19 -0
- package/dist/src/cli/commands/doctor/help.cjs.map +1 -0
- package/dist/src/cli/commands/doctor/help.d.mts +4 -0
- package/dist/src/cli/commands/doctor/help.d.mts.map +1 -0
- package/dist/src/cli/commands/doctor/help.mjs +19 -0
- package/dist/src/cli/commands/doctor/help.mjs.map +1 -0
- package/dist/src/cli/commands/doctor/index.cjs +118 -0
- package/dist/src/cli/commands/doctor/index.cjs.map +1 -0
- package/dist/src/cli/commands/doctor/index.d.mts +33 -0
- package/dist/src/cli/commands/doctor/index.d.mts.map +1 -0
- package/dist/src/cli/commands/doctor/index.mjs +113 -0
- package/dist/src/cli/commands/doctor/index.mjs.map +1 -0
- package/dist/src/cli/commands/emit-mcp/index.cjs +32 -0
- package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -0
- package/dist/src/cli/commands/emit-mcp/index.d.mts +19 -0
- package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -0
- package/dist/src/cli/commands/emit-mcp/index.mjs +31 -0
- package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -0
- package/dist/src/cli/commands/explain/index.cjs +155 -0
- package/dist/src/cli/commands/explain/index.cjs.map +1 -0
- package/dist/src/cli/commands/explain/index.d.mts +57 -0
- package/dist/src/cli/commands/explain/index.d.mts.map +1 -0
- package/dist/src/cli/commands/explain/index.mjs +150 -0
- package/dist/src/cli/commands/explain/index.mjs.map +1 -0
- package/dist/src/cli/commands/init/constants.cjs +11 -0
- package/dist/src/cli/commands/init/constants.cjs.map +1 -0
- package/dist/src/cli/commands/init/constants.mjs +11 -0
- package/dist/src/cli/commands/init/constants.mjs.map +1 -0
- package/dist/src/cli/commands/init/help.cjs +17 -0
- package/dist/src/cli/commands/init/help.cjs.map +1 -0
- package/dist/src/cli/commands/init/help.d.mts +4 -0
- package/dist/src/cli/commands/init/help.d.mts.map +1 -0
- package/dist/src/cli/commands/init/help.mjs +17 -0
- package/dist/src/cli/commands/init/help.mjs.map +1 -0
- package/dist/src/cli/commands/init/index.cjs +67 -0
- package/dist/src/cli/commands/init/index.cjs.map +1 -0
- package/dist/src/cli/commands/init/index.d.mts +12 -0
- package/dist/src/cli/commands/init/index.d.mts.map +1 -0
- package/dist/src/cli/commands/init/index.mjs +63 -0
- package/dist/src/cli/commands/init/index.mjs.map +1 -0
- package/dist/src/cli/commands/init/presenter.cjs +140 -0
- package/dist/src/cli/commands/init/presenter.cjs.map +1 -0
- package/dist/src/cli/commands/init/presenter.d.mts +8 -0
- package/dist/src/cli/commands/init/presenter.d.mts.map +1 -0
- package/dist/src/cli/commands/init/presenter.mjs +140 -0
- package/dist/src/cli/commands/init/presenter.mjs.map +1 -0
- package/dist/src/cli/commands/sync/help.cjs +34 -0
- package/dist/src/cli/commands/sync/help.cjs.map +1 -0
- package/dist/src/cli/commands/sync/help.d.mts +4 -0
- package/dist/src/cli/commands/sync/help.d.mts.map +1 -0
- package/dist/src/cli/commands/sync/help.mjs +34 -0
- package/dist/src/cli/commands/sync/help.mjs.map +1 -0
- package/dist/src/cli/commands/sync/index.cjs +215 -0
- package/dist/src/cli/commands/sync/index.cjs.map +1 -0
- package/dist/src/cli/commands/sync/index.d.mts +20 -0
- package/dist/src/cli/commands/sync/index.d.mts.map +1 -0
- package/dist/src/cli/commands/sync/index.mjs +206 -0
- package/dist/src/cli/commands/sync/index.mjs.map +1 -0
- package/dist/src/cli/commands/sync/presenter.cjs +58 -0
- package/dist/src/cli/commands/sync/presenter.cjs.map +1 -0
- package/dist/src/cli/commands/sync/presenter.d.mts +16 -0
- package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -0
- package/dist/src/cli/commands/sync/presenter.mjs +57 -0
- package/dist/src/cli/commands/sync/presenter.mjs.map +1 -0
- package/dist/src/cli/commands/sync/workflow.cjs +16 -0
- package/dist/src/cli/commands/sync/workflow.cjs.map +1 -0
- package/dist/src/cli/commands/sync/workflow.mjs +16 -0
- package/dist/src/cli/commands/sync/workflow.mjs.map +1 -0
- package/dist/src/cli/commands/web/index.cjs +88 -0
- package/dist/src/cli/commands/web/index.cjs.map +1 -0
- package/dist/src/cli/commands/web/index.mjs +85 -0
- package/dist/src/cli/commands/web/index.mjs.map +1 -0
- package/dist/src/cli/harnessOptions.cjs +70 -0
- package/dist/src/cli/harnessOptions.cjs.map +1 -0
- package/dist/src/cli/harnessOptions.d.mts +26 -0
- package/dist/src/cli/harnessOptions.d.mts.map +1 -0
- package/dist/src/cli/harnessOptions.mjs +66 -0
- package/dist/src/cli/harnessOptions.mjs.map +1 -0
- package/dist/src/cli/help.cjs +82 -0
- package/dist/src/cli/help.cjs.map +1 -0
- package/dist/src/cli/help.d.mts +10 -0
- package/dist/src/cli/help.d.mts.map +1 -0
- package/dist/src/cli/help.mjs +78 -0
- package/dist/src/cli/help.mjs.map +1 -0
- package/dist/src/cli/matrixOptions.cjs +178 -0
- package/dist/src/cli/matrixOptions.cjs.map +1 -0
- package/dist/src/cli/matrixOptions.d.mts +90 -0
- package/dist/src/cli/matrixOptions.d.mts.map +1 -0
- package/dist/src/cli/matrixOptions.mjs +151 -0
- package/dist/src/cli/matrixOptions.mjs.map +1 -0
- package/dist/src/cli/options.cjs +281 -0
- package/dist/src/cli/options.cjs.map +1 -0
- package/dist/src/cli/options.d.mts +5 -0
- package/dist/src/cli/options.d.mts.map +1 -0
- package/dist/src/cli/options.mjs +279 -0
- package/dist/src/cli/options.mjs.map +1 -0
- package/dist/src/cli/router.cjs +57 -0
- package/dist/src/cli/router.cjs.map +1 -0
- package/dist/src/cli/router.d.mts +32 -0
- package/dist/src/cli/router.d.mts.map +1 -0
- package/dist/src/cli/router.mjs +54 -0
- package/dist/src/cli/router.mjs.map +1 -0
- package/dist/src/cli/server/options.cjs +71 -0
- package/dist/src/cli/server/options.cjs.map +1 -0
- package/dist/src/cli/server/options.mjs +70 -0
- package/dist/src/cli/server/options.mjs.map +1 -0
- package/dist/src/cli/server/processGuards.cjs +83 -0
- package/dist/src/cli/server/processGuards.cjs.map +1 -0
- package/dist/src/cli/server/processGuards.mjs +79 -0
- package/dist/src/cli/server/processGuards.mjs.map +1 -0
- package/dist/src/cli/server/run.cjs +69 -0
- package/dist/src/cli/server/run.cjs.map +1 -0
- package/dist/src/cli/server/run.mjs +66 -0
- package/dist/src/cli/server/run.mjs.map +1 -0
- package/dist/src/composition/harnessState/index.cjs +48 -0
- package/dist/src/composition/harnessState/index.cjs.map +1 -0
- package/dist/src/composition/harnessState/index.d.mts +19 -0
- package/dist/src/composition/harnessState/index.d.mts.map +1 -0
- package/dist/src/composition/harnessState/index.mjs +34 -0
- package/dist/src/composition/harnessState/index.mjs.map +1 -0
- package/dist/src/composition/layerPackageInstaller/index.cjs +651 -0
- package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -0
- package/dist/src/composition/layerPackageInstaller/index.d.mts +74 -0
- package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -0
- package/dist/src/composition/layerPackageInstaller/index.mjs +637 -0
- package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -0
- package/dist/src/composition/poHomeMigration/index.cjs +234 -0
- package/dist/src/composition/poHomeMigration/index.cjs.map +1 -0
- package/dist/src/composition/poHomeMigration/index.d.mts +12 -0
- package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -0
- package/dist/src/composition/poHomeMigration/index.mjs +226 -0
- package/dist/src/composition/poHomeMigration/index.mjs.map +1 -0
- package/dist/src/composition/projectTrust/index.cjs +51 -0
- package/dist/src/composition/projectTrust/index.cjs.map +1 -0
- package/dist/src/composition/projectTrust/index.d.mts +22 -0
- package/dist/src/composition/projectTrust/index.d.mts.map +1 -0
- package/dist/src/composition/projectTrust/index.mjs +48 -0
- package/dist/src/composition/projectTrust/index.mjs.map +1 -0
- package/dist/src/composition/repository/index.cjs +68 -0
- package/dist/src/composition/repository/index.cjs.map +1 -0
- package/dist/src/composition/repository/index.d.mts +22 -0
- package/dist/src/composition/repository/index.d.mts.map +1 -0
- package/dist/src/composition/repository/index.mjs +63 -0
- package/dist/src/composition/repository/index.mjs.map +1 -0
- package/dist/src/composition/syncPrune/index.cjs +85 -0
- package/dist/src/composition/syncPrune/index.cjs.map +1 -0
- package/dist/src/composition/syncPrune/index.d.mts +33 -0
- package/dist/src/composition/syncPrune/index.d.mts.map +1 -0
- package/dist/src/composition/syncPrune/index.mjs +82 -0
- package/dist/src/composition/syncPrune/index.mjs.map +1 -0
- package/dist/src/composition/syncService/index.cjs +808 -0
- package/dist/src/composition/syncService/index.cjs.map +1 -0
- package/dist/src/composition/syncService/index.d.mts +65 -0
- package/dist/src/composition/syncService/index.d.mts.map +1 -0
- package/dist/src/composition/syncService/index.mjs +792 -0
- package/dist/src/composition/syncService/index.mjs.map +1 -0
- package/dist/src/composition/syncService/localBuilds.cjs +367 -0
- package/dist/src/composition/syncService/localBuilds.cjs.map +1 -0
- package/dist/src/composition/syncService/localBuilds.mjs +358 -0
- package/dist/src/composition/syncService/localBuilds.mjs.map +1 -0
- package/dist/src/composition/transitionLayers.cjs +17 -0
- package/dist/src/composition/transitionLayers.cjs.map +1 -0
- package/dist/src/composition/transitionLayers.d.mts +6 -0
- package/dist/src/composition/transitionLayers.d.mts.map +1 -0
- package/dist/src/composition/transitionLayers.mjs +16 -0
- package/dist/src/composition/transitionLayers.mjs.map +1 -0
- package/dist/src/composition/types/harness.d.mts +52 -0
- package/dist/src/composition/types/harness.d.mts.map +1 -0
- package/dist/src/extensions/setupDiagnostics.cjs +65 -0
- package/dist/src/extensions/setupDiagnostics.cjs.map +1 -0
- package/dist/src/extensions/setupDiagnostics.mjs +64 -0
- package/dist/src/extensions/setupDiagnostics.mjs.map +1 -0
- package/dist/utils.cjs +4 -0
- package/dist/utils.d.mts +2 -0
- package/dist/utils.mjs +2 -0
- package/dist/webBuilder.cjs +59 -0
- package/dist/webBuilder.d.mts +9 -0
- package/dist/webBuilder.mjs +9 -0
- package/docs/server/api-export.md +86 -0
- package/docs/server/api.md +144 -0
- package/docs/server/getting-started.md +114 -0
- package/docs/server/index.md +67 -0
- package/docs/server/ipc.md +97 -0
- package/docs/server/lifecycle.md +108 -0
- package/docs/server/security.md +101 -0
- package/llms.txt +12 -0
- package/package.json +295 -0
- package/src/prompts/po-author-extension/SKILL.md +35 -0
- package/src/prompts/po-author-extension/references/extension-contract.md +134 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_packageUrl = require("../server/packageUrl.cjs");
|
|
3
|
+
const require_webPluginManifest = require("./webPluginManifest.cjs");
|
|
4
|
+
const require_webPluginScan = require("./webPluginScan.cjs");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
7
|
+
let node_path = require("node:path");
|
|
8
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
9
|
+
let node_child_process = require("node:child_process");
|
|
10
|
+
let node_module = require("node:module");
|
|
11
|
+
let node_crypto = require("node:crypto");
|
|
12
|
+
node_crypto = require_runtime.__toESM(node_crypto, 1);
|
|
13
|
+
//#region src/builders/web/index.ts
|
|
14
|
+
const WEB_PACKAGE = "@agimon-ai/po-web";
|
|
15
|
+
const WEB_PACKAGE_ROOT_ENV = "PO_WEB_PACKAGE_ROOT";
|
|
16
|
+
/** The package roots a set of compositions activates, each once. */
|
|
17
|
+
function compositionPackageRoots(compositions) {
|
|
18
|
+
return [...new Set(compositions.flatMap((composition) => composition.packageEntries).map(packageRootOf).filter((root) => root !== void 0))];
|
|
19
|
+
}
|
|
20
|
+
/** Walks from a resolved module path up to the directory owning its package.json. */
|
|
21
|
+
function packageRootOf(entryPath) {
|
|
22
|
+
let dir = node_path.default.dirname(entryPath);
|
|
23
|
+
for (;;) {
|
|
24
|
+
if (node_fs.default.existsSync(node_path.default.join(dir, "package.json"))) return dir;
|
|
25
|
+
const parent = node_path.default.dirname(dir);
|
|
26
|
+
if (parent === dir) return void 0;
|
|
27
|
+
dir = parent;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function resolveWebPackageRoot(repoRoot, environment) {
|
|
31
|
+
const override = environment[WEB_PACKAGE_ROOT_ENV];
|
|
32
|
+
if (override !== void 0 && override !== "") return node_path.default.resolve(override);
|
|
33
|
+
try {
|
|
34
|
+
return node_path.default.dirname((0, node_module.createRequire)(node_path.default.join(repoRoot, "package.json")).resolve(`${WEB_PACKAGE}/package.json`));
|
|
35
|
+
} catch {
|
|
36
|
+
try {
|
|
37
|
+
return node_path.default.dirname((0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve(`${WEB_PACKAGE}/package.json`));
|
|
38
|
+
} catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The installed po-web host version the global web build would use, or `none` when it is not installed. */
|
|
44
|
+
function webHostVersion(poHome, environment = process.env) {
|
|
45
|
+
const webRoot = resolveWebPackageRoot(poHome, environment);
|
|
46
|
+
if (webRoot === void 0) return "none";
|
|
47
|
+
try {
|
|
48
|
+
const manifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(webRoot, "package.json"), "utf8"));
|
|
49
|
+
return typeof manifest.version === "string" ? manifest.version : "unversioned";
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return `unreadable:${error instanceof Error ? error.message : String(error)}`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Bumped whenever the build's output layout changes, so an old layout is never reused. */
|
|
55
|
+
const GLOBAL_BUILD_FORMAT = "global-web-4";
|
|
56
|
+
/** The record every keyed global build writes last, so a key directory holding it is complete. */
|
|
57
|
+
const BUILD_RECORD = "build.json";
|
|
58
|
+
const BUILD_CHILD_SCRIPT = `
|
|
59
|
+
const [bundleUrl, request] = process.argv.slice(1);
|
|
60
|
+
try {
|
|
61
|
+
const { bundleCockpitWeb } = await import(bundleUrl);
|
|
62
|
+
const { hostRoot, pluginRoots, outDir } = JSON.parse(request);
|
|
63
|
+
const result = await bundleCockpitWeb({
|
|
64
|
+
hostRoot,
|
|
65
|
+
pluginRoots,
|
|
66
|
+
outDir,
|
|
67
|
+
onNotice: (message) => process.stderr.write(message + '\\n'),
|
|
68
|
+
});
|
|
69
|
+
process.stdout.write(JSON.stringify(result));
|
|
70
|
+
} catch (error) {
|
|
71
|
+
process.stderr.write(error instanceof Error ? (error.stack ?? error.message) : String(error));
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
/**
|
|
76
|
+
* The size+mtime signature of every file a plugin package hands the build: its manifest
|
|
77
|
+
* plus the whole top-level folder of the client entry and of each declared export, so an
|
|
78
|
+
* edited import or a rebuilt dist chunk changes the key, not only the entry file.
|
|
79
|
+
*/
|
|
80
|
+
function packageSignature(packageDir, entries) {
|
|
81
|
+
try {
|
|
82
|
+
const files = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const entry of entries) for (const file of require_packageUrl.snapshotFiles(packageDir, entry)) files.add(file);
|
|
84
|
+
return require_packageUrl.statSignature(packageDir, [...files].sort());
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return `unreadable:${error instanceof Error ? error.message : String(error)}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The content key of a build: the format, the host package when there is one, then every
|
|
91
|
+
* plugin package's file signature. A changed source or dist file or a changed plugin set
|
|
92
|
+
* yields a new key; roots that declare no plugin do not take part.
|
|
93
|
+
*/
|
|
94
|
+
function globalBuildKey(format, hostRoot, plugins) {
|
|
95
|
+
const hash = node_crypto.default.createHash("sha256").update(format);
|
|
96
|
+
if (hostRoot !== void 0) hash.update(`host:${hostRoot}:${node_fs.default.readFileSync(node_path.default.join(hostRoot, "package.json"), "utf8")}`);
|
|
97
|
+
const entries = /* @__PURE__ */ new Map();
|
|
98
|
+
for (const plugin of [...plugins].sort((a, b) => require_webPluginManifest.compareCodeUnits(a.pluginId, b.pluginId))) {
|
|
99
|
+
hash.update(`\0${plugin.pluginId}:${plugin.packageDir}:${plugin.client.entry}`);
|
|
100
|
+
const list = entries.get(plugin.packageDir) ?? [];
|
|
101
|
+
list.push(node_path.default.join(plugin.packageDir, plugin.client.entry));
|
|
102
|
+
entries.set(plugin.packageDir, list);
|
|
103
|
+
}
|
|
104
|
+
for (const packageDir of [...entries.keys()].sort()) hash.update(`\0${packageDir}\0${packageSignature(packageDir, entries.get(packageDir) ?? [])}`);
|
|
105
|
+
return hash.digest("hex").slice(0, 32);
|
|
106
|
+
}
|
|
107
|
+
function bundleModuleUrl() {
|
|
108
|
+
const extension = require("url").pathToFileURL(__filename).href.endsWith(".ts") ? "ts" : "mjs";
|
|
109
|
+
return new URL(`./bundle.${extension}`, require("url").pathToFileURL(__filename).href).href;
|
|
110
|
+
}
|
|
111
|
+
/** Runs Vite in a child process so its module graph and caches never stay in the server heap. */
|
|
112
|
+
function runBuildProcess(request, environment, onNotice) {
|
|
113
|
+
const args = [
|
|
114
|
+
...process.execArgv,
|
|
115
|
+
"--input-type=module",
|
|
116
|
+
"--eval",
|
|
117
|
+
BUILD_CHILD_SCRIPT,
|
|
118
|
+
bundleModuleUrl(),
|
|
119
|
+
JSON.stringify(request)
|
|
120
|
+
];
|
|
121
|
+
return new Promise((resolve, reject) => {
|
|
122
|
+
(0, node_child_process.execFile)(process.execPath, args, {
|
|
123
|
+
cwd: request.hostRoot,
|
|
124
|
+
env: environment,
|
|
125
|
+
encoding: "utf8",
|
|
126
|
+
maxBuffer: 67108864
|
|
127
|
+
}, (error, stdout, stderr) => {
|
|
128
|
+
if (error) {
|
|
129
|
+
reject(new Error(`${stderr || stdout}`.trim() || `Web build exited with code ${String(error.code ?? 1)}`));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
for (const line of stderr.split("\n")) if (line.trim()) onNotice(line.trim());
|
|
133
|
+
resolve(JSON.parse(stdout));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/** A key directory's parsed build record, or undefined when the build is not there (yet). */
|
|
138
|
+
function readBuildJson(directory) {
|
|
139
|
+
try {
|
|
140
|
+
return JSON.parse(node_fs.default.readFileSync(node_path.default.join(directory, BUILD_RECORD), "utf8"));
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (error.code === "ENOENT") return void 0;
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function readBuildRecord(directory) {
|
|
147
|
+
const record = readBuildJson(directory);
|
|
148
|
+
if (record === void 0) return void 0;
|
|
149
|
+
return {
|
|
150
|
+
...record,
|
|
151
|
+
webDirectory: node_path.default.join(directory, "web"),
|
|
152
|
+
pluginsDirectory: node_path.default.join(directory, "plugins")
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function webBuildsRoot(poHome) {
|
|
156
|
+
return node_path.default.join(poHome, "build", "web");
|
|
157
|
+
}
|
|
158
|
+
/** The complete global web build of one key, or undefined when it is not there. Never builds. */
|
|
159
|
+
function readGlobalWebBuildRecord(poHome, key) {
|
|
160
|
+
return readBuildRecord(node_path.default.join(webBuildsRoot(poHome), key));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The key of the most recently written complete global web build, for a server that starts
|
|
164
|
+
* before sync ever wrote a pointer. Temporary build folders start with a dot and are skipped.
|
|
165
|
+
*/
|
|
166
|
+
function newestGlobalWebBuildKey(poHome) {
|
|
167
|
+
const root = webBuildsRoot(poHome);
|
|
168
|
+
if (!node_fs.default.existsSync(root)) return void 0;
|
|
169
|
+
return node_fs.default.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => ({
|
|
170
|
+
name: entry.name,
|
|
171
|
+
file: node_path.default.join(root, entry.name, BUILD_RECORD)
|
|
172
|
+
})).filter((entry) => node_fs.default.existsSync(entry.file)).map((entry) => ({
|
|
173
|
+
name: entry.name,
|
|
174
|
+
modified: node_fs.default.statSync(entry.file).mtimeMs
|
|
175
|
+
})).sort((left, right) => right.modified - left.modified)[0]?.name;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Builds into a temporary sibling of `directory`, writes the build record last, and renames
|
|
179
|
+
* the result into place, so a key directory is always complete. Losing the rename to another
|
|
180
|
+
* process that finished the same key is fine: its bytes are identical.
|
|
181
|
+
*/
|
|
182
|
+
async function buildKeyDirectory(buildsRoot, key, directory, build) {
|
|
183
|
+
node_fs.default.mkdirSync(buildsRoot, { recursive: true });
|
|
184
|
+
const temporary = node_fs.default.mkdtempSync(node_path.default.join(buildsRoot, `.${key}-`));
|
|
185
|
+
try {
|
|
186
|
+
const record = await build(temporary);
|
|
187
|
+
node_fs.default.writeFileSync(node_path.default.join(temporary, BUILD_RECORD), `${JSON.stringify(record, null, 2)}\n`);
|
|
188
|
+
try {
|
|
189
|
+
node_fs.default.renameSync(temporary, directory);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
if (readBuildJson(directory) === void 0) throw error;
|
|
192
|
+
}
|
|
193
|
+
} finally {
|
|
194
|
+
node_fs.default.rmSync(temporary, {
|
|
195
|
+
recursive: true,
|
|
196
|
+
force: true
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const pendingBuilds = /* @__PURE__ */ new Map();
|
|
201
|
+
/** Joins a build of the same key that is already running in this process instead of starting another. */
|
|
202
|
+
async function singleFlightBuild(key, run) {
|
|
203
|
+
const pending = pendingBuilds.get(key);
|
|
204
|
+
if (pending !== void 0) return pending;
|
|
205
|
+
const started = run();
|
|
206
|
+
pendingBuilds.set(key, started);
|
|
207
|
+
try {
|
|
208
|
+
return await started;
|
|
209
|
+
} finally {
|
|
210
|
+
pendingBuilds.delete(key);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** The build key for these plugin roots and where its build lives, without building anything. */
|
|
214
|
+
function resolveGlobalWebBuild(input) {
|
|
215
|
+
const environment = input.environment ?? process.env;
|
|
216
|
+
const webRoot = (input.resolveWebRoot ?? resolveWebPackageRoot)(input.poHome, environment);
|
|
217
|
+
if (webRoot === void 0 || !node_fs.default.existsSync(node_path.default.join(webRoot, "package.json"))) return {
|
|
218
|
+
status: "skipped",
|
|
219
|
+
reason: `${WEB_PACKAGE} is not installed; no web composition is published`
|
|
220
|
+
};
|
|
221
|
+
const pluginRoots = [...new Set(input.pluginRoots.map((root) => node_path.default.resolve(root)))].sort();
|
|
222
|
+
let key;
|
|
223
|
+
try {
|
|
224
|
+
key = globalBuildKey(GLOBAL_BUILD_FORMAT, webRoot, require_webPluginScan.scanWebPlugins(webRoot, pluginRoots, input.onNotice ?? (() => {})));
|
|
225
|
+
} catch (error) {
|
|
226
|
+
return {
|
|
227
|
+
status: "failed",
|
|
228
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
const buildsRoot = node_path.default.join(input.poHome, "build", "web");
|
|
232
|
+
return {
|
|
233
|
+
status: "resolved",
|
|
234
|
+
webRoot,
|
|
235
|
+
pluginRoots,
|
|
236
|
+
key,
|
|
237
|
+
buildsRoot,
|
|
238
|
+
directory: node_path.default.join(buildsRoot, key)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/** Whether the global build for these plugin roots exists, for a check that must not build. */
|
|
242
|
+
function readGlobalWebBuildStatus(input) {
|
|
243
|
+
const resolved = resolveGlobalWebBuild(input);
|
|
244
|
+
if (resolved.status !== "resolved") return resolved;
|
|
245
|
+
return {
|
|
246
|
+
status: readBuildRecord(resolved.directory) === void 0 ? "missing" : "current",
|
|
247
|
+
key: resolved.key
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
async function ensureGlobalWebBuild(input) {
|
|
251
|
+
const environment = input.environment ?? process.env;
|
|
252
|
+
const notice = input.onNotice ?? (() => {});
|
|
253
|
+
const resolved = resolveGlobalWebBuild(input);
|
|
254
|
+
if (resolved.status !== "resolved") return resolved;
|
|
255
|
+
const { webRoot, pluginRoots, key, buildsRoot, directory } = resolved;
|
|
256
|
+
const existing = readBuildRecord(directory);
|
|
257
|
+
if (existing !== void 0) return {
|
|
258
|
+
status: "cached",
|
|
259
|
+
build: existing
|
|
260
|
+
};
|
|
261
|
+
return singleFlightBuild(key, async () => {
|
|
262
|
+
try {
|
|
263
|
+
await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {
|
|
264
|
+
const request = {
|
|
265
|
+
hostRoot: webRoot,
|
|
266
|
+
pluginRoots,
|
|
267
|
+
outDir: temporary
|
|
268
|
+
};
|
|
269
|
+
const output = await (input.runBuild ?? ((value) => runBuildProcess(value, environment, notice)))(request);
|
|
270
|
+
return {
|
|
271
|
+
key,
|
|
272
|
+
plugins: output.plugins,
|
|
273
|
+
pluginStyles: output.pluginStyles,
|
|
274
|
+
baseStyle: output.baseStyle
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
const build = readBuildRecord(directory);
|
|
278
|
+
if (build === void 0) throw new Error(`The web build '${key}' was not recorded.`);
|
|
279
|
+
return {
|
|
280
|
+
status: "built",
|
|
281
|
+
build
|
|
282
|
+
};
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return {
|
|
285
|
+
status: "failed",
|
|
286
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/** The plugin copies a mount runs, host plugins plus its own roots', at most one per pluginId (first wins). */
|
|
292
|
+
function mountPluginCopies(build, packageRoots) {
|
|
293
|
+
const roots = new Set(packageRoots.map((root) => node_path.default.resolve(root)));
|
|
294
|
+
const seen = /* @__PURE__ */ new Set();
|
|
295
|
+
return build.plugins.filter((plugin) => {
|
|
296
|
+
if (!plugin.isHost && !roots.has(node_path.default.resolve(plugin.packageDir))) return false;
|
|
297
|
+
if (seen.has(plugin.pluginId)) return false;
|
|
298
|
+
seen.add(plugin.pluginId);
|
|
299
|
+
return true;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/** The `pluginId` values a mount runs: the host's plugins plus those of its own package roots, deduplicated. */
|
|
303
|
+
function mountWebPluginIds(build, packageRoots) {
|
|
304
|
+
return mountPluginCopies(build, packageRoots).map((plugin) => plugin.pluginId);
|
|
305
|
+
}
|
|
306
|
+
/** The slots a mount runs: one copy per pluginId, the first in build order. */
|
|
307
|
+
function mountWebPluginSlots(build, packageRoots) {
|
|
308
|
+
return mountPluginCopies(build, packageRoots).map(require_webPluginManifest.pluginSlot);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The package roots among `packageRoots` that declare a web plugin the build has no slot for:
|
|
312
|
+
* a package that was not synced yet, or was left out of the build. Their names, else their roots.
|
|
313
|
+
*/
|
|
314
|
+
function unslottedWebPackages(build, packageRoots) {
|
|
315
|
+
const slotted = new Set(build.plugins.map((plugin) => node_path.default.resolve(plugin.packageDir)));
|
|
316
|
+
const missing = [];
|
|
317
|
+
for (const root of new Set(packageRoots.map((entry) => node_path.default.resolve(entry)))) {
|
|
318
|
+
if (slotted.has(root)) continue;
|
|
319
|
+
let manifest;
|
|
320
|
+
try {
|
|
321
|
+
manifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(root, "package.json"), "utf8"));
|
|
322
|
+
} catch {
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (manifest.poWeb === void 0) continue;
|
|
326
|
+
missing.push(typeof manifest.name === "string" ? manifest.name : root);
|
|
327
|
+
}
|
|
328
|
+
return missing;
|
|
329
|
+
}
|
|
330
|
+
/** The pluginIds with more than one installed copy among the host and these roots, each with its slots in build order. */
|
|
331
|
+
function duplicatePluginCopies(build, packageRoots) {
|
|
332
|
+
const roots = new Set(packageRoots.map((root) => node_path.default.resolve(root)));
|
|
333
|
+
const slotsById = /* @__PURE__ */ new Map();
|
|
334
|
+
for (const plugin of build.plugins) {
|
|
335
|
+
if (!plugin.isHost && !roots.has(node_path.default.resolve(plugin.packageDir))) continue;
|
|
336
|
+
const slot = require_webPluginManifest.pluginSlot(plugin);
|
|
337
|
+
const slots = slotsById.get(plugin.pluginId) ?? [];
|
|
338
|
+
if (!slots.includes(slot)) slots.push(slot);
|
|
339
|
+
slotsById.set(plugin.pluginId, slots);
|
|
340
|
+
}
|
|
341
|
+
return new Map([...slotsById].filter(([, slots]) => slots.length > 1));
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
exports.BUILD_RECORD = BUILD_RECORD;
|
|
345
|
+
exports.buildKeyDirectory = buildKeyDirectory;
|
|
346
|
+
exports.compositionPackageRoots = compositionPackageRoots;
|
|
347
|
+
exports.duplicatePluginCopies = duplicatePluginCopies;
|
|
348
|
+
exports.ensureGlobalWebBuild = ensureGlobalWebBuild;
|
|
349
|
+
exports.globalBuildKey = globalBuildKey;
|
|
350
|
+
exports.mountWebPluginIds = mountWebPluginIds;
|
|
351
|
+
exports.mountWebPluginSlots = mountWebPluginSlots;
|
|
352
|
+
exports.newestGlobalWebBuildKey = newestGlobalWebBuildKey;
|
|
353
|
+
exports.packageRootOf = packageRootOf;
|
|
354
|
+
exports.readBuildJson = readBuildJson;
|
|
355
|
+
exports.readGlobalWebBuildRecord = readGlobalWebBuildRecord;
|
|
356
|
+
exports.readGlobalWebBuildStatus = readGlobalWebBuildStatus;
|
|
357
|
+
exports.singleFlightBuild = singleFlightBuild;
|
|
358
|
+
exports.unslottedWebPackages = unslottedWebPackages;
|
|
359
|
+
exports.webHostVersion = webHostVersion;
|
|
360
|
+
|
|
361
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["path","fs","createRequire","snapshotFiles","statSignature","crypto","compareCodeUnits","scanWebPlugins","pluginSlot"],"sources":["../../../../src/builders/web/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { GlobalWebBuild, GlobalWebBuildPlugin } from '@agimon-ai/po-core/webCompositions';\n\nimport { snapshotFiles, statSignature } from '../server/packageUrl';\nimport { compareCodeUnits, type DeclaredWebPlugin, pluginSlot } from './webPluginManifest';\nimport { scanWebPlugins } from './webPluginScan';\n\nconst WEB_PACKAGE = '@agimon-ai/po-web';\nconst WEB_PACKAGE_ROOT_ENV = 'PO_WEB_PACKAGE_ROOT';\n\n/** The package roots a set of compositions activates, each once. */\nexport function compositionPackageRoots(compositions: readonly { packageEntries: readonly string[] }[]): string[] {\n return [\n ...new Set(\n compositions\n .flatMap((composition) => composition.packageEntries)\n .map(packageRootOf)\n .filter((root): root is string => root !== undefined),\n ),\n ];\n}\n\n/** Walks from a resolved module path up to the directory owning its package.json. */\nexport function packageRootOf(entryPath: string): string | undefined {\n let dir = path.dirname(entryPath);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'package.json'))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\nfunction resolveWebPackageRoot(repoRoot: string, environment: NodeJS.ProcessEnv): string | undefined {\n const override = environment[WEB_PACKAGE_ROOT_ENV];\n if (override !== undefined && override !== '') return path.resolve(override);\n try {\n return path.dirname(createRequire(path.join(repoRoot, 'package.json')).resolve(`${WEB_PACKAGE}/package.json`));\n } catch {\n try {\n return path.dirname(createRequire(import.meta.url).resolve(`${WEB_PACKAGE}/package.json`));\n } catch {\n return undefined;\n }\n }\n}\n\n/** The installed po-web host version the global web build would use, or `none` when it is not installed. */\nexport function webHostVersion(poHome: string, environment: NodeJS.ProcessEnv = process.env): string {\n const webRoot = resolveWebPackageRoot(poHome, environment);\n if (webRoot === undefined) return 'none';\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(webRoot, 'package.json'), 'utf8')) as { version?: unknown };\n return typeof manifest.version === 'string' ? manifest.version : 'unversioned';\n } catch (error) {\n return `unreadable:${error instanceof Error ? error.message : String(error)}`;\n }\n}\n\n/** Bumped whenever the build's output layout changes, so an old layout is never reused. */\nconst GLOBAL_BUILD_FORMAT = 'global-web-4';\n/** The record every keyed global build writes last, so a key directory holding it is complete. */\nexport const BUILD_RECORD = 'build.json';\nconst BUILD_CHILD_SCRIPT = `\nconst [bundleUrl, request] = process.argv.slice(1);\ntry {\n const { bundleCockpitWeb } = await import(bundleUrl);\n const { hostRoot, pluginRoots, outDir } = JSON.parse(request);\n const result = await bundleCockpitWeb({\n hostRoot,\n pluginRoots,\n outDir,\n onNotice: (message) => process.stderr.write(message + '\\\\n'),\n });\n process.stdout.write(JSON.stringify(result));\n} catch (error) {\n process.stderr.write(error instanceof Error ? (error.stack ?? error.message) : String(error));\n process.exitCode = 1;\n}\n`;\n\n/** One build's record: the publishable build, whose plugins carry each copy's package and slot closure. */\nexport type GlobalWebBuildRecord = GlobalWebBuild;\n\nexport interface GlobalWebBuildInput {\n /** Po's global home; builds land in `<home>/build/web/<key>/`. */\n poHome: string;\n /** The union of every scope's package roots; roots without a poWeb block are ignored. */\n pluginRoots: readonly string[];\n environment?: NodeJS.ProcessEnv;\n onNotice?: (message: string) => void;\n /** Test seam over the child-process build. */\n runBuild?: (request: { hostRoot: string; pluginRoots: string[]; outDir: string }) => Promise<BuildOutput>;\n /** Test seam over package resolution. */\n resolveWebRoot?: (repoRoot: string, environment: NodeJS.ProcessEnv) => string | undefined;\n}\n\ninterface BuildOutput {\n assetsDir: string;\n pluginsDir: string;\n plugins: GlobalWebBuildPlugin[];\n pluginStyles: Record<string, string>;\n baseStyle: string;\n}\n\nexport type GlobalWebBuildResult =\n | { status: 'built' | 'cached'; build: GlobalWebBuildRecord }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/**\n * The size+mtime signature of every file a plugin package hands the build: its manifest\n * plus the whole top-level folder of the client entry and of each declared export, so an\n * edited import or a rebuilt dist chunk changes the key, not only the entry file.\n */\nfunction packageSignature(packageDir: string, entries: readonly string[]): string {\n try {\n const files = new Set<string>();\n for (const entry of entries) for (const file of snapshotFiles(packageDir, entry)) files.add(file);\n return statSignature(packageDir, [...files].sort());\n } catch (error) {\n // A declared export that is not built yet must not block the build; it only weakens the key.\n return `unreadable:${error instanceof Error ? error.message : String(error)}`;\n }\n}\n\n/**\n * The content key of a build: the format, the host package when there is one, then every\n * plugin package's file signature. A changed source or dist file or a changed plugin set\n * yields a new key; roots that declare no plugin do not take part.\n */\nexport function globalBuildKey(\n format: string,\n hostRoot: string | undefined,\n plugins: readonly DeclaredWebPlugin[],\n): string {\n const hash = crypto.createHash('sha256').update(format);\n if (hostRoot !== undefined)\n hash.update(`host:${hostRoot}:${fs.readFileSync(path.join(hostRoot, 'package.json'), 'utf8')}`);\n const entries = new Map<string, string[]>();\n for (const plugin of [...plugins].sort((a, b) => compareCodeUnits(a.pluginId, b.pluginId))) {\n hash.update(`\\0${plugin.pluginId}:${plugin.packageDir}:${plugin.client.entry}`);\n const list = entries.get(plugin.packageDir) ?? [];\n list.push(path.join(plugin.packageDir, plugin.client.entry));\n entries.set(plugin.packageDir, list);\n }\n for (const packageDir of [...entries.keys()].sort())\n hash.update(`\\0${packageDir}\\0${packageSignature(packageDir, entries.get(packageDir) ?? [])}`);\n return hash.digest('hex').slice(0, 32);\n}\n\nfunction bundleModuleUrl(): string {\n const extension = import.meta.url.endsWith('.ts') ? 'ts' : 'mjs';\n return new URL(`./bundle.${extension}`, import.meta.url).href;\n}\n\n/** Runs Vite in a child process so its module graph and caches never stay in the server heap. */\nfunction runBuildProcess(\n request: { hostRoot: string; pluginRoots: string[]; outDir: string },\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): Promise<BuildOutput> {\n const args = [\n ...process.execArgv,\n '--input-type=module',\n '--eval',\n BUILD_CHILD_SCRIPT,\n bundleModuleUrl(),\n JSON.stringify(request),\n ];\n return new Promise((resolve, reject) => {\n execFile(\n process.execPath,\n args,\n { cwd: request.hostRoot, env: environment, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },\n (error, stdout, stderr) => {\n if (error) {\n reject(new Error(`${stderr || stdout}`.trim() || `Web build exited with code ${String(error.code ?? 1)}`));\n return;\n }\n for (const line of stderr.split('\\n')) if (line.trim()) onNotice(line.trim());\n resolve(JSON.parse(stdout) as BuildOutput);\n },\n );\n });\n}\n\n/** A key directory's parsed build record, or undefined when the build is not there (yet). */\nexport function readBuildJson<T>(directory: string): T | undefined {\n try {\n return JSON.parse(fs.readFileSync(path.join(directory, BUILD_RECORD), 'utf8')) as T;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nfunction readBuildRecord(directory: string): GlobalWebBuildRecord | undefined {\n const record = readBuildJson<Omit<GlobalWebBuildRecord, 'webDirectory' | 'pluginsDirectory'>>(directory);\n if (record === undefined) return undefined;\n return { ...record, webDirectory: path.join(directory, 'web'), pluginsDirectory: path.join(directory, 'plugins') };\n}\n\nfunction webBuildsRoot(poHome: string): string {\n return path.join(poHome, 'build', 'web');\n}\n\n/** The complete global web build of one key, or undefined when it is not there. Never builds. */\nexport function readGlobalWebBuildRecord(poHome: string, key: string): GlobalWebBuildRecord | undefined {\n return readBuildRecord(path.join(webBuildsRoot(poHome), key));\n}\n\n/**\n * The key of the most recently written complete global web build, for a server that starts\n * before sync ever wrote a pointer. Temporary build folders start with a dot and are skipped.\n */\nexport function newestGlobalWebBuildKey(poHome: string): string | undefined {\n const root = webBuildsRoot(poHome);\n if (!fs.existsSync(root)) return undefined;\n return fs\n .readdirSync(root, { withFileTypes: true })\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))\n .map((entry) => ({ name: entry.name, file: path.join(root, entry.name, BUILD_RECORD) }))\n .filter((entry) => fs.existsSync(entry.file))\n .map((entry) => ({ name: entry.name, modified: fs.statSync(entry.file).mtimeMs }))\n .sort((left, right) => right.modified - left.modified)[0]?.name;\n}\n\n/**\n * Builds into a temporary sibling of `directory`, writes the build record last, and renames\n * the result into place, so a key directory is always complete. Losing the rename to another\n * process that finished the same key is fine: its bytes are identical.\n */\nexport async function buildKeyDirectory(\n buildsRoot: string,\n key: string,\n directory: string,\n build: (temporary: string) => Promise<object>,\n): Promise<void> {\n fs.mkdirSync(buildsRoot, { recursive: true });\n const temporary = fs.mkdtempSync(path.join(buildsRoot, `.${key}-`));\n try {\n const record = await build(temporary);\n fs.writeFileSync(path.join(temporary, BUILD_RECORD), `${JSON.stringify(record, null, 2)}\\n`);\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n if (readBuildJson(directory) === undefined) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n}\n\nconst pendingBuilds = new Map<string, Promise<unknown>>();\n\n/** Joins a build of the same key that is already running in this process instead of starting another. */\nexport async function singleFlightBuild<T>(key: string, run: () => Promise<T>): Promise<T> {\n const pending = pendingBuilds.get(key);\n if (pending !== undefined) return pending as Promise<T>;\n const started = run();\n pendingBuilds.set(key, started);\n try {\n return await started;\n } finally {\n pendingBuilds.delete(key);\n }\n}\n\n/**\n * Ensures the one global web build for the given plugin roots exists and returns it.\n *\n * The output is `<home>/build/web/<key>/`, built in a temporary directory and renamed into\n * place, so a key directory is always complete; an existing key builds nothing. Each\n * non-host plugin gets its own content-hashed stylesheet, so a mount loads only its own.\n */\ntype ResolvedGlobalWebBuild =\n | { status: 'resolved'; webRoot: string; pluginRoots: string[]; key: string; buildsRoot: string; directory: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string };\n\n/** The build key for these plugin roots and where its build lives, without building anything. */\nfunction resolveGlobalWebBuild(input: GlobalWebBuildInput): ResolvedGlobalWebBuild {\n const environment = input.environment ?? process.env;\n const webRoot = (input.resolveWebRoot ?? resolveWebPackageRoot)(input.poHome, environment);\n if (webRoot === undefined || !fs.existsSync(path.join(webRoot, 'package.json')))\n return { status: 'skipped', reason: `${WEB_PACKAGE} is not installed; no web composition is published` };\n const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();\n let key: string;\n try {\n key = globalBuildKey(\n GLOBAL_BUILD_FORMAT,\n webRoot,\n scanWebPlugins(webRoot, pluginRoots, input.onNotice ?? ((): void => {})),\n );\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n const buildsRoot = path.join(input.poHome, 'build', 'web');\n return { status: 'resolved', webRoot, pluginRoots, key, buildsRoot, directory: path.join(buildsRoot, key) };\n}\n\n/** Whether the global build for these plugin roots exists, for a check that must not build. */\nexport function readGlobalWebBuildStatus(\n input: GlobalWebBuildInput,\n):\n | { status: 'current' | 'missing'; key: string }\n | { status: 'skipped'; reason: string }\n | { status: 'failed'; reason: string } {\n const resolved = resolveGlobalWebBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n return { status: readBuildRecord(resolved.directory) === undefined ? 'missing' : 'current', key: resolved.key };\n}\n\nexport async function ensureGlobalWebBuild(input: GlobalWebBuildInput): Promise<GlobalWebBuildResult> {\n const environment = input.environment ?? process.env;\n const notice = input.onNotice ?? ((): void => {});\n const resolved = resolveGlobalWebBuild(input);\n if (resolved.status !== 'resolved') return resolved;\n const { webRoot, pluginRoots, key, buildsRoot, directory } = resolved;\n const existing = readBuildRecord(directory);\n if (existing !== undefined) return { status: 'cached', build: existing };\n return singleFlightBuild(key, async (): Promise<GlobalWebBuildResult> => {\n try {\n await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {\n const request = { hostRoot: webRoot, pluginRoots, outDir: temporary };\n const output = await (input.runBuild ?? ((value) => runBuildProcess(value, environment, notice)))(request);\n return {\n key,\n plugins: output.plugins,\n pluginStyles: output.pluginStyles,\n baseStyle: output.baseStyle,\n };\n });\n const build = readBuildRecord(directory);\n if (build === undefined) throw new Error(`The web build '${key}' was not recorded.`);\n return { status: 'built', build };\n } catch (error) {\n return { status: 'failed', reason: error instanceof Error ? error.message : String(error) };\n }\n });\n}\n\ntype MountPluginRecord = { pluginId: string; packageDir: string; isHost: boolean };\n\n/** The plugin copies a mount runs, host plugins plus its own roots', at most one per pluginId (first wins). */\nfunction mountPluginCopies(\n build: { plugins: readonly MountPluginRecord[] },\n packageRoots: readonly string[],\n): MountPluginRecord[] {\n const roots = new Set(packageRoots.map((root) => path.resolve(root)));\n const seen = new Set<string>();\n return build.plugins.filter((plugin) => {\n if (!plugin.isHost && !roots.has(path.resolve(plugin.packageDir))) return false;\n if (seen.has(plugin.pluginId)) return false;\n seen.add(plugin.pluginId);\n return true;\n });\n}\n\n/** The `pluginId` values a mount runs: the host's plugins plus those of its own package roots, deduplicated. */\nexport function mountWebPluginIds(\n build: { plugins: readonly MountPluginRecord[] },\n packageRoots: readonly string[],\n): string[] {\n return mountPluginCopies(build, packageRoots).map((plugin) => plugin.pluginId);\n}\n\n/** The slots a mount runs: one copy per pluginId, the first in build order. */\nexport function mountWebPluginSlots(\n build: { plugins: readonly MountPluginRecord[] },\n packageRoots: readonly string[],\n): string[] {\n return mountPluginCopies(build, packageRoots).map(pluginSlot);\n}\n\n/**\n * The package roots among `packageRoots` that declare a web plugin the build has no slot for:\n * a package that was not synced yet, or was left out of the build. Their names, else their roots.\n */\nexport function unslottedWebPackages(\n build: { plugins: readonly MountPluginRecord[] },\n packageRoots: readonly string[],\n): string[] {\n const slotted = new Set(build.plugins.map((plugin) => path.resolve(plugin.packageDir)));\n const missing: string[] = [];\n for (const root of new Set(packageRoots.map((entry) => path.resolve(entry)))) {\n if (slotted.has(root)) continue;\n let manifest: { name?: unknown; poWeb?: unknown };\n try {\n manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')) as typeof manifest;\n } catch {\n // Unreadable manifests are reported by the build's own scan, not as a missing slot.\n continue;\n }\n if (manifest.poWeb === undefined) continue;\n missing.push(typeof manifest.name === 'string' ? manifest.name : root);\n }\n return missing;\n}\n\n/** The pluginIds with more than one installed copy among the host and these roots, each with its slots in build order. */\nexport function duplicatePluginCopies(\n build: { plugins: readonly MountPluginRecord[] },\n packageRoots: readonly string[],\n): Map<string, string[]> {\n const roots = new Set(packageRoots.map((root) => path.resolve(root)));\n const slotsById = new Map<string, string[]>();\n for (const plugin of build.plugins) {\n if (!plugin.isHost && !roots.has(path.resolve(plugin.packageDir))) continue;\n const slot = pluginSlot(plugin);\n const slots = slotsById.get(plugin.pluginId) ?? [];\n if (!slots.includes(slot)) slots.push(slot);\n slotsById.set(plugin.pluginId, slots);\n }\n return new Map([...slotsById].filter(([, slots]) => slots.length > 1));\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,cAAc;AACpB,MAAM,uBAAuB;;AAG7B,SA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OAAO,SAAS,SAAS,WAAW,SAAS,OAAO,IAAI;CACvE;CACA,OAAO;AACT;;AAGA,SAAgB,sBACd,OACA,cACuB;CACvB,MAAM,QAAQ,IAAI,IAAI,aAAa,KAAK,SAASA,UAAAA,QAAK,QAAQ,IAAI,CAAC,CAAC;CACpE,MAAM,4BAAY,IAAI,IAAsB;CAC5C,KAAK,MAAM,UAAU,MAAM,SAAS;EAClC,IAAI,CAAC,OAAO,UAAU,CAAC,MAAM,IAAIA,UAAAA,QAAK,QAAQ,OAAO,UAAU,CAAC,GAAG;EACnE,MAAM,OAAOQ,0BAAAA,WAAW,MAAM;EAC9B,MAAM,QAAQ,UAAU,IAAI,OAAO,QAAQ,KAAK,CAAC;EACjD,IAAI,CAAC,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI;EAC1C,UAAU,IAAI,OAAO,UAAU,KAAK;CACtC;CACA,OAAO,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,QAAQ,GAAG,WAAW,MAAM,SAAS,CAAC,CAAC;AACvE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { DeclaredWebPlugin } from "./webPluginManifest.mjs";
|
|
2
|
+
import { GlobalWebBuild, GlobalWebBuildPlugin } from "@agimon-ai/po-core/webCompositions";
|
|
3
|
+
//#region src/builders/web/index.d.ts
|
|
4
|
+
/** The package roots a set of compositions activates, each once. */
|
|
5
|
+
export declare function compositionPackageRoots(compositions: readonly {
|
|
6
|
+
packageEntries: readonly string[];
|
|
7
|
+
}[]): string[];
|
|
8
|
+
/** Walks from a resolved module path up to the directory owning its package.json. */
|
|
9
|
+
export declare function packageRootOf(entryPath: string): string | undefined;
|
|
10
|
+
/** The installed po-web host version the global web build would use, or `none` when it is not installed. */
|
|
11
|
+
export declare function webHostVersion(poHome: string, environment?: NodeJS.ProcessEnv): string;
|
|
12
|
+
/** The record every keyed global build writes last, so a key directory holding it is complete. */
|
|
13
|
+
export declare const BUILD_RECORD = "build.json";
|
|
14
|
+
/** One build's record: the publishable build, whose plugins carry each copy's package and slot closure. */
|
|
15
|
+
export type GlobalWebBuildRecord = GlobalWebBuild;
|
|
16
|
+
export interface GlobalWebBuildInput {
|
|
17
|
+
/** Po's global home; builds land in `<home>/build/web/<key>/`. */
|
|
18
|
+
poHome: string;
|
|
19
|
+
/** The union of every scope's package roots; roots without a poWeb block are ignored. */
|
|
20
|
+
pluginRoots: readonly string[];
|
|
21
|
+
environment?: NodeJS.ProcessEnv;
|
|
22
|
+
onNotice?: (message: string) => void;
|
|
23
|
+
/** Test seam over the child-process build. */
|
|
24
|
+
runBuild?: (request: {
|
|
25
|
+
hostRoot: string;
|
|
26
|
+
pluginRoots: string[];
|
|
27
|
+
outDir: string;
|
|
28
|
+
}) => Promise<BuildOutput>;
|
|
29
|
+
/** Test seam over package resolution. */
|
|
30
|
+
resolveWebRoot?: (repoRoot: string, environment: NodeJS.ProcessEnv) => string | undefined;
|
|
31
|
+
}
|
|
32
|
+
interface BuildOutput {
|
|
33
|
+
assetsDir: string;
|
|
34
|
+
pluginsDir: string;
|
|
35
|
+
plugins: GlobalWebBuildPlugin[];
|
|
36
|
+
pluginStyles: Record<string, string>;
|
|
37
|
+
baseStyle: string;
|
|
38
|
+
}
|
|
39
|
+
export type GlobalWebBuildResult = {
|
|
40
|
+
status: 'built' | 'cached';
|
|
41
|
+
build: GlobalWebBuildRecord;
|
|
42
|
+
} | {
|
|
43
|
+
status: 'skipped';
|
|
44
|
+
reason: string;
|
|
45
|
+
} | {
|
|
46
|
+
status: 'failed';
|
|
47
|
+
reason: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The content key of a build: the format, the host package when there is one, then every
|
|
51
|
+
* plugin package's file signature. A changed source or dist file or a changed plugin set
|
|
52
|
+
* yields a new key; roots that declare no plugin do not take part.
|
|
53
|
+
*/
|
|
54
|
+
export declare function globalBuildKey(format: string, hostRoot: string | undefined, plugins: readonly DeclaredWebPlugin[]): string;
|
|
55
|
+
/** A key directory's parsed build record, or undefined when the build is not there (yet). */
|
|
56
|
+
export declare function readBuildJson<T>(directory: string): T | undefined;
|
|
57
|
+
/** The complete global web build of one key, or undefined when it is not there. Never builds. */
|
|
58
|
+
export declare function readGlobalWebBuildRecord(poHome: string, key: string): GlobalWebBuildRecord | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* The key of the most recently written complete global web build, for a server that starts
|
|
61
|
+
* before sync ever wrote a pointer. Temporary build folders start with a dot and are skipped.
|
|
62
|
+
*/
|
|
63
|
+
export declare function newestGlobalWebBuildKey(poHome: string): string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Builds into a temporary sibling of `directory`, writes the build record last, and renames
|
|
66
|
+
* the result into place, so a key directory is always complete. Losing the rename to another
|
|
67
|
+
* process that finished the same key is fine: its bytes are identical.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildKeyDirectory(buildsRoot: string, key: string, directory: string, build: (temporary: string) => Promise<object>): Promise<void>;
|
|
70
|
+
/** Joins a build of the same key that is already running in this process instead of starting another. */
|
|
71
|
+
export declare function singleFlightBuild<T>(key: string, run: () => Promise<T>): Promise<T>;
|
|
72
|
+
/** Whether the global build for these plugin roots exists, for a check that must not build. */
|
|
73
|
+
export declare function readGlobalWebBuildStatus(input: GlobalWebBuildInput): {
|
|
74
|
+
status: 'current' | 'missing';
|
|
75
|
+
key: string;
|
|
76
|
+
} | {
|
|
77
|
+
status: 'skipped';
|
|
78
|
+
reason: string;
|
|
79
|
+
} | {
|
|
80
|
+
status: 'failed';
|
|
81
|
+
reason: string;
|
|
82
|
+
};
|
|
83
|
+
export declare function ensureGlobalWebBuild(input: GlobalWebBuildInput): Promise<GlobalWebBuildResult>;
|
|
84
|
+
type MountPluginRecord = {
|
|
85
|
+
pluginId: string;
|
|
86
|
+
packageDir: string;
|
|
87
|
+
isHost: boolean;
|
|
88
|
+
};
|
|
89
|
+
/** The `pluginId` values a mount runs: the host's plugins plus those of its own package roots, deduplicated. */
|
|
90
|
+
export declare function mountWebPluginIds(build: {
|
|
91
|
+
plugins: readonly MountPluginRecord[];
|
|
92
|
+
}, packageRoots: readonly string[]): string[];
|
|
93
|
+
/** The slots a mount runs: one copy per pluginId, the first in build order. */
|
|
94
|
+
export declare function mountWebPluginSlots(build: {
|
|
95
|
+
plugins: readonly MountPluginRecord[];
|
|
96
|
+
}, packageRoots: readonly string[]): string[];
|
|
97
|
+
/**
|
|
98
|
+
* The package roots among `packageRoots` that declare a web plugin the build has no slot for:
|
|
99
|
+
* a package that was not synced yet, or was left out of the build. Their names, else their roots.
|
|
100
|
+
*/
|
|
101
|
+
export declare function unslottedWebPackages(build: {
|
|
102
|
+
plugins: readonly MountPluginRecord[];
|
|
103
|
+
}, packageRoots: readonly string[]): string[];
|
|
104
|
+
/** The pluginIds with more than one installed copy among the host and these roots, each with its slots in build order. */
|
|
105
|
+
export declare function duplicatePluginCopies(build: {
|
|
106
|
+
plugins: readonly MountPluginRecord[];
|
|
107
|
+
}, packageRoots: readonly string[]): Map<string, string[]>;
|
|
108
|
+
//#endregion
|
|
109
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/builders/web/index.ts"],"mappings":";;;;wBAgBgB,wBAAwB;EAAyB;;;wBAYjD,cAAc;;wBAyBd,eAAe,gBAAgB,cAAa,OAAO;;qBActD;;YAoBD,uBAAuB;iBAElB;;EAEf;;EAEA;EACA,cAAc,OAAO;EACrB,YAAY;;EAEZ,YAAY;IAAW;IAAkB;IAAuB;QAAqB,QAAQ;;EAE7F,kBAAkB,kBAAkB,aAAa,OAAO;;UAGhD;EACR;EACA;EACA,SAAS;EACT,cAAc;EACd;;YAGU;EACN;EAA4B,OAAO;;EACnC;EAAmB;;EACnB;EAAkB;;;;;;;wBAuBR,eACd,gBACA,8BACA,kBAAkB;;wBAsDJ,cAAc,GAAG,oBAAoB;;wBAoBrC,yBAAyB,gBAAgB,cAAc;;;;;wBAQvD,wBAAwB;;;;;;wBAiBlB,kBACpB,oBACA,aACA,mBACA,QAAQ,sBAAsB,kBAC7B;;wBAmBmB,kBAAkB,GAAG,aAAa,WAAW,QAAQ,KAAK,QAAQ;;wBA8CxE,yBACd,OAAO;EAEH;EAA+B;;EAC/B;EAAmB;;EACnB;EAAkB;;wBAMF,qBAAqB,OAAO,sBAAsB,QAAQ;KA6B3E;EAAsB;EAAkB;EAAoB;;;wBAkBjD,kBACd;EAAS,kBAAkB;GAC3B;;wBAMc,oBACd;EAAS,kBAAkB;GAC3B;;;;;wBASc,qBACd;EAAS,kBAAkB;GAC3B;;wBAoBc,sBACd;EAAS,kBAAkB;GAC3B,kCACC"}
|