@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 @@
|
|
|
1
|
+
{"version":3,"file":"webPluginVite.cjs","names":["fs","path","createRequire","PLUGIN_ROOTS_ENV","devPluginRoots","compositionPackageRoots","rootCompositions"],"sources":["../../../../src/builders/web/webPluginVite.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { Alias, Plugin } from 'vite';\n\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { compositionPackageRoots } from './index';\nimport { devPluginRoots, PLUGIN_ROOTS_ENV } from './webDevRoots';\nimport type { WebPluginRegistryModules } from './webPluginGenerate';\n\nconst PO_ROOT_ENV = 'PO_ROOT';\n\n/**\n * The modules the cockpit supplies page-wide, rather than each plugin\n * carrying its own copy.\n *\n * Build-time metadata, and it stays here rather than in a browser-facing\n * barrel on purpose: exporting it from po-core/web put the literal list\n * into the shipped cockpit bundle, where a plugin's own specifier strings\n * would then appear as data.\n */\nexport const WEB_PLUGIN_RUNTIME_SPECIFIERS = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-dashboard/views',\n '@agimon-ai/po-core/web',\n '@agimon-ai/po-web-components',\n '@agimon-ai/po-web-security/browser',\n '@codemirror/state',\n '@codemirror/view',\n] as const;\n\nconst WEB_PLUGIN_RUNTIME_PROPERTIES: Record<(typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number], string> = {\n react: 'react',\n 'react/jsx-runtime': 'reactJsxRuntime',\n 'react/jsx-dev-runtime': 'reactJsxDevRuntime',\n 'react-dom': 'reactDom',\n 'react-dom/client': 'reactDomClient',\n '@tanstack/store': 'tanstackStore',\n '@tanstack/react-store': 'tanstackReactStore',\n '@tanstack/react-router': 'tanstackRouter',\n '@agimon-ai/po-web-dashboard': 'dashboard',\n '@agimon-ai/po-web-dashboard/views': 'dashboardViews',\n '@agimon-ai/po-core/web': 'webContracts',\n '@agimon-ai/po-web-components': 'webComponents',\n '@agimon-ai/po-web-security/browser': 'webSecurityBrowser',\n '@codemirror/state': 'codemirrorState',\n '@codemirror/view': 'codemirrorView',\n};\n\ntype WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];\n\n/** Expression for a shared module supplied by the session shell. */\nexport function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string {\n return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;\n}\n\n/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */\nconst COMMONJS_RUNTIME_SPECIFIERS: ReadonlySet<string> = new Set([\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n]);\n\nconst FACADE_PREFIX = '\\0po-web-runtime:';\n/** The chunk every facade lands in, so each shared module is read from the runtime once. */\nexport const WEB_PLUGIN_FACADE_CHUNK = 'po-web-runtime';\n\n/** True for a module id that is one of the shared-module facades. */\nexport function isWebPluginFacade(id: string): boolean {\n return id.startsWith(FACADE_PREFIX);\n}\n\n/** The ES module name of a default export. */\nconst DEFAULT_EXPORT = 'default';\n\ntype AstNode = { type: string; [key: string]: unknown };\n\nfunction patternNames(pattern: AstNode): string[] {\n switch (pattern.type) {\n case 'Identifier':\n return [pattern.name as string];\n case 'ObjectPattern':\n return (pattern.properties as AstNode[]).flatMap((property) =>\n patternNames((property.type === 'RestElement' ? property.argument : property.value) as AstNode),\n );\n case 'ArrayPattern':\n return (pattern.elements as (AstNode | null)[]).flatMap((element) => (element ? patternNames(element) : []));\n case 'RestElement':\n return patternNames(pattern.argument as AstNode);\n case 'AssignmentPattern':\n return patternNames(pattern.left as AstNode);\n default:\n return [];\n }\n}\n\nfunction exportedName(node: AstNode): string {\n return node.type === 'Identifier' ? (node.name as string) : String(node.value);\n}\n\n/** Static reading of an ES module's export names, as the facade plugin needs it. */\nexport interface ExportNameReader {\n parse: (code: string) => { body: unknown[] };\n /** Resolves a bare specifier from the file that imports it, to a file path. */\n resolve: (source: string, importer: string) => Promise<string | undefined>;\n}\n\n/**\n * The export names of an ES module file. `export *` is followed through relative paths,\n * and through a bare specifier only when that specifier is itself a shared module\n * (resolved from the re-exporting file, since that is the copy the runtime object holds).\n * Any other bare `export *` and any unparseable file fail the build.\n */\nexport async function esModuleExportNames(\n specifier: string,\n file: string,\n reader: ExportNameReader,\n seen: Set<string> = new Set(),\n): Promise<Set<string>> {\n const names = new Set<string>();\n if (seen.has(file)) return names;\n seen.add(file);\n let body: AstNode[];\n try {\n body = reader.parse(fs.readFileSync(file, 'utf8')).body as AstNode[];\n } catch (error) {\n throw new Error(\n `The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n for (const node of body) {\n if (node.type === 'ExportDefaultDeclaration') names.add(DEFAULT_EXPORT);\n if (node.type === 'ExportNamedDeclaration') {\n const declaration = node.declaration as AstNode | null;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations as AstNode[])\n for (const name of patternNames(declarator.id as AstNode)) names.add(name);\n } else if (declaration) {\n names.add((declaration.id as AstNode).name as string);\n }\n for (const entry of (node.specifiers as AstNode[] | undefined) ?? [])\n names.add(exportedName(entry.exported as AstNode));\n }\n if (node.type === 'ExportAllDeclaration') {\n if (node.exported) {\n names.add(exportedName(node.exported as AstNode));\n continue;\n }\n const source = String((node.source as AstNode).value);\n let target: string | undefined;\n if (source.startsWith('./') || source.startsWith('../')) target = path.resolve(path.dirname(file), source);\n else if (shared.has(source)) {\n target = await reader.resolve(source, file);\n if (target === undefined)\n throw new Error(\n `The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`,\n );\n } else\n throw new Error(\n `The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`,\n );\n for (const name of await esModuleExportNames(specifier, target, reader, seen))\n if (name !== DEFAULT_EXPORT) names.add(name);\n }\n }\n return names;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/u;\n\n/** A module that reads one shared module from the page runtime and re-exports the given names. */\nexport function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string {\n const all = new Set(names);\n const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];\n const exported: string[] = [];\n let index = 0;\n for (const name of [...all].sort()) {\n if (name === DEFAULT_EXPORT) continue;\n const local = `_${String(index++)}`;\n lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);\n exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);\n }\n if (exported.length > 0) lines.push(`export { ${exported.join(', ')} };`);\n // CommonJS has no default export of its own; interop treats the whole object as one.\n if (all.has(DEFAULT_EXPORT)) lines.push('export default runtime[\"default\"];');\n else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push('export default runtime;');\n lines.push('');\n return lines.join('\\n');\n}\n\n/**\n * Resolves every shared runtime specifier to a virtual facade that re-exports, by name,\n * from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without\n * the page providing an import map. Names come from the host's own copy of each module.\n */\nexport function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin {\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n const hostImporter = path.join(hostRoot, 'package.json');\n const hostRequire = createRequire(hostImporter);\n return {\n name: 'po-web-runtime-facades',\n enforce: 'pre',\n resolveId(source) {\n return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;\n },\n async load(id) {\n if (!isWebPluginFacade(id)) return null;\n const specifier = id.slice(FACADE_PREFIX.length) as WebPluginRuntimeSpecifier;\n if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier))\n return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier) as object));\n const resolveFile = async (source: string, importer: string): Promise<string | undefined> => {\n const resolved = await this.resolve(source, importer, { skipSelf: true });\n return resolved ? (resolved.id.split('?')[0] ?? resolved.id) : undefined;\n };\n const file = await resolveFile(specifier, hostImporter);\n if (file === undefined) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);\n const { parseAst } = await import('vite');\n return renderWebPluginFacade(\n specifier,\n await esModuleExportNames(specifier, file, { parse: (code) => parseAst(code), resolve: resolveFile }),\n );\n },\n };\n}\n\n/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */\nexport function webPluginRuntimeAliases(clientRoot: string): Alias[] {\n const runtimeRequire = createRequire(path.join(clientRoot, 'index.html'));\n return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith('react/jsx-')).map((specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: runtimeRequire.resolve(specifier),\n }));\n}\n\n/**\n * Swaps the committed builtin registry modules for generated ones. A\n * resolveId hook rather than resolve.alias because aliases match raw import\n * specifiers while these two are known by their resolved paths. Both the\n * sync-time build and the dev server use it, so a plugin edit in dev is the\n * same module the bundle would carry.\n */\nexport function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin {\n const overrides = new Map([\n [path.join(clientRoot, 'app', 'webPlugins.generated.ts'), generated.clientModulePath],\n [path.join(clientRoot, 'styles', 'webPluginSources.generated.css'), generated.cssModulePath],\n ]);\n return {\n name: 'po-web-plugin-overrides',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!source.includes('webPlugins.generated') && !source.includes('webPluginSources.generated.css')) return null;\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n if (!resolved) return null;\n return overrides.get(resolved.id) ?? null;\n },\n };\n}\n\n/**\n * The CSS sources module cannot ride the resolveId hook: Vite and Tailwind\n * resolve CSS @import through Vite's own id resolver, which consults aliases\n * but no plugin hooks. Without this the builtin (empty) @source list ships\n * and every plugin-only utility class is missing.\n */\nexport function webPluginCssAlias(generated: WebPluginRegistryModules): Alias {\n return { find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: generated.cssModulePath };\n}\n\n/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */\nexport function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): string[] {\n const explicit = environment[PLUGIN_ROOTS_ENV];\n if (explicit !== undefined && explicit !== '') {\n return devPluginRoots({ envValue: explicit, rootsFileText: undefined, delimiter: path.delimiter });\n }\n const repoRoot = environment[PO_ROOT_ENV];\n if (repoRoot === undefined || repoRoot === '') return [];\n // Resolved live from the root's configuration and installed packages, as the server does.\n return compositionPackageRoots(rootCompositions({ root: repoRoot, homeDirectory, environment }));\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,cAAc;;;;;;;;;;AAWpB,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gCAAgG;CACpG,OAAO;CACP,qBAAqB;CACrB,yBAAyB;CACzB,aAAa;CACb,oBAAoB;CACpB,mBAAmB;CACnB,yBAAyB;CACzB,0BAA0B;CAC1B,+BAA+B;CAC/B,qCAAqC;CACrC,0BAA0B;CAC1B,gCAAgC;CAChC,sCAAsC;CACtC,qBAAqB;CACrB,oBAAoB;AACtB;;AAKA,SAAgB,uBAAuB,WAA8C;CACnF,OAAO,iCAAiC,8BAA8B;AACxE;;AAGA,MAAM,8CAAmD,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,gBAAgB;;AAEtB,MAAa,0BAA0B;;AAGvC,SAAgB,kBAAkB,IAAqB;CACrD,OAAO,GAAG,WAAW,aAAa;AACpC;;AAGA,MAAM,iBAAiB;AAIvB,SAAS,aAAa,SAA4B;CAChD,QAAQ,QAAQ,MAAhB;EACE,KAAK,cACH,OAAO,CAAC,QAAQ,IAAc;EAChC,KAAK,iBACH,OAAQ,QAAQ,WAAyB,SA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,MAAM;EAAU;EAAe;CAAY,CAAC,CAAC;AACjG"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { WebPluginRegistryModules } from "./webPluginGenerate.mjs";
|
|
2
|
+
import { Alias, Plugin } from "vite";
|
|
3
|
+
//#region src/builders/web/webPluginVite.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The modules the cockpit supplies page-wide, rather than each plugin
|
|
6
|
+
* carrying its own copy.
|
|
7
|
+
*
|
|
8
|
+
* Build-time metadata, and it stays here rather than in a browser-facing
|
|
9
|
+
* barrel on purpose: exporting it from po-core/web put the literal list
|
|
10
|
+
* into the shipped cockpit bundle, where a plugin's own specifier strings
|
|
11
|
+
* would then appear as data.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WEB_PLUGIN_RUNTIME_SPECIFIERS: readonly ['react', 'react/jsx-runtime', 'react/jsx-dev-runtime', 'react-dom', 'react-dom/client', '@tanstack/store', '@tanstack/react-store', '@tanstack/react-router', '@agimon-ai/po-web-dashboard', '@agimon-ai/po-web-dashboard/views', '@agimon-ai/po-core/web', '@agimon-ai/po-web-components', '@agimon-ai/po-web-security/browser', '@codemirror/state', '@codemirror/view'];
|
|
14
|
+
type WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];
|
|
15
|
+
/** Expression for a shared module supplied by the session shell. */
|
|
16
|
+
export declare function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string;
|
|
17
|
+
/** The chunk every facade lands in, so each shared module is read from the runtime once. */
|
|
18
|
+
export declare const WEB_PLUGIN_FACADE_CHUNK = "po-web-runtime";
|
|
19
|
+
/** True for a module id that is one of the shared-module facades. */
|
|
20
|
+
export declare function isWebPluginFacade(id: string): boolean;
|
|
21
|
+
/** Static reading of an ES module's export names, as the facade plugin needs it. */
|
|
22
|
+
export interface ExportNameReader {
|
|
23
|
+
parse: (code: string) => {
|
|
24
|
+
body: unknown[];
|
|
25
|
+
};
|
|
26
|
+
/** Resolves a bare specifier from the file that imports it, to a file path. */
|
|
27
|
+
resolve: (source: string, importer: string) => Promise<string | undefined>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The export names of an ES module file. `export *` is followed through relative paths,
|
|
31
|
+
* and through a bare specifier only when that specifier is itself a shared module
|
|
32
|
+
* (resolved from the re-exporting file, since that is the copy the runtime object holds).
|
|
33
|
+
* Any other bare `export *` and any unparseable file fail the build.
|
|
34
|
+
*/
|
|
35
|
+
export declare function esModuleExportNames(specifier: string, file: string, reader: ExportNameReader, seen?: Set<string>): Promise<Set<string>>;
|
|
36
|
+
/** A module that reads one shared module from the page runtime and re-exports the given names. */
|
|
37
|
+
export declare function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves every shared runtime specifier to a virtual facade that re-exports, by name,
|
|
40
|
+
* from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without
|
|
41
|
+
* the page providing an import map. Names come from the host's own copy of each module.
|
|
42
|
+
*/
|
|
43
|
+
export declare function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin;
|
|
44
|
+
/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */
|
|
45
|
+
export declare function webPluginRuntimeAliases(clientRoot: string): Alias[];
|
|
46
|
+
/**
|
|
47
|
+
* Swaps the committed builtin registry modules for generated ones. A
|
|
48
|
+
* resolveId hook rather than resolve.alias because aliases match raw import
|
|
49
|
+
* specifiers while these two are known by their resolved paths. Both the
|
|
50
|
+
* sync-time build and the dev server use it, so a plugin edit in dev is the
|
|
51
|
+
* same module the bundle would carry.
|
|
52
|
+
*/
|
|
53
|
+
export declare function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin;
|
|
54
|
+
/**
|
|
55
|
+
* The CSS sources module cannot ride the resolveId hook: Vite and Tailwind
|
|
56
|
+
* resolve CSS @import through Vite's own id resolver, which consults aliases
|
|
57
|
+
* but no plugin hooks. Without this the builtin (empty) @source list ships
|
|
58
|
+
* and every plugin-only utility class is missing.
|
|
59
|
+
*/
|
|
60
|
+
export declare function webPluginCssAlias(generated: WebPluginRegistryModules): Alias;
|
|
61
|
+
/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */
|
|
62
|
+
export declare function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): string[];
|
|
63
|
+
//#endregion
|
|
64
|
+
//# sourceMappingURL=webPluginVite.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webPluginVite.d.mts","names":[],"sources":["../../../../src/builders/web/webPluginVite.ts"],"mappings":";;;;;;;;;;;;qBAsBa;KAoCR,oCAAoC;;wBAGzB,uBAAuB,WAAW;;qBAerC;;wBAGG,kBAAkB;;iBAiCjB;EACf,QAAQ;IAAmB;;;EAE3B,UAAU,gBAAgB,qBAAqB;;;;;;;;wBAS3B,oBACpB,mBACA,cACA,QAAQ,kBACR,OAAM,cACL,QAAQ;;wBAsDK,sBAAsB,WAAW,2BAA2B,OAAO;;;;;;wBAwBnE,6BAA6B,mBAAmB;;wBA+BhD,wBAAwB,qBAAqB;;;;;;;;wBAe7C,wBAAwB,oBAAoB,WAAW,2BAA2B;;;;;;;wBAuBlF,kBAAkB,WAAW,2BAA2B;;wBAKxD,mBAAmB,aAAa,OAAO,YAAY"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { compositionPackageRoots } from "./index.mjs";
|
|
2
|
+
import { rootCompositions } from "../cli/sessionComposition.mjs";
|
|
3
|
+
import { PLUGIN_ROOTS_ENV, devPluginRoots } from "./webDevRoots.mjs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
//#region src/builders/web/webPluginVite.ts
|
|
8
|
+
const PO_ROOT_ENV = "PO_ROOT";
|
|
9
|
+
/**
|
|
10
|
+
* The modules the cockpit supplies page-wide, rather than each plugin
|
|
11
|
+
* carrying its own copy.
|
|
12
|
+
*
|
|
13
|
+
* Build-time metadata, and it stays here rather than in a browser-facing
|
|
14
|
+
* barrel on purpose: exporting it from po-core/web put the literal list
|
|
15
|
+
* into the shipped cockpit bundle, where a plugin's own specifier strings
|
|
16
|
+
* would then appear as data.
|
|
17
|
+
*/
|
|
18
|
+
const WEB_PLUGIN_RUNTIME_SPECIFIERS = [
|
|
19
|
+
"react",
|
|
20
|
+
"react/jsx-runtime",
|
|
21
|
+
"react/jsx-dev-runtime",
|
|
22
|
+
"react-dom",
|
|
23
|
+
"react-dom/client",
|
|
24
|
+
"@tanstack/store",
|
|
25
|
+
"@tanstack/react-store",
|
|
26
|
+
"@tanstack/react-router",
|
|
27
|
+
"@agimon-ai/po-web-dashboard",
|
|
28
|
+
"@agimon-ai/po-web-dashboard/views",
|
|
29
|
+
"@agimon-ai/po-core/web",
|
|
30
|
+
"@agimon-ai/po-web-components",
|
|
31
|
+
"@agimon-ai/po-web-security/browser",
|
|
32
|
+
"@codemirror/state",
|
|
33
|
+
"@codemirror/view"
|
|
34
|
+
];
|
|
35
|
+
const WEB_PLUGIN_RUNTIME_PROPERTIES = {
|
|
36
|
+
react: "react",
|
|
37
|
+
"react/jsx-runtime": "reactJsxRuntime",
|
|
38
|
+
"react/jsx-dev-runtime": "reactJsxDevRuntime",
|
|
39
|
+
"react-dom": "reactDom",
|
|
40
|
+
"react-dom/client": "reactDomClient",
|
|
41
|
+
"@tanstack/store": "tanstackStore",
|
|
42
|
+
"@tanstack/react-store": "tanstackReactStore",
|
|
43
|
+
"@tanstack/react-router": "tanstackRouter",
|
|
44
|
+
"@agimon-ai/po-web-dashboard": "dashboard",
|
|
45
|
+
"@agimon-ai/po-web-dashboard/views": "dashboardViews",
|
|
46
|
+
"@agimon-ai/po-core/web": "webContracts",
|
|
47
|
+
"@agimon-ai/po-web-components": "webComponents",
|
|
48
|
+
"@agimon-ai/po-web-security/browser": "webSecurityBrowser",
|
|
49
|
+
"@codemirror/state": "codemirrorState",
|
|
50
|
+
"@codemirror/view": "codemirrorView"
|
|
51
|
+
};
|
|
52
|
+
/** Expression for a shared module supplied by the session shell. */
|
|
53
|
+
function webPluginRuntimeGlobal(specifier) {
|
|
54
|
+
return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;
|
|
55
|
+
}
|
|
56
|
+
/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */
|
|
57
|
+
const COMMONJS_RUNTIME_SPECIFIERS = /* @__PURE__ */ new Set([
|
|
58
|
+
"react",
|
|
59
|
+
"react/jsx-runtime",
|
|
60
|
+
"react/jsx-dev-runtime",
|
|
61
|
+
"react-dom",
|
|
62
|
+
"react-dom/client"
|
|
63
|
+
]);
|
|
64
|
+
const FACADE_PREFIX = "\0po-web-runtime:";
|
|
65
|
+
/** The chunk every facade lands in, so each shared module is read from the runtime once. */
|
|
66
|
+
const WEB_PLUGIN_FACADE_CHUNK = "po-web-runtime";
|
|
67
|
+
/** True for a module id that is one of the shared-module facades. */
|
|
68
|
+
function isWebPluginFacade(id) {
|
|
69
|
+
return id.startsWith(FACADE_PREFIX);
|
|
70
|
+
}
|
|
71
|
+
/** The ES module name of a default export. */
|
|
72
|
+
const DEFAULT_EXPORT = "default";
|
|
73
|
+
function patternNames(pattern) {
|
|
74
|
+
switch (pattern.type) {
|
|
75
|
+
case "Identifier": return [pattern.name];
|
|
76
|
+
case "ObjectPattern": return pattern.properties.flatMap((property) => patternNames(property.type === "RestElement" ? property.argument : property.value));
|
|
77
|
+
case "ArrayPattern": return pattern.elements.flatMap((element) => element ? patternNames(element) : []);
|
|
78
|
+
case "RestElement": return patternNames(pattern.argument);
|
|
79
|
+
case "AssignmentPattern": return patternNames(pattern.left);
|
|
80
|
+
default: return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function exportedName(node) {
|
|
84
|
+
return node.type === "Identifier" ? node.name : String(node.value);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The export names of an ES module file. `export *` is followed through relative paths,
|
|
88
|
+
* and through a bare specifier only when that specifier is itself a shared module
|
|
89
|
+
* (resolved from the re-exporting file, since that is the copy the runtime object holds).
|
|
90
|
+
* Any other bare `export *` and any unparseable file fail the build.
|
|
91
|
+
*/
|
|
92
|
+
async function esModuleExportNames(specifier, file, reader, seen = /* @__PURE__ */ new Set()) {
|
|
93
|
+
const names = /* @__PURE__ */ new Set();
|
|
94
|
+
if (seen.has(file)) return names;
|
|
95
|
+
seen.add(file);
|
|
96
|
+
let body;
|
|
97
|
+
try {
|
|
98
|
+
body = reader.parse(fs.readFileSync(file, "utf8")).body;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
throw new Error(`The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
101
|
+
}
|
|
102
|
+
const shared = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);
|
|
103
|
+
for (const node of body) {
|
|
104
|
+
if (node.type === "ExportDefaultDeclaration") names.add(DEFAULT_EXPORT);
|
|
105
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
106
|
+
const declaration = node.declaration;
|
|
107
|
+
if (declaration?.type === "VariableDeclaration") for (const declarator of declaration.declarations) for (const name of patternNames(declarator.id)) names.add(name);
|
|
108
|
+
else if (declaration) names.add(declaration.id.name);
|
|
109
|
+
for (const entry of node.specifiers ?? []) names.add(exportedName(entry.exported));
|
|
110
|
+
}
|
|
111
|
+
if (node.type === "ExportAllDeclaration") {
|
|
112
|
+
if (node.exported) {
|
|
113
|
+
names.add(exportedName(node.exported));
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const source = String(node.source.value);
|
|
117
|
+
let target;
|
|
118
|
+
if (source.startsWith("./") || source.startsWith("../")) target = path.resolve(path.dirname(file), source);
|
|
119
|
+
else if (shared.has(source)) {
|
|
120
|
+
target = await reader.resolve(source, file);
|
|
121
|
+
if (target === void 0) throw new Error(`The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`);
|
|
122
|
+
} else throw new Error(`The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`);
|
|
123
|
+
for (const name of await esModuleExportNames(specifier, target, reader, seen)) if (name !== DEFAULT_EXPORT) names.add(name);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return names;
|
|
127
|
+
}
|
|
128
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/u;
|
|
129
|
+
/** A module that reads one shared module from the page runtime and re-exports the given names. */
|
|
130
|
+
function renderWebPluginFacade(specifier, names) {
|
|
131
|
+
const all = new Set(names);
|
|
132
|
+
const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];
|
|
133
|
+
const exported = [];
|
|
134
|
+
let index = 0;
|
|
135
|
+
for (const name of [...all].sort()) {
|
|
136
|
+
if (name === DEFAULT_EXPORT) continue;
|
|
137
|
+
const local = `_${String(index++)}`;
|
|
138
|
+
lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);
|
|
139
|
+
exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);
|
|
140
|
+
}
|
|
141
|
+
if (exported.length > 0) lines.push(`export { ${exported.join(", ")} };`);
|
|
142
|
+
if (all.has(DEFAULT_EXPORT)) lines.push("export default runtime[\"default\"];");
|
|
143
|
+
else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push("export default runtime;");
|
|
144
|
+
lines.push("");
|
|
145
|
+
return lines.join("\n");
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Resolves every shared runtime specifier to a virtual facade that re-exports, by name,
|
|
149
|
+
* from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without
|
|
150
|
+
* the page providing an import map. Names come from the host's own copy of each module.
|
|
151
|
+
*/
|
|
152
|
+
function webPluginRuntimeFacadePlugin(hostRoot) {
|
|
153
|
+
const shared = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);
|
|
154
|
+
const hostImporter = path.join(hostRoot, "package.json");
|
|
155
|
+
const hostRequire = createRequire(hostImporter);
|
|
156
|
+
return {
|
|
157
|
+
name: "po-web-runtime-facades",
|
|
158
|
+
enforce: "pre",
|
|
159
|
+
resolveId(source) {
|
|
160
|
+
return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;
|
|
161
|
+
},
|
|
162
|
+
async load(id) {
|
|
163
|
+
if (!isWebPluginFacade(id)) return null;
|
|
164
|
+
const specifier = id.slice(16);
|
|
165
|
+
if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier)));
|
|
166
|
+
const resolveFile = async (source, importer) => {
|
|
167
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true });
|
|
168
|
+
return resolved ? resolved.id.split("?")[0] ?? resolved.id : void 0;
|
|
169
|
+
};
|
|
170
|
+
const file = await resolveFile(specifier, hostImporter);
|
|
171
|
+
if (file === void 0) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);
|
|
172
|
+
const { parseAst } = await import("vite");
|
|
173
|
+
return renderWebPluginFacade(specifier, await esModuleExportNames(specifier, file, {
|
|
174
|
+
parse: (code) => parseAst(code),
|
|
175
|
+
resolve: resolveFile
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */
|
|
181
|
+
function webPluginRuntimeAliases(clientRoot) {
|
|
182
|
+
const runtimeRequire = createRequire(path.join(clientRoot, "index.html"));
|
|
183
|
+
return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith("react/jsx-")).map((specifier) => ({
|
|
184
|
+
find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "u"),
|
|
185
|
+
replacement: runtimeRequire.resolve(specifier)
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Swaps the committed builtin registry modules for generated ones. A
|
|
190
|
+
* resolveId hook rather than resolve.alias because aliases match raw import
|
|
191
|
+
* specifiers while these two are known by their resolved paths. Both the
|
|
192
|
+
* sync-time build and the dev server use it, so a plugin edit in dev is the
|
|
193
|
+
* same module the bundle would carry.
|
|
194
|
+
*/
|
|
195
|
+
function webPluginOverridePlugin(clientRoot, generated) {
|
|
196
|
+
const overrides = /* @__PURE__ */ new Map([[path.join(clientRoot, "app", "webPlugins.generated.ts"), generated.clientModulePath], [path.join(clientRoot, "styles", "webPluginSources.generated.css"), generated.cssModulePath]]);
|
|
197
|
+
return {
|
|
198
|
+
name: "po-web-plugin-overrides",
|
|
199
|
+
enforce: "pre",
|
|
200
|
+
async resolveId(source, importer, options) {
|
|
201
|
+
if (!source.includes("webPlugins.generated") && !source.includes("webPluginSources.generated.css")) return null;
|
|
202
|
+
const resolved = await this.resolve(source, importer, {
|
|
203
|
+
...options,
|
|
204
|
+
skipSelf: true
|
|
205
|
+
});
|
|
206
|
+
if (!resolved) return null;
|
|
207
|
+
return overrides.get(resolved.id) ?? null;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The CSS sources module cannot ride the resolveId hook: Vite and Tailwind
|
|
213
|
+
* resolve CSS @import through Vite's own id resolver, which consults aliases
|
|
214
|
+
* but no plugin hooks. Without this the builtin (empty) @source list ships
|
|
215
|
+
* and every plugin-only utility class is missing.
|
|
216
|
+
*/
|
|
217
|
+
function webPluginCssAlias(generated) {
|
|
218
|
+
return {
|
|
219
|
+
find: /^\.\/webPluginSources\.generated\.css$/,
|
|
220
|
+
replacement: generated.cssModulePath
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */
|
|
224
|
+
function readDevPluginRoots(environment, homeDirectory) {
|
|
225
|
+
const explicit = environment[PLUGIN_ROOTS_ENV];
|
|
226
|
+
if (explicit !== void 0 && explicit !== "") return devPluginRoots({
|
|
227
|
+
envValue: explicit,
|
|
228
|
+
rootsFileText: void 0,
|
|
229
|
+
delimiter: path.delimiter
|
|
230
|
+
});
|
|
231
|
+
const repoRoot = environment[PO_ROOT_ENV];
|
|
232
|
+
if (repoRoot === void 0 || repoRoot === "") return [];
|
|
233
|
+
return compositionPackageRoots(rootCompositions({
|
|
234
|
+
root: repoRoot,
|
|
235
|
+
homeDirectory,
|
|
236
|
+
environment
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
export { WEB_PLUGIN_FACADE_CHUNK, WEB_PLUGIN_RUNTIME_SPECIFIERS, esModuleExportNames, isWebPluginFacade, readDevPluginRoots, renderWebPluginFacade, webPluginCssAlias, webPluginOverridePlugin, webPluginRuntimeAliases, webPluginRuntimeFacadePlugin, webPluginRuntimeGlobal };
|
|
241
|
+
|
|
242
|
+
//# sourceMappingURL=webPluginVite.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webPluginVite.mjs","names":[],"sources":["../../../../src/builders/web/webPluginVite.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport type { Alias, Plugin } from 'vite';\n\nimport { rootCompositions } from '../cli/sessionComposition';\nimport { compositionPackageRoots } from './index';\nimport { devPluginRoots, PLUGIN_ROOTS_ENV } from './webDevRoots';\nimport type { WebPluginRegistryModules } from './webPluginGenerate';\n\nconst PO_ROOT_ENV = 'PO_ROOT';\n\n/**\n * The modules the cockpit supplies page-wide, rather than each plugin\n * carrying its own copy.\n *\n * Build-time metadata, and it stays here rather than in a browser-facing\n * barrel on purpose: exporting it from po-core/web put the literal list\n * into the shipped cockpit bundle, where a plugin's own specifier strings\n * would then appear as data.\n */\nexport const WEB_PLUGIN_RUNTIME_SPECIFIERS = [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n '@tanstack/store',\n '@tanstack/react-store',\n '@tanstack/react-router',\n '@agimon-ai/po-web-dashboard',\n '@agimon-ai/po-web-dashboard/views',\n '@agimon-ai/po-core/web',\n '@agimon-ai/po-web-components',\n '@agimon-ai/po-web-security/browser',\n '@codemirror/state',\n '@codemirror/view',\n] as const;\n\nconst WEB_PLUGIN_RUNTIME_PROPERTIES: Record<(typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number], string> = {\n react: 'react',\n 'react/jsx-runtime': 'reactJsxRuntime',\n 'react/jsx-dev-runtime': 'reactJsxDevRuntime',\n 'react-dom': 'reactDom',\n 'react-dom/client': 'reactDomClient',\n '@tanstack/store': 'tanstackStore',\n '@tanstack/react-store': 'tanstackReactStore',\n '@tanstack/react-router': 'tanstackRouter',\n '@agimon-ai/po-web-dashboard': 'dashboard',\n '@agimon-ai/po-web-dashboard/views': 'dashboardViews',\n '@agimon-ai/po-core/web': 'webContracts',\n '@agimon-ai/po-web-components': 'webComponents',\n '@agimon-ai/po-web-security/browser': 'webSecurityBrowser',\n '@codemirror/state': 'codemirrorState',\n '@codemirror/view': 'codemirrorView',\n};\n\ntype WebPluginRuntimeSpecifier = (typeof WEB_PLUGIN_RUNTIME_SPECIFIERS)[number];\n\n/** Expression for a shared module supplied by the session shell. */\nexport function webPluginRuntimeGlobal(specifier: WebPluginRuntimeSpecifier): string {\n return `globalThis.PoWebPluginRuntime.${WEB_PLUGIN_RUNTIME_PROPERTIES[specifier]}`;\n}\n\n/** The React family ships CommonJS, so its names come from loading it rather than parsing it. */\nconst COMMONJS_RUNTIME_SPECIFIERS: ReadonlySet<string> = new Set([\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n 'react-dom/client',\n]);\n\nconst FACADE_PREFIX = '\\0po-web-runtime:';\n/** The chunk every facade lands in, so each shared module is read from the runtime once. */\nexport const WEB_PLUGIN_FACADE_CHUNK = 'po-web-runtime';\n\n/** True for a module id that is one of the shared-module facades. */\nexport function isWebPluginFacade(id: string): boolean {\n return id.startsWith(FACADE_PREFIX);\n}\n\n/** The ES module name of a default export. */\nconst DEFAULT_EXPORT = 'default';\n\ntype AstNode = { type: string; [key: string]: unknown };\n\nfunction patternNames(pattern: AstNode): string[] {\n switch (pattern.type) {\n case 'Identifier':\n return [pattern.name as string];\n case 'ObjectPattern':\n return (pattern.properties as AstNode[]).flatMap((property) =>\n patternNames((property.type === 'RestElement' ? property.argument : property.value) as AstNode),\n );\n case 'ArrayPattern':\n return (pattern.elements as (AstNode | null)[]).flatMap((element) => (element ? patternNames(element) : []));\n case 'RestElement':\n return patternNames(pattern.argument as AstNode);\n case 'AssignmentPattern':\n return patternNames(pattern.left as AstNode);\n default:\n return [];\n }\n}\n\nfunction exportedName(node: AstNode): string {\n return node.type === 'Identifier' ? (node.name as string) : String(node.value);\n}\n\n/** Static reading of an ES module's export names, as the facade plugin needs it. */\nexport interface ExportNameReader {\n parse: (code: string) => { body: unknown[] };\n /** Resolves a bare specifier from the file that imports it, to a file path. */\n resolve: (source: string, importer: string) => Promise<string | undefined>;\n}\n\n/**\n * The export names of an ES module file. `export *` is followed through relative paths,\n * and through a bare specifier only when that specifier is itself a shared module\n * (resolved from the re-exporting file, since that is the copy the runtime object holds).\n * Any other bare `export *` and any unparseable file fail the build.\n */\nexport async function esModuleExportNames(\n specifier: string,\n file: string,\n reader: ExportNameReader,\n seen: Set<string> = new Set(),\n): Promise<Set<string>> {\n const names = new Set<string>();\n if (seen.has(file)) return names;\n seen.add(file);\n let body: AstNode[];\n try {\n body = reader.parse(fs.readFileSync(file, 'utf8')).body as AstNode[];\n } catch (error) {\n throw new Error(\n `The shared module '${specifier}' cannot be parsed at ${file}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n for (const node of body) {\n if (node.type === 'ExportDefaultDeclaration') names.add(DEFAULT_EXPORT);\n if (node.type === 'ExportNamedDeclaration') {\n const declaration = node.declaration as AstNode | null;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations as AstNode[])\n for (const name of patternNames(declarator.id as AstNode)) names.add(name);\n } else if (declaration) {\n names.add((declaration.id as AstNode).name as string);\n }\n for (const entry of (node.specifiers as AstNode[] | undefined) ?? [])\n names.add(exportedName(entry.exported as AstNode));\n }\n if (node.type === 'ExportAllDeclaration') {\n if (node.exported) {\n names.add(exportedName(node.exported as AstNode));\n continue;\n }\n const source = String((node.source as AstNode).value);\n let target: string | undefined;\n if (source.startsWith('./') || source.startsWith('../')) target = path.resolve(path.dirname(file), source);\n else if (shared.has(source)) {\n target = await reader.resolve(source, file);\n if (target === undefined)\n throw new Error(\n `The shared module '${specifier}' re-exports '${source}', which does not resolve from ${file}.`,\n );\n } else\n throw new Error(\n `The shared module '${specifier}' re-exports everything from the bare specifier '${source}' (${file}), which is not a shared module; its names cannot be listed.`,\n );\n for (const name of await esModuleExportNames(specifier, target, reader, seen))\n if (name !== DEFAULT_EXPORT) names.add(name);\n }\n }\n return names;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/u;\n\n/** A module that reads one shared module from the page runtime and re-exports the given names. */\nexport function renderWebPluginFacade(specifier: WebPluginRuntimeSpecifier, names: Iterable<string>): string {\n const all = new Set(names);\n const lines = [`const runtime = ${webPluginRuntimeGlobal(specifier)};`];\n const exported: string[] = [];\n let index = 0;\n for (const name of [...all].sort()) {\n if (name === DEFAULT_EXPORT) continue;\n const local = `_${String(index++)}`;\n lines.push(`const ${local} = runtime[${JSON.stringify(name)}];`);\n exported.push(`${local} as ${IDENTIFIER.test(name) ? name : JSON.stringify(name)}`);\n }\n if (exported.length > 0) lines.push(`export { ${exported.join(', ')} };`);\n // CommonJS has no default export of its own; interop treats the whole object as one.\n if (all.has(DEFAULT_EXPORT)) lines.push('export default runtime[\"default\"];');\n else if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier)) lines.push('export default runtime;');\n lines.push('');\n return lines.join('\\n');\n}\n\n/**\n * Resolves every shared runtime specifier to a virtual facade that re-exports, by name,\n * from `globalThis.PoWebPluginRuntime`, so ES-module slot entries can import them without\n * the page providing an import map. Names come from the host's own copy of each module.\n */\nexport function webPluginRuntimeFacadePlugin(hostRoot: string): Plugin {\n const shared: ReadonlySet<string> = new Set(WEB_PLUGIN_RUNTIME_SPECIFIERS);\n const hostImporter = path.join(hostRoot, 'package.json');\n const hostRequire = createRequire(hostImporter);\n return {\n name: 'po-web-runtime-facades',\n enforce: 'pre',\n resolveId(source) {\n return shared.has(source) ? `${FACADE_PREFIX}${source}` : null;\n },\n async load(id) {\n if (!isWebPluginFacade(id)) return null;\n const specifier = id.slice(FACADE_PREFIX.length) as WebPluginRuntimeSpecifier;\n if (COMMONJS_RUNTIME_SPECIFIERS.has(specifier))\n return renderWebPluginFacade(specifier, Object.keys(hostRequire(specifier) as object));\n const resolveFile = async (source: string, importer: string): Promise<string | undefined> => {\n const resolved = await this.resolve(source, importer, { skipSelf: true });\n return resolved ? (resolved.id.split('?')[0] ?? resolved.id) : undefined;\n };\n const file = await resolveFile(specifier, hostImporter);\n if (file === undefined) throw new Error(`The shared module '${specifier}' does not resolve from ${hostRoot}.`);\n const { parseAst } = await import('vite');\n return renderWebPluginFacade(\n specifier,\n await esModuleExportNames(specifier, file, { parse: (code) => parseAst(code), resolve: resolveFile }),\n );\n },\n };\n}\n\n/** Resolves generated JSX imports from the host instead of a plugin's optional React peer tree. */\nexport function webPluginRuntimeAliases(clientRoot: string): Alias[] {\n const runtimeRequire = createRequire(path.join(clientRoot, 'index.html'));\n return WEB_PLUGIN_RUNTIME_SPECIFIERS.filter((specifier) => specifier.startsWith('react/jsx-')).map((specifier) => ({\n find: new RegExp(`^${specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}$`, 'u'),\n replacement: runtimeRequire.resolve(specifier),\n }));\n}\n\n/**\n * Swaps the committed builtin registry modules for generated ones. A\n * resolveId hook rather than resolve.alias because aliases match raw import\n * specifiers while these two are known by their resolved paths. Both the\n * sync-time build and the dev server use it, so a plugin edit in dev is the\n * same module the bundle would carry.\n */\nexport function webPluginOverridePlugin(clientRoot: string, generated: WebPluginRegistryModules): Plugin {\n const overrides = new Map([\n [path.join(clientRoot, 'app', 'webPlugins.generated.ts'), generated.clientModulePath],\n [path.join(clientRoot, 'styles', 'webPluginSources.generated.css'), generated.cssModulePath],\n ]);\n return {\n name: 'po-web-plugin-overrides',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n if (!source.includes('webPlugins.generated') && !source.includes('webPluginSources.generated.css')) return null;\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n if (!resolved) return null;\n return overrides.get(resolved.id) ?? null;\n },\n };\n}\n\n/**\n * The CSS sources module cannot ride the resolveId hook: Vite and Tailwind\n * resolve CSS @import through Vite's own id resolver, which consults aliases\n * but no plugin hooks. Without this the builtin (empty) @source list ships\n * and every plugin-only utility class is missing.\n */\nexport function webPluginCssAlias(generated: WebPluginRegistryModules): Alias {\n return { find: /^\\.\\/webPluginSources\\.generated\\.css$/, replacement: generated.cssModulePath };\n}\n\n/** The plugin package roots the dev server should serve, from an explicit override or PO_ROOT. */\nexport function readDevPluginRoots(environment: NodeJS.ProcessEnv, homeDirectory: string): string[] {\n const explicit = environment[PLUGIN_ROOTS_ENV];\n if (explicit !== undefined && explicit !== '') {\n return devPluginRoots({ envValue: explicit, rootsFileText: undefined, delimiter: path.delimiter });\n }\n const repoRoot = environment[PO_ROOT_ENV];\n if (repoRoot === undefined || repoRoot === '') return [];\n // Resolved live from the root's configuration and installed packages, as the server does.\n return compositionPackageRoots(rootCompositions({ root: repoRoot, homeDirectory, environment }));\n}\n"],"mappings":";;;;;;;AAWA,MAAM,cAAc;;;;;;;;;;AAWpB,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gCA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GAAK,CAAC;GACpF,IAAI,CAAC,UAAU,OAAO;GACtB,OAAO,UAAU,IAAI,SAAS,EAAE,KAAK;EACvC;CACF;AACF;;;;;;;AAQA,SAAgB,kBAAkB,WAA4C;CAC5E,OAAO;EAAE,MAAM;EAA0C,aAAa,UAAU;CAAc;AAChG;;AAGA,SAAgB,mBAAmB,aAAgC,eAAiC;CAClG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IACzC,OAAO,eAAe;EAAE,UAAU;EAAU,eAAe,KAAA;EAAW,WAAW,KAAK;CAAU,CAAC;CAEnG,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,IAAI,OAAO,CAAC;CAEvD,OAAO,wBAAwB,iBAAiB;EAAE,MAAM;EAAU;EAAe;CAAY,CAAC,CAAC;AACjG"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
const require_help = require("./help.cjs");
|
|
2
|
+
const require_options = require("./options.cjs");
|
|
3
|
+
//#region src/cli/cliApp.ts
|
|
4
|
+
const NO_HARNESS_COMMAND = "No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.";
|
|
5
|
+
/**
|
|
6
|
+
* Main CLI Application
|
|
7
|
+
*
|
|
8
|
+
* Owns command registration and dispatch. Preparation is shared: the context
|
|
9
|
+
* is built once and handed to whichever command claims the run.
|
|
10
|
+
*/
|
|
11
|
+
async function selectHarnessCommand(options) {
|
|
12
|
+
if (options.emitMcp) return (await Promise.resolve().then(() => require("./commands/emit-mcp/index.cjs"))).runEmitMcp;
|
|
13
|
+
if (options.explain) return (await Promise.resolve().then(() => require("./commands/explain/index.cjs"))).runExplain;
|
|
14
|
+
throw new Error(NO_HARNESS_COMMAND);
|
|
15
|
+
}
|
|
16
|
+
async function selectLegacyCommand(options) {
|
|
17
|
+
if (options.emitMcp) {
|
|
18
|
+
const { EmitMcpCommand } = await Promise.resolve().then(() => require("./commands/emit-mcp/index.cjs"));
|
|
19
|
+
return new EmitMcpCommand();
|
|
20
|
+
}
|
|
21
|
+
if (options.explain) {
|
|
22
|
+
const { ExplainCommand } = await Promise.resolve().then(() => require("./commands/explain/index.cjs"));
|
|
23
|
+
return new ExplainCommand();
|
|
24
|
+
}
|
|
25
|
+
throw new Error(NO_HARNESS_COMMAND);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The terminal app reads only what sync prepared. Packages the selected layers name that do not
|
|
29
|
+
* resolve yet start a detached background sync from the repository, which registers it as a
|
|
30
|
+
* workspace so sync covers its packages, and they arrive on the next launch.
|
|
31
|
+
*/
|
|
32
|
+
async function requestUnsyncedPackages(repoRoot, context) {
|
|
33
|
+
const [{ missingLayerPackageSpecifiers }, { createLayerResolvers }, { createBackgroundSync }] = await Promise.all([
|
|
34
|
+
Promise.resolve().then(() => require("../composition/layerPackageInstaller/index.cjs")),
|
|
35
|
+
Promise.resolve().then(() => require("../../builders/cli/extensionAssembler/index.cjs")),
|
|
36
|
+
Promise.resolve().then(() => require("../builders/server/backgroundSync.cjs"))
|
|
37
|
+
]);
|
|
38
|
+
const missing = missingLayerPackageSpecifiers(context.majorModesConfig, context.selectedLayers, createLayerResolvers(repoRoot, context.environment));
|
|
39
|
+
if (missing.length === 0) return;
|
|
40
|
+
const notice = (message) => {
|
|
41
|
+
process.stderr.write(`${message}\n`);
|
|
42
|
+
};
|
|
43
|
+
notice(createBackgroundSync({
|
|
44
|
+
environment: context.environment,
|
|
45
|
+
onNotice: notice,
|
|
46
|
+
detached: true,
|
|
47
|
+
repoRoot
|
|
48
|
+
}).request("the terminal app found unsynced packages") ? `Po is syncing ${missing.join(", ")} in the background; they arrive on the next launch.` : `${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not synced; run po sync to prepare them.`);
|
|
49
|
+
}
|
|
50
|
+
/** Only the diagnostic commands consume a harness context; bare `po` runs po-web. */
|
|
51
|
+
function wantsHarnessCommand(options) {
|
|
52
|
+
return Boolean(options.emitMcp) || options.explain;
|
|
53
|
+
}
|
|
54
|
+
function createCliApplication(initialTelemetry) {
|
|
55
|
+
let telemetry = initialTelemetry;
|
|
56
|
+
let ownsTelemetry = false;
|
|
57
|
+
async function getTelemetry() {
|
|
58
|
+
if (telemetry) return telemetry;
|
|
59
|
+
const { createHarnessTelemetry } = await import("@agimon-ai/po-core/runtimeLogSinkTelemetry");
|
|
60
|
+
telemetry = createHarnessTelemetry({ deferSpans: true });
|
|
61
|
+
ownsTelemetry = true;
|
|
62
|
+
return telemetry;
|
|
63
|
+
}
|
|
64
|
+
async function runHarness(options) {
|
|
65
|
+
const telemetry = await getTelemetry();
|
|
66
|
+
const [{ buildHarnessContext }, { HARNESS_EVENT }] = await Promise.all([Promise.resolve().then(() => require("../builders/cli/harnessContext.cjs")), import("@agimon-ai/po-core/runtimeLogSinkTelemetry")]);
|
|
67
|
+
return telemetry.runInSpan("doom_pi.run", {
|
|
68
|
+
"harness.major_mode": options.majorMode,
|
|
69
|
+
"harness.domain_count": options.domains.length,
|
|
70
|
+
"harness.agents": options.agents,
|
|
71
|
+
"harness.mcp": options.mcp,
|
|
72
|
+
"harness.hooks": options.hooks,
|
|
73
|
+
...options.profile ? { "harness.profile": options.profile } : {},
|
|
74
|
+
...options.preset ? { "harness.preset": options.preset } : {}
|
|
75
|
+
}, async () => {
|
|
76
|
+
const context = await buildHarnessContext(options, telemetry);
|
|
77
|
+
try {
|
|
78
|
+
await requestUnsyncedPackages(options.repoRoot, context);
|
|
79
|
+
return await (await selectHarnessCommand(context.options))(context, telemetry);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
await telemetry.recordError(HARNESS_EVENT.cliFailed, error);
|
|
82
|
+
throw error;
|
|
83
|
+
} finally {
|
|
84
|
+
await context.cleanup();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function run(args) {
|
|
89
|
+
if (args[0] === "init") {
|
|
90
|
+
const { runInit } = await Promise.resolve().then(() => require("./commands/init/index.cjs"));
|
|
91
|
+
return runInit(args);
|
|
92
|
+
}
|
|
93
|
+
if (args[0] === "sync") {
|
|
94
|
+
const { runSync } = await Promise.resolve().then(() => require("./commands/sync/workflow.cjs"));
|
|
95
|
+
return runSync(args);
|
|
96
|
+
}
|
|
97
|
+
if (args[0] === "api-export") {
|
|
98
|
+
const { runApiExport } = await Promise.resolve().then(() => require("./commands/api-export/index.cjs"));
|
|
99
|
+
return runApiExport(args);
|
|
100
|
+
}
|
|
101
|
+
if (args[0] === "doctor") {
|
|
102
|
+
const { runDoctor } = await Promise.resolve().then(() => require("./commands/doctor/index.cjs"));
|
|
103
|
+
return runDoctor(args);
|
|
104
|
+
}
|
|
105
|
+
if (args[0] === "compat") {
|
|
106
|
+
const [{ runCompatibility }, telemetry] = await Promise.all([Promise.resolve().then(() => require("./commands/compat/index.cjs")), getTelemetry()]);
|
|
107
|
+
return runCompatibility(args, void 0, void 0, telemetry);
|
|
108
|
+
}
|
|
109
|
+
const initial = require_options.parseHarnessArgs(args);
|
|
110
|
+
if (initial.help) {
|
|
111
|
+
require_help.printHelp();
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
if (initial.version) {
|
|
115
|
+
process.stdout.write(`${require_help.HARNESS_VERSION}\n`);
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
if (!wantsHarnessCommand(initial.options)) {
|
|
119
|
+
const { runPoWeb } = await Promise.resolve().then(() => require("./commands/web/index.cjs"));
|
|
120
|
+
return runPoWeb(args);
|
|
121
|
+
}
|
|
122
|
+
const telemetry = await getTelemetry();
|
|
123
|
+
const [{ resolveHarnessOptions }, { toFailureReporter }] = await Promise.all([Promise.resolve().then(() => require("./harnessOptions.cjs")), import("@agimon-ai/po-core/runtimeLogSinkTelemetry")]);
|
|
124
|
+
return runHarness(resolveHarnessOptions({
|
|
125
|
+
args,
|
|
126
|
+
report: toFailureReporter(telemetry)
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
async function shutdown() {
|
|
130
|
+
if (ownsTelemetry) await telemetry?.shutdown();
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
run,
|
|
134
|
+
runHarness,
|
|
135
|
+
shutdown
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Public compatibility API; execution is implemented by the application functions. */
|
|
139
|
+
var CliApp = class {
|
|
140
|
+
app;
|
|
141
|
+
constructor(telemetry) {
|
|
142
|
+
this.app = createCliApplication(telemetry);
|
|
143
|
+
}
|
|
144
|
+
selectCommand(options) {
|
|
145
|
+
return selectLegacyCommand(options);
|
|
146
|
+
}
|
|
147
|
+
runHarness(options) {
|
|
148
|
+
return this.app.runHarness(options);
|
|
149
|
+
}
|
|
150
|
+
run(args) {
|
|
151
|
+
return this.app.run(args);
|
|
152
|
+
}
|
|
153
|
+
shutdown() {
|
|
154
|
+
return this.app.shutdown();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Convenience wrapper kept so the binary and tests need no CliApp knowledge.
|
|
159
|
+
*
|
|
160
|
+
* Telemetry is shut down here rather than inside runHarness, because this is
|
|
161
|
+
* the only scope that owns the process: flushing earlier would drop the records
|
|
162
|
+
* a later command still emits.
|
|
163
|
+
*/
|
|
164
|
+
async function runCli(args) {
|
|
165
|
+
const app = createCliApplication();
|
|
166
|
+
try {
|
|
167
|
+
return await app.run(args);
|
|
168
|
+
} finally {
|
|
169
|
+
await app.shutdown();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** Runs an already-resolved option set, skipping argument parsing. */
|
|
173
|
+
async function runHarness(options) {
|
|
174
|
+
const app = createCliApplication();
|
|
175
|
+
try {
|
|
176
|
+
return await app.runHarness(options);
|
|
177
|
+
} finally {
|
|
178
|
+
await app.shutdown();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
exports.CliApp = CliApp;
|
|
183
|
+
exports.requestUnsyncedPackages = requestUnsyncedPackages;
|
|
184
|
+
exports.runCli = runCli;
|
|
185
|
+
exports.runHarness = runHarness;
|
|
186
|
+
|
|
187
|
+
//# sourceMappingURL=cliApp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliApp.cjs","names":["parseHarnessArgs","HARNESS_VERSION"],"sources":["../../../src/cli/cliApp.ts"],"sourcesContent":["import type { HarnessTelemetry } from '@agimon-ai/po-core/runtimeLogSinkTelemetry';\n\nimport type { HarnessOptions } from '../composition/types/harness';\nimport type { BaseCommand } from './commands/baseCommand';\nimport { HARNESS_VERSION, printHelp } from './help';\nimport { parseHarnessArgs } from './options';\n\nconst NO_HARNESS_COMMAND = 'No harness command selected: pass --explain or --emit-mcp, or run po to start po-web.';\n\n/**\n * Main CLI Application\n *\n * Owns command registration and dispatch. Preparation is shared: the context\n * is built once and handed to whichever command claims the run.\n */\nasync function selectHarnessCommand(\n options: HarnessOptions,\n): Promise<\n (context: import('../builders/cli/harnessContext').HarnessContext, telemetry: HarnessTelemetry) => Promise<number>\n> {\n if (options.emitMcp) return (await import('./commands/emit-mcp')).runEmitMcp;\n if (options.explain) return (await import('./commands/explain')).runExplain;\n throw new Error(NO_HARNESS_COMMAND);\n}\nasync function selectLegacyCommand(options: HarnessOptions): Promise<BaseCommand> {\n if (options.emitMcp) {\n const { EmitMcpCommand } = await import('./commands/emit-mcp');\n return new EmitMcpCommand();\n }\n if (options.explain) {\n const { ExplainCommand } = await import('./commands/explain');\n return new ExplainCommand();\n }\n throw new Error(NO_HARNESS_COMMAND);\n}\n/**\n * The terminal app reads only what sync prepared. Packages the selected layers name that do not\n * resolve yet start a detached background sync from the repository, which registers it as a\n * workspace so sync covers its packages, and they arrive on the next launch.\n */\nexport async function requestUnsyncedPackages(\n repoRoot: string,\n context: Pick<\n import('../builders/cli/harnessContext').HarnessContext,\n 'majorModesConfig' | 'selectedLayers' | 'environment'\n >,\n): Promise<void> {\n const [{ missingLayerPackageSpecifiers }, { createLayerResolvers }, { createBackgroundSync }] = await Promise.all([\n import('../composition/layerPackageInstaller'),\n import('../builders/cli/extensionAssembler'),\n import('../builders/server/backgroundSync'),\n ]);\n const missing = missingLayerPackageSpecifiers(\n context.majorModesConfig,\n context.selectedLayers,\n createLayerResolvers(repoRoot, context.environment),\n );\n if (missing.length === 0) return;\n const notice = (message: string): void => {\n process.stderr.write(`${message}\\n`);\n };\n const started = createBackgroundSync({\n environment: context.environment,\n onNotice: notice,\n detached: true,\n repoRoot,\n }).request('the terminal app found unsynced packages');\n notice(\n started\n ? `Po is syncing ${missing.join(', ')} in the background; they arrive on the next launch.`\n : `${missing.join(', ')} ${missing.length === 1 ? 'is' : 'are'} not synced; run po sync to prepare them.`,\n );\n}\n/** Only the diagnostic commands consume a harness context; bare `po` runs po-web. */\nfunction wantsHarnessCommand(options: Pick<HarnessOptions, 'emitMcp' | 'explain'>): boolean {\n return Boolean(options.emitMcp) || options.explain;\n}\nfunction createCliApplication(initialTelemetry?: HarnessTelemetry) {\n let telemetry = initialTelemetry;\n let ownsTelemetry = false;\n async function getTelemetry(): Promise<HarnessTelemetry> {\n if (telemetry) return telemetry;\n const { createHarnessTelemetry } = await import('@agimon-ai/po-core/runtimeLogSinkTelemetry');\n // Telemetry's transport graph costs roughly one launcher budget slice by\n // itself. Startup callbacks and lifecycle events buffer until shutdown, so\n // transport initialization cannot compete with the Pi child for input.\n telemetry = createHarnessTelemetry({ deferSpans: true });\n ownsTelemetry = true;\n return telemetry;\n }\n\n async function runHarness(options: HarnessOptions): Promise<number> {\n const telemetry = await getTelemetry();\n const [{ buildHarnessContext }, { HARNESS_EVENT }] = await Promise.all([\n import('../builders/cli/harnessContext'),\n import('@agimon-ai/po-core/runtimeLogSinkTelemetry'),\n ]);\n return telemetry.runInSpan(\n 'doom_pi.run',\n {\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n 'harness.agents': options.agents,\n 'harness.mcp': options.mcp,\n 'harness.hooks': options.hooks,\n ...(options.profile ? { 'harness.profile': options.profile } : {}),\n ...(options.preset ? { 'harness.preset': options.preset } : {}),\n },\n async () => {\n const context = await buildHarnessContext(options, telemetry);\n try {\n await requestUnsyncedPackages(options.repoRoot, context);\n const command = await selectHarnessCommand(context.options);\n // Selection uses the same resolved options used to build the context.\n return await command(context, telemetry);\n } catch (error) {\n await telemetry.recordError(HARNESS_EVENT.cliFailed, error);\n throw error;\n } finally {\n await context.cleanup();\n }\n },\n );\n }\n\n async function run(args: string[]): Promise<number> {\n if (args[0] === 'init') {\n const { runInit } = await import('./commands/init');\n return runInit(args);\n }\n if (args[0] === 'sync') {\n const { runSync } = await import('./commands/sync/workflow');\n return runSync(args);\n }\n if (args[0] === 'api-export') {\n const { runApiExport } = await import('./commands/api-export');\n return runApiExport(args);\n }\n if (args[0] === 'doctor') {\n const { runDoctor } = await import('./commands/doctor');\n return runDoctor(args);\n }\n if (args[0] === 'compat') {\n const [{ runCompatibility }, telemetry] = await Promise.all([import('./commands/compat'), getTelemetry()]);\n return runCompatibility(args, undefined, undefined, telemetry);\n }\n\n // The first pass resolves --cwd without touching repository configuration,\n // which keeps help and version available even when modes.yaml is malformed.\n const initial = parseHarnessArgs(args);\n if (initial.help) {\n printHelp();\n return 0;\n }\n if (initial.version) {\n process.stdout.write(`${HARNESS_VERSION}\\n`);\n return 0;\n }\n // Bare `po` serves the web console. po-web owns its own arguments, so they\n // pass through untouched and never reach repository configuration here.\n if (!wantsHarnessCommand(initial.options)) {\n const { runPoWeb } = await import('./commands/web');\n return runPoWeb(args);\n }\n const telemetry = await getTelemetry();\n const [{ resolveHarnessOptions }, { toFailureReporter }] = await Promise.all([\n import('./harnessOptions'),\n import('@agimon-ai/po-core/runtimeLogSinkTelemetry'),\n ]);\n return runHarness(resolveHarnessOptions({ args, report: toFailureReporter(telemetry) }));\n }\n\n async function shutdown(): Promise<void> {\n if (ownsTelemetry) await telemetry?.shutdown();\n }\n return { run, runHarness, shutdown };\n}\n/** Public compatibility API; execution is implemented by the application functions. */\nexport class CliApp {\n private readonly app: ReturnType<typeof createCliApplication>;\n constructor(telemetry?: HarnessTelemetry) {\n this.app = createCliApplication(telemetry);\n }\n selectCommand(options: HarnessOptions): Promise<BaseCommand> {\n return selectLegacyCommand(options);\n }\n runHarness(options: HarnessOptions): Promise<number> {\n return this.app.runHarness(options);\n }\n run(args: string[]): Promise<number> {\n return this.app.run(args);\n }\n shutdown(): Promise<void> {\n return this.app.shutdown();\n }\n}\n\n/**\n * Convenience wrapper kept so the binary and tests need no CliApp knowledge.\n *\n * Telemetry is shut down here rather than inside runHarness, because this is\n * the only scope that owns the process: flushing earlier would drop the records\n * a later command still emits.\n */\nexport async function runCli(args: string[]): Promise<number> {\n const app = createCliApplication();\n try {\n return await app.run(args);\n } finally {\n await app.shutdown();\n }\n}\n\n/** Runs an already-resolved option set, skipping argument parsing. */\nexport async function runHarness(options: HarnessOptions): Promise<number> {\n const app = createCliApplication();\n try {\n return await app.runHarness(options);\n } finally {\n await app.shutdown();\n }\n}\n"],"mappings":";;;AAOA,MAAM,qBAAqB;;;;;;;AAQ3B,eAAe,qBACb,SAGA;CACA,IAAI,QAAQ,SAAS,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,+BAAA,CAAA,EAAA,CAA+B;CAClE,IAAI,QAAQ,SAAS,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,8BAAA,CAAA,EAAA,CAA8B;CACjE,MAAM,IAAI,MAAM,kBAAkB;AACpC;AACA,eAAe,oBAAoB,SAA+C;CAChF,IAAI,QAAQ,SAAS;EACnB,MAAM,EAAE,mBAAmB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,+BAAA,CAAA;EACjC,OAAO,IAAI,eAAe;CAC5B;CACA,IAAI,QAAQ,SAAS;EACnB,MAAM,EAAE,mBAAmB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,8BAAA,CAAA;EACjC,OAAO,IAAI,eAAe;CAC5B;CACA,MAAM,IAAI,MAAM,kBAAkB;AACpC;;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