@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,342 @@
|
|
|
1
|
+
import { snapshotFiles, statSignature } from "../server/packageUrl.mjs";
|
|
2
|
+
import { compareCodeUnits, pluginSlot } from "./webPluginManifest.mjs";
|
|
3
|
+
import { scanWebPlugins } from "./webPluginScan.mjs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { execFile } from "node:child_process";
|
|
8
|
+
import crypto from "node:crypto";
|
|
9
|
+
//#region src/builders/web/index.ts
|
|
10
|
+
const WEB_PACKAGE = "@agimon-ai/po-web";
|
|
11
|
+
const WEB_PACKAGE_ROOT_ENV = "PO_WEB_PACKAGE_ROOT";
|
|
12
|
+
/** The package roots a set of compositions activates, each once. */
|
|
13
|
+
function compositionPackageRoots(compositions) {
|
|
14
|
+
return [...new Set(compositions.flatMap((composition) => composition.packageEntries).map(packageRootOf).filter((root) => root !== void 0))];
|
|
15
|
+
}
|
|
16
|
+
/** Walks from a resolved module path up to the directory owning its package.json. */
|
|
17
|
+
function packageRootOf(entryPath) {
|
|
18
|
+
let dir = path.dirname(entryPath);
|
|
19
|
+
for (;;) {
|
|
20
|
+
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
21
|
+
const parent = path.dirname(dir);
|
|
22
|
+
if (parent === dir) return void 0;
|
|
23
|
+
dir = parent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function resolveWebPackageRoot(repoRoot, environment) {
|
|
27
|
+
const override = environment[WEB_PACKAGE_ROOT_ENV];
|
|
28
|
+
if (override !== void 0 && override !== "") return path.resolve(override);
|
|
29
|
+
try {
|
|
30
|
+
return path.dirname(createRequire(path.join(repoRoot, "package.json")).resolve(`${WEB_PACKAGE}/package.json`));
|
|
31
|
+
} catch {
|
|
32
|
+
try {
|
|
33
|
+
return path.dirname(createRequire(import.meta.url).resolve(`${WEB_PACKAGE}/package.json`));
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** The installed po-web host version the global web build would use, or `none` when it is not installed. */
|
|
40
|
+
function webHostVersion(poHome, environment = process.env) {
|
|
41
|
+
const webRoot = resolveWebPackageRoot(poHome, environment);
|
|
42
|
+
if (webRoot === void 0) return "none";
|
|
43
|
+
try {
|
|
44
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(webRoot, "package.json"), "utf8"));
|
|
45
|
+
return typeof manifest.version === "string" ? manifest.version : "unversioned";
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return `unreadable:${error instanceof Error ? error.message : String(error)}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Bumped whenever the build's output layout changes, so an old layout is never reused. */
|
|
51
|
+
const GLOBAL_BUILD_FORMAT = "global-web-4";
|
|
52
|
+
/** The record every keyed global build writes last, so a key directory holding it is complete. */
|
|
53
|
+
const BUILD_RECORD = "build.json";
|
|
54
|
+
const BUILD_CHILD_SCRIPT = `
|
|
55
|
+
const [bundleUrl, request] = process.argv.slice(1);
|
|
56
|
+
try {
|
|
57
|
+
const { bundleCockpitWeb } = await import(bundleUrl);
|
|
58
|
+
const { hostRoot, pluginRoots, outDir } = JSON.parse(request);
|
|
59
|
+
const result = await bundleCockpitWeb({
|
|
60
|
+
hostRoot,
|
|
61
|
+
pluginRoots,
|
|
62
|
+
outDir,
|
|
63
|
+
onNotice: (message) => process.stderr.write(message + '\\n'),
|
|
64
|
+
});
|
|
65
|
+
process.stdout.write(JSON.stringify(result));
|
|
66
|
+
} catch (error) {
|
|
67
|
+
process.stderr.write(error instanceof Error ? (error.stack ?? error.message) : String(error));
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
/**
|
|
72
|
+
* The size+mtime signature of every file a plugin package hands the build: its manifest
|
|
73
|
+
* plus the whole top-level folder of the client entry and of each declared export, so an
|
|
74
|
+
* edited import or a rebuilt dist chunk changes the key, not only the entry file.
|
|
75
|
+
*/
|
|
76
|
+
function packageSignature(packageDir, entries) {
|
|
77
|
+
try {
|
|
78
|
+
const files = /* @__PURE__ */ new Set();
|
|
79
|
+
for (const entry of entries) for (const file of snapshotFiles(packageDir, entry)) files.add(file);
|
|
80
|
+
return statSignature(packageDir, [...files].sort());
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return `unreadable:${error instanceof Error ? error.message : String(error)}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The content key of a build: the format, the host package when there is one, then every
|
|
87
|
+
* plugin package's file signature. A changed source or dist file or a changed plugin set
|
|
88
|
+
* yields a new key; roots that declare no plugin do not take part.
|
|
89
|
+
*/
|
|
90
|
+
function globalBuildKey(format, hostRoot, plugins) {
|
|
91
|
+
const hash = crypto.createHash("sha256").update(format);
|
|
92
|
+
if (hostRoot !== void 0) hash.update(`host:${hostRoot}:${fs.readFileSync(path.join(hostRoot, "package.json"), "utf8")}`);
|
|
93
|
+
const entries = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const plugin of [...plugins].sort((a, b) => compareCodeUnits(a.pluginId, b.pluginId))) {
|
|
95
|
+
hash.update(`\0${plugin.pluginId}:${plugin.packageDir}:${plugin.client.entry}`);
|
|
96
|
+
const list = entries.get(plugin.packageDir) ?? [];
|
|
97
|
+
list.push(path.join(plugin.packageDir, plugin.client.entry));
|
|
98
|
+
entries.set(plugin.packageDir, list);
|
|
99
|
+
}
|
|
100
|
+
for (const packageDir of [...entries.keys()].sort()) hash.update(`\0${packageDir}\0${packageSignature(packageDir, entries.get(packageDir) ?? [])}`);
|
|
101
|
+
return hash.digest("hex").slice(0, 32);
|
|
102
|
+
}
|
|
103
|
+
function bundleModuleUrl() {
|
|
104
|
+
const extension = import.meta.url.endsWith(".ts") ? "ts" : "mjs";
|
|
105
|
+
return new URL(`./bundle.${extension}`, import.meta.url).href;
|
|
106
|
+
}
|
|
107
|
+
/** Runs Vite in a child process so its module graph and caches never stay in the server heap. */
|
|
108
|
+
function runBuildProcess(request, environment, onNotice) {
|
|
109
|
+
const args = [
|
|
110
|
+
...process.execArgv,
|
|
111
|
+
"--input-type=module",
|
|
112
|
+
"--eval",
|
|
113
|
+
BUILD_CHILD_SCRIPT,
|
|
114
|
+
bundleModuleUrl(),
|
|
115
|
+
JSON.stringify(request)
|
|
116
|
+
];
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
execFile(process.execPath, args, {
|
|
119
|
+
cwd: request.hostRoot,
|
|
120
|
+
env: environment,
|
|
121
|
+
encoding: "utf8",
|
|
122
|
+
maxBuffer: 67108864
|
|
123
|
+
}, (error, stdout, stderr) => {
|
|
124
|
+
if (error) {
|
|
125
|
+
reject(new Error(`${stderr || stdout}`.trim() || `Web build exited with code ${String(error.code ?? 1)}`));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const line of stderr.split("\n")) if (line.trim()) onNotice(line.trim());
|
|
129
|
+
resolve(JSON.parse(stdout));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** A key directory's parsed build record, or undefined when the build is not there (yet). */
|
|
134
|
+
function readBuildJson(directory) {
|
|
135
|
+
try {
|
|
136
|
+
return JSON.parse(fs.readFileSync(path.join(directory, BUILD_RECORD), "utf8"));
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error.code === "ENOENT") return void 0;
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function readBuildRecord(directory) {
|
|
143
|
+
const record = readBuildJson(directory);
|
|
144
|
+
if (record === void 0) return void 0;
|
|
145
|
+
return {
|
|
146
|
+
...record,
|
|
147
|
+
webDirectory: path.join(directory, "web"),
|
|
148
|
+
pluginsDirectory: path.join(directory, "plugins")
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function webBuildsRoot(poHome) {
|
|
152
|
+
return path.join(poHome, "build", "web");
|
|
153
|
+
}
|
|
154
|
+
/** The complete global web build of one key, or undefined when it is not there. Never builds. */
|
|
155
|
+
function readGlobalWebBuildRecord(poHome, key) {
|
|
156
|
+
return readBuildRecord(path.join(webBuildsRoot(poHome), key));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The key of the most recently written complete global web build, for a server that starts
|
|
160
|
+
* before sync ever wrote a pointer. Temporary build folders start with a dot and are skipped.
|
|
161
|
+
*/
|
|
162
|
+
function newestGlobalWebBuildKey(poHome) {
|
|
163
|
+
const root = webBuildsRoot(poHome);
|
|
164
|
+
if (!fs.existsSync(root)) return void 0;
|
|
165
|
+
return fs.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => ({
|
|
166
|
+
name: entry.name,
|
|
167
|
+
file: path.join(root, entry.name, BUILD_RECORD)
|
|
168
|
+
})).filter((entry) => fs.existsSync(entry.file)).map((entry) => ({
|
|
169
|
+
name: entry.name,
|
|
170
|
+
modified: fs.statSync(entry.file).mtimeMs
|
|
171
|
+
})).sort((left, right) => right.modified - left.modified)[0]?.name;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Builds into a temporary sibling of `directory`, writes the build record last, and renames
|
|
175
|
+
* the result into place, so a key directory is always complete. Losing the rename to another
|
|
176
|
+
* process that finished the same key is fine: its bytes are identical.
|
|
177
|
+
*/
|
|
178
|
+
async function buildKeyDirectory(buildsRoot, key, directory, build) {
|
|
179
|
+
fs.mkdirSync(buildsRoot, { recursive: true });
|
|
180
|
+
const temporary = fs.mkdtempSync(path.join(buildsRoot, `.${key}-`));
|
|
181
|
+
try {
|
|
182
|
+
const record = await build(temporary);
|
|
183
|
+
fs.writeFileSync(path.join(temporary, BUILD_RECORD), `${JSON.stringify(record, null, 2)}\n`);
|
|
184
|
+
try {
|
|
185
|
+
fs.renameSync(temporary, directory);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (readBuildJson(directory) === void 0) throw error;
|
|
188
|
+
}
|
|
189
|
+
} finally {
|
|
190
|
+
fs.rmSync(temporary, {
|
|
191
|
+
recursive: true,
|
|
192
|
+
force: true
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const pendingBuilds = /* @__PURE__ */ new Map();
|
|
197
|
+
/** Joins a build of the same key that is already running in this process instead of starting another. */
|
|
198
|
+
async function singleFlightBuild(key, run) {
|
|
199
|
+
const pending = pendingBuilds.get(key);
|
|
200
|
+
if (pending !== void 0) return pending;
|
|
201
|
+
const started = run();
|
|
202
|
+
pendingBuilds.set(key, started);
|
|
203
|
+
try {
|
|
204
|
+
return await started;
|
|
205
|
+
} finally {
|
|
206
|
+
pendingBuilds.delete(key);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** The build key for these plugin roots and where its build lives, without building anything. */
|
|
210
|
+
function resolveGlobalWebBuild(input) {
|
|
211
|
+
const environment = input.environment ?? process.env;
|
|
212
|
+
const webRoot = (input.resolveWebRoot ?? resolveWebPackageRoot)(input.poHome, environment);
|
|
213
|
+
if (webRoot === void 0 || !fs.existsSync(path.join(webRoot, "package.json"))) return {
|
|
214
|
+
status: "skipped",
|
|
215
|
+
reason: `${WEB_PACKAGE} is not installed; no web composition is published`
|
|
216
|
+
};
|
|
217
|
+
const pluginRoots = [...new Set(input.pluginRoots.map((root) => path.resolve(root)))].sort();
|
|
218
|
+
let key;
|
|
219
|
+
try {
|
|
220
|
+
key = globalBuildKey(GLOBAL_BUILD_FORMAT, webRoot, scanWebPlugins(webRoot, pluginRoots, input.onNotice ?? (() => {})));
|
|
221
|
+
} catch (error) {
|
|
222
|
+
return {
|
|
223
|
+
status: "failed",
|
|
224
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const buildsRoot = path.join(input.poHome, "build", "web");
|
|
228
|
+
return {
|
|
229
|
+
status: "resolved",
|
|
230
|
+
webRoot,
|
|
231
|
+
pluginRoots,
|
|
232
|
+
key,
|
|
233
|
+
buildsRoot,
|
|
234
|
+
directory: path.join(buildsRoot, key)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Whether the global build for these plugin roots exists, for a check that must not build. */
|
|
238
|
+
function readGlobalWebBuildStatus(input) {
|
|
239
|
+
const resolved = resolveGlobalWebBuild(input);
|
|
240
|
+
if (resolved.status !== "resolved") return resolved;
|
|
241
|
+
return {
|
|
242
|
+
status: readBuildRecord(resolved.directory) === void 0 ? "missing" : "current",
|
|
243
|
+
key: resolved.key
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
async function ensureGlobalWebBuild(input) {
|
|
247
|
+
const environment = input.environment ?? process.env;
|
|
248
|
+
const notice = input.onNotice ?? (() => {});
|
|
249
|
+
const resolved = resolveGlobalWebBuild(input);
|
|
250
|
+
if (resolved.status !== "resolved") return resolved;
|
|
251
|
+
const { webRoot, pluginRoots, key, buildsRoot, directory } = resolved;
|
|
252
|
+
const existing = readBuildRecord(directory);
|
|
253
|
+
if (existing !== void 0) return {
|
|
254
|
+
status: "cached",
|
|
255
|
+
build: existing
|
|
256
|
+
};
|
|
257
|
+
return singleFlightBuild(key, async () => {
|
|
258
|
+
try {
|
|
259
|
+
await buildKeyDirectory(buildsRoot, key, directory, async (temporary) => {
|
|
260
|
+
const request = {
|
|
261
|
+
hostRoot: webRoot,
|
|
262
|
+
pluginRoots,
|
|
263
|
+
outDir: temporary
|
|
264
|
+
};
|
|
265
|
+
const output = await (input.runBuild ?? ((value) => runBuildProcess(value, environment, notice)))(request);
|
|
266
|
+
return {
|
|
267
|
+
key,
|
|
268
|
+
plugins: output.plugins,
|
|
269
|
+
pluginStyles: output.pluginStyles,
|
|
270
|
+
baseStyle: output.baseStyle
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
const build = readBuildRecord(directory);
|
|
274
|
+
if (build === void 0) throw new Error(`The web build '${key}' was not recorded.`);
|
|
275
|
+
return {
|
|
276
|
+
status: "built",
|
|
277
|
+
build
|
|
278
|
+
};
|
|
279
|
+
} catch (error) {
|
|
280
|
+
return {
|
|
281
|
+
status: "failed",
|
|
282
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/** The plugin copies a mount runs, host plugins plus its own roots', at most one per pluginId (first wins). */
|
|
288
|
+
function mountPluginCopies(build, packageRoots) {
|
|
289
|
+
const roots = new Set(packageRoots.map((root) => path.resolve(root)));
|
|
290
|
+
const seen = /* @__PURE__ */ new Set();
|
|
291
|
+
return build.plugins.filter((plugin) => {
|
|
292
|
+
if (!plugin.isHost && !roots.has(path.resolve(plugin.packageDir))) return false;
|
|
293
|
+
if (seen.has(plugin.pluginId)) return false;
|
|
294
|
+
seen.add(plugin.pluginId);
|
|
295
|
+
return true;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/** The `pluginId` values a mount runs: the host's plugins plus those of its own package roots, deduplicated. */
|
|
299
|
+
function mountWebPluginIds(build, packageRoots) {
|
|
300
|
+
return mountPluginCopies(build, packageRoots).map((plugin) => plugin.pluginId);
|
|
301
|
+
}
|
|
302
|
+
/** The slots a mount runs: one copy per pluginId, the first in build order. */
|
|
303
|
+
function mountWebPluginSlots(build, packageRoots) {
|
|
304
|
+
return mountPluginCopies(build, packageRoots).map(pluginSlot);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The package roots among `packageRoots` that declare a web plugin the build has no slot for:
|
|
308
|
+
* a package that was not synced yet, or was left out of the build. Their names, else their roots.
|
|
309
|
+
*/
|
|
310
|
+
function unslottedWebPackages(build, packageRoots) {
|
|
311
|
+
const slotted = new Set(build.plugins.map((plugin) => path.resolve(plugin.packageDir)));
|
|
312
|
+
const missing = [];
|
|
313
|
+
for (const root of new Set(packageRoots.map((entry) => path.resolve(entry)))) {
|
|
314
|
+
if (slotted.has(root)) continue;
|
|
315
|
+
let manifest;
|
|
316
|
+
try {
|
|
317
|
+
manifest = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
318
|
+
} catch {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (manifest.poWeb === void 0) continue;
|
|
322
|
+
missing.push(typeof manifest.name === "string" ? manifest.name : root);
|
|
323
|
+
}
|
|
324
|
+
return missing;
|
|
325
|
+
}
|
|
326
|
+
/** The pluginIds with more than one installed copy among the host and these roots, each with its slots in build order. */
|
|
327
|
+
function duplicatePluginCopies(build, packageRoots) {
|
|
328
|
+
const roots = new Set(packageRoots.map((root) => path.resolve(root)));
|
|
329
|
+
const slotsById = /* @__PURE__ */ new Map();
|
|
330
|
+
for (const plugin of build.plugins) {
|
|
331
|
+
if (!plugin.isHost && !roots.has(path.resolve(plugin.packageDir))) continue;
|
|
332
|
+
const slot = pluginSlot(plugin);
|
|
333
|
+
const slots = slotsById.get(plugin.pluginId) ?? [];
|
|
334
|
+
if (!slots.includes(slot)) slots.push(slot);
|
|
335
|
+
slotsById.set(plugin.pluginId, slots);
|
|
336
|
+
}
|
|
337
|
+
return new Map([...slotsById].filter(([, slots]) => slots.length > 1));
|
|
338
|
+
}
|
|
339
|
+
//#endregion
|
|
340
|
+
export { BUILD_RECORD, buildKeyDirectory, compositionPackageRoots, duplicatePluginCopies, ensureGlobalWebBuild, globalBuildKey, mountWebPluginIds, mountWebPluginSlots, newestGlobalWebBuildKey, packageRootOf, readBuildJson, readGlobalWebBuildRecord, readGlobalWebBuildStatus, singleFlightBuild, unslottedWebPackages, webHostVersion };
|
|
341
|
+
|
|
342
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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,SAAgB,wBAAwB,cAA0E;CAChH,OAAO,CACL,GAAG,IAAI,IACL,aACG,SAAS,gBAAgB,YAAY,cAAc,CAAC,CACpD,IAAI,aAAa,CAAC,CAClB,QAAQ,SAAyB,SAAS,KAAA,CAAS,CACxD,CACF;AACF;;AAGA,SAAgB,cAAc,WAAuC;CACnE,IAAI,MAAM,KAAK,QAAQ,SAAS;CAChC,SAAS;EACP,IAAI,GAAG,WAAW,KAAK,KAAK,KAAK,cAAc,CAAC,GAAG,OAAO;EAC1D,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,OAAO,KAAA;EAC3B,MAAM;CACR;AACF;AAEA,SAAS,sBAAsB,UAAkB,aAAoD;CACnG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IAAI,OAAO,KAAK,QAAQ,QAAQ;CAC3E,IAAI;EACF,OAAO,KAAK,QAAQ,cAAc,KAAK,KAAK,UAAU,cAAc,CAAC,CAAC,CAAC,QAAQ,GAAG,YAAY,cAAc,CAAC;CAC/G,QAAQ;EACN,IAAI;GACF,OAAO,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,CAAC,QAAQ,GAAG,YAAY,cAAc,CAAC;EAC3F,QAAQ;GACN;EACF;CACF;AACF;;AAGA,SAAgB,eAAe,QAAgB,cAAiC,QAAQ,KAAa;CACnG,MAAM,UAAU,sBAAsB,QAAQ,WAAW;CACzD,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,IAAI;EACF,MAAM,WAAW,KAAK,MAAM,GAAG,aAAa,KAAK,KAAK,SAAS,cAAc,GAAG,MAAM,CAAC;EACvF,OAAO,OAAO,SAA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,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,27 @@
|
|
|
1
|
+
//#region src/builders/web/webDevRoots.ts
|
|
2
|
+
/**
|
|
3
|
+
* Where the cockpit's dev server finds the plugin packages to serve with hot
|
|
4
|
+
* reload. Pure: the adapter hands in the environment value and the roots file
|
|
5
|
+
* the last `po sync` wrote next to its bundle; this only decides.
|
|
6
|
+
*/
|
|
7
|
+
/** A delimiter-separated list of plugin package roots; wins over the synced roots file. */
|
|
8
|
+
const PLUGIN_ROOTS_ENV = "PO_WEB_PLUGIN_ROOTS";
|
|
9
|
+
/** The file `po sync` writes beside its bundle, listing the package roots it bundled. */
|
|
10
|
+
const PLUGIN_ROOTS_FILE = "pluginRoots.json";
|
|
11
|
+
/** The plugin roots the dev server should serve: the environment list, else the synced list, else none. */
|
|
12
|
+
function devPluginRoots({ envValue, rootsFileText, delimiter }) {
|
|
13
|
+
if (envValue !== void 0 && envValue.trim() !== "") return envValue.split(delimiter).map((root) => root.trim()).filter((root) => root !== "");
|
|
14
|
+
if (rootsFileText === void 0) return [];
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(rootsFileText);
|
|
17
|
+
return Array.isArray(parsed) ? parsed.filter((root) => typeof root === "string") : [];
|
|
18
|
+
} catch {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.PLUGIN_ROOTS_ENV = PLUGIN_ROOTS_ENV;
|
|
24
|
+
exports.PLUGIN_ROOTS_FILE = PLUGIN_ROOTS_FILE;
|
|
25
|
+
exports.devPluginRoots = devPluginRoots;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=webDevRoots.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webDevRoots.cjs","names":[],"sources":["../../../../src/builders/web/webDevRoots.ts"],"sourcesContent":["/**\n * Where the cockpit's dev server finds the plugin packages to serve with hot\n * reload. Pure: the adapter hands in the environment value and the roots file\n * the last `po sync` wrote next to its bundle; this only decides.\n */\n\n/** A delimiter-separated list of plugin package roots; wins over the synced roots file. */\nexport const PLUGIN_ROOTS_ENV = 'PO_WEB_PLUGIN_ROOTS';\n/** The file `po sync` writes beside its bundle, listing the package roots it bundled. */\nexport const PLUGIN_ROOTS_FILE = 'pluginRoots.json';\n\nexport interface DevPluginRootsInput {\n /** The raw environment value, undefined when unset. */\n envValue: string | undefined;\n /** The roots file's text, undefined when no synced bundle exists. */\n rootsFileText: string | undefined;\n /** The platform's path list delimiter (':' on POSIX, ';' on Windows). */\n delimiter: string;\n}\n\n/** The plugin roots the dev server should serve: the environment list, else the synced list, else none. */\nexport function devPluginRoots({ envValue, rootsFileText, delimiter }: DevPluginRootsInput): string[] {\n if (envValue !== undefined && envValue.trim() !== '') {\n return envValue\n .split(delimiter)\n .map((root) => root.trim())\n .filter((root) => root !== '');\n }\n if (rootsFileText === undefined) return [];\n try {\n const parsed: unknown = JSON.parse(rootsFileText);\n return Array.isArray(parsed) ? parsed.filter((root): root is string => typeof root === 'string') : [];\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB;;AAEhC,MAAa,oBAAoB;;AAYjC,SAAgB,eAAe,EAAE,UAAU,eAAe,aAA4C;CACpG,IAAI,aAAa,KAAA,KAAa,SAAS,KAAK,MAAM,IAChD,OAAO,SACJ,MAAM,SAAS,CAAC,CAChB,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE;CAEjC,IAAI,kBAAkB,KAAA,GAAW,OAAO,CAAC;CACzC,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,aAAa;EAChD,OAAO,MAAM,QAAQ,MAAM,IAAI,OAAO,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAC;CACtG,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/builders/web/webDevRoots.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Where the cockpit's dev server finds the plugin packages to serve with hot
|
|
4
|
+
* reload. Pure: the adapter hands in the environment value and the roots file
|
|
5
|
+
* the last `po sync` wrote next to its bundle; this only decides.
|
|
6
|
+
*/
|
|
7
|
+
/** A delimiter-separated list of plugin package roots; wins over the synced roots file. */
|
|
8
|
+
export declare const PLUGIN_ROOTS_ENV = "PO_WEB_PLUGIN_ROOTS";
|
|
9
|
+
/** The file `po sync` writes beside its bundle, listing the package roots it bundled. */
|
|
10
|
+
export declare const PLUGIN_ROOTS_FILE = "pluginRoots.json";
|
|
11
|
+
export interface DevPluginRootsInput {
|
|
12
|
+
/** The raw environment value, undefined when unset. */
|
|
13
|
+
envValue: string | undefined;
|
|
14
|
+
/** The roots file's text, undefined when no synced bundle exists. */
|
|
15
|
+
rootsFileText: string | undefined;
|
|
16
|
+
/** The platform's path list delimiter (':' on POSIX, ';' on Windows). */
|
|
17
|
+
delimiter: string;
|
|
18
|
+
}
|
|
19
|
+
/** The plugin roots the dev server should serve: the environment list, else the synced list, else none. */
|
|
20
|
+
export declare function devPluginRoots({ envValue, rootsFileText, delimiter }: DevPluginRootsInput): string[];
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=webDevRoots.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webDevRoots.d.mts","names":[],"sources":["../../../../src/builders/web/webDevRoots.ts"],"mappings":";;;;;;;qBAOa;;qBAEA;iBAEI;;EAEf;;EAEA;;EAEA;;;wBAIc,iBAAiB,UAAU,eAAe,aAAa"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/builders/web/webDevRoots.ts
|
|
2
|
+
/**
|
|
3
|
+
* Where the cockpit's dev server finds the plugin packages to serve with hot
|
|
4
|
+
* reload. Pure: the adapter hands in the environment value and the roots file
|
|
5
|
+
* the last `po sync` wrote next to its bundle; this only decides.
|
|
6
|
+
*/
|
|
7
|
+
/** A delimiter-separated list of plugin package roots; wins over the synced roots file. */
|
|
8
|
+
const PLUGIN_ROOTS_ENV = "PO_WEB_PLUGIN_ROOTS";
|
|
9
|
+
/** The file `po sync` writes beside its bundle, listing the package roots it bundled. */
|
|
10
|
+
const PLUGIN_ROOTS_FILE = "pluginRoots.json";
|
|
11
|
+
/** The plugin roots the dev server should serve: the environment list, else the synced list, else none. */
|
|
12
|
+
function devPluginRoots({ envValue, rootsFileText, delimiter }) {
|
|
13
|
+
if (envValue !== void 0 && envValue.trim() !== "") return envValue.split(delimiter).map((root) => root.trim()).filter((root) => root !== "");
|
|
14
|
+
if (rootsFileText === void 0) return [];
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(rootsFileText);
|
|
17
|
+
return Array.isArray(parsed) ? parsed.filter((root) => typeof root === "string") : [];
|
|
18
|
+
} catch {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { PLUGIN_ROOTS_ENV, PLUGIN_ROOTS_FILE, devPluginRoots };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=webDevRoots.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webDevRoots.mjs","names":[],"sources":["../../../../src/builders/web/webDevRoots.ts"],"sourcesContent":["/**\n * Where the cockpit's dev server finds the plugin packages to serve with hot\n * reload. Pure: the adapter hands in the environment value and the roots file\n * the last `po sync` wrote next to its bundle; this only decides.\n */\n\n/** A delimiter-separated list of plugin package roots; wins over the synced roots file. */\nexport const PLUGIN_ROOTS_ENV = 'PO_WEB_PLUGIN_ROOTS';\n/** The file `po sync` writes beside its bundle, listing the package roots it bundled. */\nexport const PLUGIN_ROOTS_FILE = 'pluginRoots.json';\n\nexport interface DevPluginRootsInput {\n /** The raw environment value, undefined when unset. */\n envValue: string | undefined;\n /** The roots file's text, undefined when no synced bundle exists. */\n rootsFileText: string | undefined;\n /** The platform's path list delimiter (':' on POSIX, ';' on Windows). */\n delimiter: string;\n}\n\n/** The plugin roots the dev server should serve: the environment list, else the synced list, else none. */\nexport function devPluginRoots({ envValue, rootsFileText, delimiter }: DevPluginRootsInput): string[] {\n if (envValue !== undefined && envValue.trim() !== '') {\n return envValue\n .split(delimiter)\n .map((root) => root.trim())\n .filter((root) => root !== '');\n }\n if (rootsFileText === undefined) return [];\n try {\n const parsed: unknown = JSON.parse(rootsFileText);\n return Array.isArray(parsed) ? parsed.filter((root): root is string => typeof root === 'string') : [];\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB;;AAEhC,MAAa,oBAAoB;;AAYjC,SAAgB,eAAe,EAAE,UAAU,eAAe,aAA4C;CACpG,IAAI,aAAa,KAAA,KAAa,SAAS,KAAK,MAAM,IAChD,OAAO,SACJ,MAAM,SAAS,CAAC,CAChB,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE;CAEjC,IAAI,kBAAkB,KAAA,GAAW,OAAO,CAAC;CACzC,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,aAAa;EAChD,OAAO,MAAM,QAAQ,MAAM,IAAI,OAAO,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAC;CACtG,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
|