@chainingintention/pi-web-cn 2.0.0 → 2.202610.1
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/README.md +61 -106
- package/dist/.plugins-ready +1 -0
- package/dist/cli.js +331 -174
- package/dist/cli.js.map +1 -1
- package/dist/client/apple-touch-icon-dev.png +0 -0
- package/dist/client/assets/PiWebApp-vueV4eKR.js +4938 -0
- package/dist/client/assets/classic-CyM97Akm.css +54 -0
- package/dist/client/assets/external-B9K8duyP.js +2 -0
- package/dist/client/assets/graphite-DquaqFXU.css +54 -0
- package/dist/client/assets/index-C8f0d0CR.js +2 -0
- package/dist/client/assets/paper-CB1oLuRr.css +54 -0
- package/dist/client/assets/pi-web-dark-D_KtbM95.css +54 -0
- package/dist/client/assets/pi-web-light-DSNLMIBI.css +54 -0
- package/dist/client/assets/vendor-editor-core-BfnHL1Dg.js +10 -0
- package/dist/client/assets/vendor-editor-languages-bNquDJP0.js +28 -0
- package/dist/client/favicon-dev.svg +8 -0
- package/dist/client/index.html +7 -51
- package/dist/client/manifest.webmanifest +2 -1
- package/dist/client/pwa-icon-dev-192.png +0 -0
- package/dist/client/pwa-icon-dev-512.png +0 -0
- package/dist/config.js +55 -8
- package/dist/config.js.map +1 -1
- package/dist/docker/piWebDockerCommandPlan.js +13 -4
- package/dist/docker/piWebDockerCommandPlan.js.map +1 -1
- package/dist/environment.js +4 -0
- package/dist/environment.js.map +1 -0
- package/dist/localization.js +24 -0
- package/dist/localization.js.map +1 -0
- package/dist/nativeServices/installedServiceDefinitions.js +617 -0
- package/dist/nativeServices/installedServiceDefinitions.js.map +1 -0
- package/dist/nativeServices/serviceAction.js +78 -20
- package/dist/nativeServices/serviceAction.js.map +1 -1
- package/dist/nativeServices/serviceDoctor.js +418 -114
- package/dist/nativeServices/serviceDoctor.js.map +1 -1
- package/dist/nativeServices/servicePlan.js +2 -2
- package/dist/nativeServices/servicePlan.js.map +1 -1
- package/dist/pi-packages/captains-log/README.md +11 -0
- package/dist/pi-packages/captains-log/dist/browser/channelProtocol.js +29 -0
- package/dist/pi-packages/captains-log/dist/browser/index.js +143 -0
- package/dist/pi-packages/captains-log/dist/browser/markdown.js +68 -0
- package/dist/pi-packages/captains-log/dist/browser/panel.js +148 -0
- package/dist/pi-packages/captains-log/dist/browser/protocol.js +26 -0
- package/dist/pi-packages/captains-log/dist/companion.js +126 -0
- package/dist/pi-packages/captains-log/dist/roundtrip.js +62 -0
- package/dist/pi-packages/captains-log/dist/server.js +210 -0
- package/dist/pi-packages/captains-log/dist/store.js +75 -0
- package/dist/pi-packages/captains-log/docs/usage.md +29 -0
- package/dist/pi-packages/captains-log/i18n.js +7 -0
- package/dist/pi-packages/captains-log/package.json +35 -0
- package/dist/pi-packages/captains-log/tsconfig.json +21 -0
- package/dist/pi-packages/captains-log/vite.config.mjs +28 -0
- package/dist/pi-packages/relays/extensions/index.js +61 -0
- package/dist/pi-packages/relays/i18n.js +7 -0
- package/dist/{pi-web-plugins → pi-packages}/relays/markdownDocument.js +3 -2
- package/dist/pi-packages/relays/package.json +20 -0
- package/dist/pi-packages/relays/pi-web-plugin.js +96 -0
- package/dist/pi-packages/relays/prompts/relay-worktree.md +18 -0
- package/dist/pi-packages/relays/prompts/relay.md +18 -0
- package/dist/{pi-web-plugins → pi-packages}/relays/relayDiscovery.js +2 -2
- package/dist/pi-packages/relays/relayDispatch.js +67 -0
- package/dist/pi-packages/relays/relayIdentity.js +37 -0
- package/dist/{pi-web-plugins → pi-packages}/relays/relaysPanelElement.js +98 -59
- package/dist/pi-packages/relays/skills/relay/SKILL.md +50 -0
- package/dist/pi-packages/relays/skills/relay-runner/SKILL.md +74 -0
- package/dist/pi-packages/workflows/browser/pi-web-plugin.js +42 -0
- package/dist/pi-packages/workflows/browser/worktreeDialog.js +170 -0
- package/dist/pi-packages/workflows/package.json +23 -0
- package/dist/pi-packages/workflows/prompts/worktree.md +21 -0
- package/dist/pi-packages/workflows/server-plugin.js +586 -0
- package/dist/pi-packages/workflows/vite.config.mjs +17 -0
- package/dist/pi-web-plugins/code-highlight/browser/pi-web-plugin.js +22 -0
- package/dist/pi-web-plugins/code-highlight/package.json +13 -0
- package/dist/pi-web-plugins/files/browser/assets/files-icon-DZObYhxb.svg +3 -0
- package/dist/pi-web-plugins/files/browser/pi-web-plugin.js +466 -0
- package/dist/pi-web-plugins/files/package.json +15 -0
- package/dist/pi-web-plugins/git/browser/git-contract.js +22 -11
- package/dist/pi-web-plugins/git/browser/git-panel.js +228 -100
- package/dist/pi-web-plugins/git/browser/i18n.js +7 -0
- package/dist/pi-web-plugins/git/browser/pi-web-plugin.js +28 -4
- package/dist/pi-web-plugins/git/git-backend.js +61 -21
- package/dist/pi-web-plugins/git/gitStatusCache.js +48 -0
- package/dist/pi-web-plugins/git/i18n.js +7 -0
- package/dist/pi-web-plugins/git/package.json +1 -0
- package/dist/pi-web-plugins/git/server-plugin.js +45 -24
- package/dist/pi-web-plugins/git/workspace-discovery-notify.cjs +14 -0
- package/dist/pi-web-plugins/git/workspaceDiscoveryHooks.js +186 -0
- package/dist/pi-web-plugins/info/i18n.js +7 -0
- package/dist/pi-web-plugins/info/infoInternals.js +76 -65
- package/dist/pi-web-plugins/info/package.json +1 -1
- package/dist/pi-web-plugins/info/pi-web-plugin.js +40 -42
- package/dist/pi-web-plugins/mermaid/browser/mermaid-engine.js +4255 -0
- package/dist/pi-web-plugins/mermaid/browser/pi-web-plugin.js +11 -0
- package/dist/pi-web-plugins/mermaid/package.json +13 -0
- package/dist/pi-web-plugins/terminal/browser/pi-web-plugin.js +219 -0
- package/dist/pi-web-plugins/terminal/i18n.js +7 -0
- package/dist/pi-web-plugins/terminal/package.json +16 -0
- package/dist/pi-web-plugins/terminal/server-plugin.js +367 -0
- package/dist/pi-web-plugins/terminal/terminalService.js +436 -0
- package/dist/pi-web-plugins/updates/i18n.js +7 -0
- package/dist/pi-web-plugins/updates/package.json +1 -1
- package/dist/pi-web-plugins/updates/pi-web-plugin.js +143 -140
- package/dist/pi-web-plugins/updates/updatesLogic.js +24 -24
- package/dist/pi-web-plugins/workspace-tasks/config.js +12 -11
- package/dist/pi-web-plugins/workspace-tasks/i18n.js +7 -0
- package/dist/pi-web-plugins/workspace-tasks/package.json +1 -1
- package/dist/pi-web-plugins/workspace-tasks/pi-web-plugin.js +31 -9
- package/dist/pi-web-plugins/workspace-tasks/tasksPanelElement.js +54 -36
- package/dist/pi-web-plugins/workspace-tasks/workspaceTasksClient.js +12 -11
- package/dist/pi-web-plugins/zh-cn/auth.json +9 -0
- package/dist/pi-web-plugins/zh-cn/bundled.json +219 -0
- package/dist/pi-web-plugins/zh-cn/cli.json +230 -0
- package/dist/pi-web-plugins/zh-cn/client.json +225 -0
- package/dist/pi-web-plugins/zh-cn/components.json +1252 -0
- package/dist/pi-web-plugins/zh-cn/config-errors.json +188 -0
- package/dist/pi-web-plugins/zh-cn/files.json +50 -0
- package/dist/pi-web-plugins/zh-cn/machines.json +28 -0
- package/dist/pi-web-plugins/zh-cn/main.json +459 -0
- package/dist/pi-web-plugins/zh-cn/management-errors.json +23 -0
- package/dist/pi-web-plugins/zh-cn/manifest.webmanifest +25 -0
- package/dist/pi-web-plugins/zh-cn/metadata.json +3 -0
- package/dist/pi-web-plugins/zh-cn/package.json +10 -0
- package/dist/pi-web-plugins/zh-cn/pi-web-plugin.js +16 -0
- package/dist/pi-web-plugins/zh-cn/projects.json +6 -0
- package/dist/pi-web-plugins/zh-cn/provider-auth.json +18 -0
- package/dist/pi-web-plugins/zh-cn/routing.json +68 -0
- package/dist/pi-web-plugins/zh-cn/server-main.json +99 -0
- package/dist/pi-web-plugins/zh-cn/server.json +256 -0
- package/dist/piAi.js +4 -0
- package/dist/piAi.js.map +1 -0
- package/dist/piRuntime.js +150 -0
- package/dist/piRuntime.js.map +1 -0
- package/dist/piSdk.js +5 -0
- package/dist/piSdk.js.map +1 -0
- package/dist/piWebUpdate.js +508 -0
- package/dist/piWebUpdate.js.map +1 -0
- package/dist/piWebVersionReport.js +109 -41
- package/dist/piWebVersionReport.js.map +1 -1
- package/dist/plugin-api.d.ts +609 -29
- package/dist/plugin-api.js +1 -0
- package/dist/pluginRecoveryCli.js +27 -25
- package/dist/pluginRecoveryCli.js.map +1 -1
- package/dist/server/activity/workspaceActivityService.js +13 -6
- package/dist/server/activity/workspaceActivityService.js.map +1 -1
- package/dist/server/app.js +158 -89
- package/dist/server/app.js.map +1 -1
- package/dist/server/audit/managementAuditStore.js +6 -1
- package/dist/server/audit/managementAuditStore.js.map +1 -1
- package/dist/server/audit/normalToolAuditCli.js +45 -43
- package/dist/server/audit/normalToolAuditCli.js.map +1 -1
- package/dist/server/browserMessageProjection.js +39 -22
- package/dist/server/browserMessageProjection.js.map +1 -1
- package/dist/server/configRoutes.js +54 -33
- package/dist/server/configRoutes.js.map +1 -1
- package/dist/server/deploymentIdentity.js +67 -0
- package/dist/server/deploymentIdentity.js.map +1 -0
- package/dist/server/deploymentIdentityRoutes.js +22 -0
- package/dist/server/deploymentIdentityRoutes.js.map +1 -0
- package/dist/server/diagnostics/nodePtyNativeModule.js +7 -6
- package/dist/server/diagnostics/nodePtyNativeModule.js.map +1 -1
- package/dist/server/diagnostics/nodePtySpawnHelper.js +21 -20
- package/dist/server/diagnostics/nodePtySpawnHelper.js.map +1 -1
- package/dist/server/index.js +10 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/knownAutoInstallPiPackages.js +36 -0
- package/dist/server/knownAutoInstallPiPackages.js.map +1 -0
- package/dist/server/knownPiPackages.js +12 -0
- package/dist/server/knownPiPackages.js.map +1 -0
- package/dist/server/machines/machineClient.js +23 -19
- package/dist/server/machines/machineClient.js.map +1 -1
- package/dist/server/machines/machinePluginProxyRoutes.js +131 -31
- package/dist/server/machines/machinePluginProxyRoutes.js.map +1 -1
- package/dist/server/machines/machineProxyRoutes.js +138 -47
- package/dist/server/machines/machineProxyRoutes.js.map +1 -1
- package/dist/server/machines/machineRoutes.js +18 -13
- package/dist/server/machines/machineRoutes.js.map +1 -1
- package/dist/server/machines/machineService.js +40 -18
- package/dist/server/machines/machineService.js.map +1 -1
- package/dist/server/managementEmbed.js +149 -30
- package/dist/server/managementEmbed.js.map +1 -1
- package/dist/server/managementPrivileges.js +21 -0
- package/dist/server/managementPrivileges.js.map +1 -0
- package/dist/server/managementTerminalProxyRoutes.js +124 -0
- package/dist/server/managementTerminalProxyRoutes.js.map +1 -0
- package/dist/server/navigationPreferenceRoutes.js +59 -0
- package/dist/server/navigationPreferenceRoutes.js.map +1 -0
- package/dist/server/normalAuth.js +77 -53
- package/dist/server/normalAuth.js.map +1 -1
- package/dist/server/notices/serverNoticeRoutes.js +43 -0
- package/dist/server/notices/serverNoticeRoutes.js.map +1 -0
- package/dist/server/notices/serverNoticeService.js +26 -0
- package/dist/server/notices/serverNoticeService.js.map +1 -0
- package/dist/server/notices/serverNoticeStore.js +122 -0
- package/dist/server/notices/serverNoticeStore.js.map +1 -0
- package/dist/server/passwordVerifier.js +91 -0
- package/dist/server/passwordVerifier.js.map +1 -0
- package/dist/server/piPackageIdentity.js +25 -0
- package/dist/server/piPackageIdentity.js.map +1 -0
- package/dist/server/piPackageService.js +72 -9
- package/dist/server/piPackageService.js.map +1 -1
- package/dist/server/piWebPluginCatalog.js +212 -35
- package/dist/server/piWebPluginCatalog.js.map +1 -1
- package/dist/server/piWebPluginLifecycle.js +29 -3
- package/dist/server/piWebPluginLifecycle.js.map +1 -1
- package/dist/server/piWebPluginService.js +199 -292
- package/dist/server/piWebPluginService.js.map +1 -1
- package/dist/server/piWebStatus.js +57 -100
- package/dist/server/piWebStatus.js.map +1 -1
- package/dist/server/pluginCallbackDrain.js +35 -0
- package/dist/server/pluginCallbackDrain.js.map +1 -0
- package/dist/server/plugins/pluginBackendChannelProxyAdmission.js +84 -0
- package/dist/server/plugins/pluginBackendChannelProxyAdmission.js.map +1 -0
- package/dist/server/plugins/pluginBackendChannelProxyCoordinator.js +234 -0
- package/dist/server/plugins/pluginBackendChannelProxyCoordinator.js.map +1 -0
- package/dist/server/plugins/pluginBackendChannelProxyRoutes.js +61 -0
- package/dist/server/plugins/pluginBackendChannelProxyRoutes.js.map +1 -0
- package/dist/server/plugins/pluginBackendProxyRoutes.js +47 -57
- package/dist/server/plugins/pluginBackendProxyRoutes.js.map +1 -1
- package/dist/server/plugins/pluginBackendRegistry.js +804 -0
- package/dist/server/plugins/pluginBackendRegistry.js.map +1 -0
- package/dist/server/plugins/projectPluginSettings.js +95 -0
- package/dist/server/plugins/projectPluginSettings.js.map +1 -0
- package/dist/server/plugins/serverPluginCatalogCapability.js +106 -0
- package/dist/server/plugins/serverPluginCatalogCapability.js.map +1 -0
- package/dist/server/plugins/serverPluginPiSessionEventsCapability.js +34 -0
- package/dist/server/plugins/serverPluginPiSessionEventsCapability.js.map +1 -0
- package/dist/server/plugins/serverPluginPiSessionsCapability.js +185 -0
- package/dist/server/plugins/serverPluginPiSessionsCapability.js.map +1 -0
- package/dist/server/plugins/serverPluginRuntime.js +1088 -108
- package/dist/server/plugins/serverPluginRuntime.js.map +1 -1
- package/dist/server/plugins/serverPluginWorkspacesCapability.js +114 -0
- package/dist/server/plugins/serverPluginWorkspacesCapability.js.map +1 -0
- package/dist/server/projectTrustRoutes.js +86 -0
- package/dist/server/projectTrustRoutes.js.map +1 -0
- package/dist/server/projects/projectLifecycleService.js +94 -0
- package/dist/server/projects/projectLifecycleService.js.map +1 -0
- package/dist/server/projects/projectService.js +7 -4
- package/dist/server/projects/projectService.js.map +1 -1
- package/dist/server/realtime/sessionEventHub.js +58 -39
- package/dist/server/realtime/sessionEventHub.js.map +1 -1
- package/dist/server/realtime/sessionEventScope.js +4 -0
- package/dist/server/realtime/sessionEventScope.js.map +1 -1
- package/dist/server/requestCancellation.js +15 -1
- package/dist/server/requestCancellation.js.map +1 -1
- package/dist/server/sessiond/agentHttpDispatcher.js +108 -0
- package/dist/server/sessiond/agentHttpDispatcher.js.map +1 -0
- package/dist/server/sessiond/autoInstallPiPackages.js +63 -0
- package/dist/server/sessiond/autoInstallPiPackages.js.map +1 -0
- package/dist/server/sessiond/pluginBackendChannelRoutes.js +410 -0
- package/dist/server/sessiond/pluginBackendChannelRoutes.js.map +1 -0
- package/dist/server/sessiond/pluginBackendRoutes.js +64 -47
- package/dist/server/sessiond/pluginBackendRoutes.js.map +1 -1
- package/dist/server/sessiond/pluginCatalogRoutes.js +41 -0
- package/dist/server/sessiond/pluginCatalogRoutes.js.map +1 -0
- package/dist/server/sessiond/projectMutationRoutes.js +39 -0
- package/dist/server/sessiond/projectMutationRoutes.js.map +1 -0
- package/dist/server/sessiond/sessionDaemonShutdown.js +36 -0
- package/dist/server/sessiond/sessionDaemonShutdown.js.map +1 -0
- package/dist/server/sessiond/sessionDaemonStartup.js +30 -4
- package/dist/server/sessiond/sessionDaemonStartup.js.map +1 -1
- package/dist/server/sessiond/sessionProxyRoutes.js +263 -91
- package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
- package/dist/server/sessiond/sessionServiceDependencies.js +5 -0
- package/dist/server/sessiond/sessionServiceDependencies.js.map +1 -1
- package/dist/server/sessiond/sessiondStateOwnership.js +174 -39
- package/dist/server/sessiond/sessiondStateOwnership.js.map +1 -1
- package/dist/server/sessiond/workspaceCatalogRoutes.js +11 -5
- package/dist/server/sessiond/workspaceCatalogRoutes.js.map +1 -1
- package/dist/server/sessiond/workspaceNotificationRoutes.js +55 -0
- package/dist/server/sessiond/workspaceNotificationRoutes.js.map +1 -0
- package/dist/server/sessiond/workspaceRemovalRoutes.js +1 -1
- package/dist/server/sessiond/workspaceRemovalRoutes.js.map +1 -1
- package/dist/server/sessiond.js +313 -69
- package/dist/server/sessiond.js.map +1 -1
- package/dist/server/sessions/askUserDomain.js +232 -0
- package/dist/server/sessions/askUserDomain.js.map +1 -0
- package/dist/server/sessions/askUserTool.js +18 -21
- package/dist/server/sessions/askUserTool.js.map +1 -1
- package/dist/server/sessions/attachmentService.js +2 -6
- package/dist/server/sessions/attachmentService.js.map +1 -1
- package/dist/server/sessions/authRoutes.js +32 -19
- package/dist/server/sessions/authRoutes.js.map +1 -1
- package/dist/server/sessions/authService.js +31 -11
- package/dist/server/sessions/authService.js.map +1 -1
- package/dist/server/sessions/builtinCommands.js +28 -21
- package/dist/server/sessions/builtinCommands.js.map +1 -1
- package/dist/server/sessions/builtinExtensionFactories.js +36 -0
- package/dist/server/sessions/builtinExtensionFactories.js.map +1 -0
- package/dist/server/sessions/clientSessionPreview.js +14 -0
- package/dist/server/sessions/clientSessionPreview.js.map +1 -0
- package/dist/server/sessions/companionBackend.js +286 -0
- package/dist/server/sessions/companionBackend.js.map +1 -0
- package/dist/server/sessions/dockerEnvironmentFacts.js +98 -10
- package/dist/server/sessions/dockerEnvironmentFacts.js.map +1 -1
- package/dist/server/sessions/extensionSessionDispatch.js +76 -0
- package/dist/server/sessions/extensionSessionDispatch.js.map +1 -0
- package/dist/server/sessions/globalProviderPolicy.js +88 -19
- package/dist/server/sessions/globalProviderPolicy.js.map +1 -1
- package/dist/server/sessions/managementAgentTools.js +116 -6
- package/dist/server/sessions/managementAgentTools.js.map +1 -1
- package/dist/server/sessions/managementPermissionSystem.js +36 -14
- package/dist/server/sessions/managementPermissionSystem.js.map +1 -1
- package/dist/server/sessions/managementSandbox.js +7 -18
- package/dist/server/sessions/managementSandbox.js.map +1 -1
- package/dist/server/sessions/mcpAuthFlowService.js +289 -0
- package/dist/server/sessions/mcpAuthFlowService.js.map +1 -0
- package/dist/server/sessions/mcpAuthRoutes.js +104 -0
- package/dist/server/sessions/mcpAuthRoutes.js.map +1 -0
- package/dist/server/sessions/mcpOAuthCredentialAdapter.js +92 -0
- package/dist/server/sessions/mcpOAuthCredentialAdapter.js.map +1 -0
- package/dist/server/sessions/messageHistoryTarget.js +79 -0
- package/dist/server/sessions/messageHistoryTarget.js.map +1 -0
- package/dist/server/sessions/messagePaging.js +2 -2
- package/dist/server/sessions/messagePaging.js.map +1 -1
- package/dist/server/sessions/modelCatalogRefresher.js +4 -3
- package/dist/server/sessions/modelCatalogRefresher.js.map +1 -1
- package/dist/server/sessions/oauthLoginFlowService.js +19 -20
- package/dist/server/sessions/oauthLoginFlowService.js.map +1 -1
- package/dist/server/sessions/piSessionEventConnections.js +68 -0
- package/dist/server/sessions/piSessionEventConnections.js.map +1 -0
- package/dist/server/sessions/piSessionManagerGateway.js +206 -27
- package/dist/server/sessions/piSessionManagerGateway.js.map +1 -1
- package/dist/server/sessions/piSessionService.js +2508 -991
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/plainTextTheme.js +1 -1
- package/dist/server/sessions/plainTextTheme.js.map +1 -1
- package/dist/server/sessions/projectAuthService.js +35 -6
- package/dist/server/sessions/projectAuthService.js.map +1 -1
- package/dist/server/sessions/projectSettingsScope.js +88 -33
- package/dist/server/sessions/projectSettingsScope.js.map +1 -1
- package/dist/server/sessions/projectTrust.js +119 -0
- package/dist/server/sessions/projectTrust.js.map +1 -0
- package/dist/server/sessions/queuedMessageMutation.js +170 -0
- package/dist/server/sessions/queuedMessageMutation.js.map +1 -0
- package/dist/server/sessions/relaySkill.js +169 -0
- package/dist/server/sessions/relaySkill.js.map +1 -0
- package/dist/server/sessions/sessionActivityMarker.js +105 -0
- package/dist/server/sessions/sessionActivityMarker.js.map +1 -0
- package/dist/server/sessions/sessionArchiveMapping.js +16 -15
- package/dist/server/sessions/sessionArchiveMapping.js.map +1 -1
- package/dist/server/sessions/sessionArchiveStore.js +5 -1
- package/dist/server/sessions/sessionArchiveStore.js.map +1 -1
- package/dist/server/sessions/sessionArchiveTree.js +2 -2
- package/dist/server/sessions/sessionArchiveTree.js.map +1 -1
- package/dist/server/sessions/sessionCleanup.js +4 -3
- package/dist/server/sessions/sessionCleanup.js.map +1 -1
- package/dist/server/sessions/sessionCommandService.js +79 -87
- package/dist/server/sessions/sessionCommandService.js.map +1 -1
- package/dist/server/sessions/sessionEnvironmentFacts.js +5 -4
- package/dist/server/sessions/sessionEnvironmentFacts.js.map +1 -1
- package/dist/server/sessions/sessionFileHeader.js +41 -0
- package/dist/server/sessions/sessionFileHeader.js.map +1 -1
- package/dist/server/sessions/sessionImageDimensions.js +31 -0
- package/dist/server/sessions/sessionImageDimensions.js.map +1 -0
- package/dist/server/sessions/sessionMediaIndex.js +191 -0
- package/dist/server/sessions/sessionMediaIndex.js.map +1 -0
- package/dist/server/sessions/sessionMetadata.js +51 -0
- package/dist/server/sessions/sessionMetadata.js.map +1 -0
- package/dist/server/sessions/sessionModelScope.js +160 -0
- package/dist/server/sessions/sessionModelScope.js.map +1 -0
- package/dist/server/sessions/sessionNameGenerator.js +16 -35
- package/dist/server/sessions/sessionNameGenerator.js.map +1 -1
- package/dist/server/sessions/sessionNotificationStore.js +14 -11
- package/dist/server/sessions/sessionNotificationStore.js.map +1 -1
- package/dist/server/sessions/sessionReadAccess.js +41 -0
- package/dist/server/sessions/sessionReadAccess.js.map +1 -0
- package/dist/server/sessions/sessionRoutes.js +221 -78
- package/dist/server/sessions/sessionRoutes.js.map +1 -1
- package/dist/server/sessions/sessionSummaryScanner.js +62 -5
- package/dist/server/sessions/sessionSummaryScanner.js.map +1 -1
- package/dist/server/sessions/sessionTreeProjection.js +50 -49
- package/dist/server/sessions/sessionTreeProjection.js.map +1 -1
- package/dist/server/sessions/sessionUiEvents.js +22 -10
- package/dist/server/sessions/sessionUiEvents.js.map +1 -1
- package/dist/server/sessions/sessionUnreadStore.js +53 -3
- package/dist/server/sessions/sessionUnreadStore.js.map +1 -1
- package/dist/server/sessions/spawnSessionTool.js +14 -6
- package/dist/server/sessions/spawnSessionTool.js.map +1 -1
- package/dist/server/sessions/spawnSubsessionTool.js +40 -24
- package/dist/server/sessions/spawnSubsessionTool.js.map +1 -1
- package/dist/server/sessions/spawnTargetResolver.js +1 -1
- package/dist/server/sessions/subsessionCompletionDelivery.js +15 -0
- package/dist/server/sessions/subsessionCompletionDelivery.js.map +1 -0
- package/dist/server/sessions/subsessionCompletionInbox.js +134 -0
- package/dist/server/sessions/subsessionCompletionInbox.js.map +1 -0
- package/dist/server/sessions/subsessionProvenance.js +27 -0
- package/dist/server/sessions/subsessionProvenance.js.map +1 -0
- package/dist/server/sessions/transcriptBranchCache.js +81 -0
- package/dist/server/sessions/transcriptBranchCache.js.map +1 -0
- package/dist/server/sessions/transcriptMarkdown.js +48 -0
- package/dist/server/sessions/transcriptMarkdown.js.map +1 -0
- package/dist/server/sessions/transcriptMessages.js +57 -0
- package/dist/server/sessions/transcriptMessages.js.map +1 -0
- package/dist/server/startupLogger.js +13 -0
- package/dist/server/startupLogger.js.map +1 -0
- package/dist/server/startupUrls.js +27 -0
- package/dist/server/startupUrls.js.map +1 -0
- package/dist/server/status/machineStatusService.js +15 -7
- package/dist/server/status/machineStatusService.js.map +1 -1
- package/dist/server/storage/navigationPreferenceStore.js +138 -0
- package/dist/server/storage/navigationPreferenceStore.js.map +1 -0
- package/dist/server/storage/piPackageDismissalStore.js +78 -0
- package/dist/server/storage/piPackageDismissalStore.js.map +1 -0
- package/dist/server/terminals/{terminalService.js → managementCommandRunService.js} +98 -102
- package/dist/server/terminals/managementCommandRunService.js.map +1 -0
- package/dist/server/terminals/managementTerminalRoutes.js +91 -0
- package/dist/server/terminals/managementTerminalRoutes.js.map +1 -0
- package/dist/server/terminals/requiredTerminalService.js +103 -0
- package/dist/server/terminals/requiredTerminalService.js.map +1 -0
- package/dist/server/webSocketBridge.js +348 -0
- package/dist/server/webSocketBridge.js.map +1 -1
- package/dist/server/workbench/accessStateStore.js +33 -5
- package/dist/server/workbench/accessStateStore.js.map +1 -1
- package/dist/server/workbench/capabilitySearch.js +3 -2
- package/dist/server/workbench/capabilitySearch.js.map +1 -1
- package/dist/server/workbench/gatewayIntegration.js +40 -13
- package/dist/server/workbench/gatewayIntegration.js.map +1 -1
- package/dist/server/workbench/knowledgeSearch.js +100 -0
- package/dist/server/workbench/knowledgeSearch.js.map +1 -0
- package/dist/server/workbench/mcpClient.js +41 -8
- package/dist/server/workbench/mcpClient.js.map +1 -1
- package/dist/server/workbench/skillSync.js +11 -3
- package/dist/server/workbench/skillSync.js.map +1 -1
- package/dist/server/workbench/workbenchClient.js +130 -7
- package/dist/server/workbench/workbenchClient.js.map +1 -1
- package/dist/server/workbench/workbenchTools.js +196 -14
- package/dist/server/workbench/workbenchTools.js.map +1 -1
- package/dist/server/workingDirectory.js +3 -2
- package/dist/server/workingDirectory.js.map +1 -1
- package/dist/server/workspaceExplorerRoutes.js +53 -21
- package/dist/server/workspaceExplorerRoutes.js.map +1 -1
- package/dist/server/workspaces/fileContentService.js +31 -16
- package/dist/server/workspaces/fileContentService.js.map +1 -1
- package/dist/server/workspaces/fileOperationService.js +11 -9
- package/dist/server/workspaces/fileOperationService.js.map +1 -1
- package/dist/server/workspaces/filePreviewService.js +10 -6
- package/dist/server/workspaces/filePreviewService.js.map +1 -1
- package/dist/server/workspaces/fileSuggestions.js +77 -10
- package/dist/server/workspaces/fileSuggestions.js.map +1 -1
- package/dist/server/workspaces/fileTreeService.js +103 -15
- package/dist/server/workspaces/fileTreeService.js.map +1 -1
- package/dist/server/workspaces/normalProjectCwdResolver.js +35 -0
- package/dist/server/workspaces/normalProjectCwdResolver.js.map +1 -0
- package/dist/server/workspaces/pathAccessPolicy.js +24 -18
- package/dist/server/workspaces/pathAccessPolicy.js.map +1 -1
- package/dist/server/workspaces/pathSafety.js +6 -5
- package/dist/server/workspaces/pathSafety.js.map +1 -1
- package/dist/server/workspaces/projectPiWebConfig.js +95 -8
- package/dist/server/workspaces/projectPiWebConfig.js.map +1 -1
- package/dist/server/workspaces/projectWorkspaceCwds.js +0 -5
- package/dist/server/workspaces/projectWorkspaceCwds.js.map +1 -1
- package/dist/server/workspaces/sessionDaemonWorkspaceCatalog.js +37 -22
- package/dist/server/workspaces/sessionDaemonWorkspaceCatalog.js.map +1 -1
- package/dist/server/workspaces/workspaceCatalog.js +6 -4
- package/dist/server/workspaces/workspaceCatalog.js.map +1 -1
- package/dist/server/workspaces/workspaceChangeNotifier.js +12 -0
- package/dist/server/workspaces/workspaceChangeNotifier.js.map +1 -0
- package/dist/server/workspaces/workspaceDeletionRoutes.js +9 -70
- package/dist/server/workspaces/workspaceDeletionRoutes.js.map +1 -1
- package/dist/server/workspaces/workspaceNotificationCommand.js +64 -0
- package/dist/server/workspaces/workspaceNotificationCommand.js.map +1 -0
- package/dist/server/workspaces/workspaceProviderRegistry.js +128 -24
- package/dist/server/workspaces/workspaceProviderRegistry.js.map +1 -1
- package/dist/server/workspaces/workspaceRemovalService.js +41 -7
- package/dist/server/workspaces/workspaceRemovalService.js.map +1 -1
- package/dist/server/workspaces/workspaceRouteContext.js +1 -1
- package/dist/server/workspaces/workspaceRouteContext.js.map +1 -1
- package/dist/server/workspaces/workspaceRouteErrors.js +4 -2
- package/dist/server/workspaces/workspaceRouteErrors.js.map +1 -1
- package/dist/server/workspaces/workspaceUserError.js +18 -0
- package/dist/server/workspaces/workspaceUserError.js.map +1 -0
- package/dist/server-plugin-api.d.ts +349 -49
- package/dist/server-plugin-api.js +344 -2
- package/dist/server-plugin-api.js.map +1 -1
- package/dist/serverPluginRecovery.js +6 -1
- package/dist/serverPluginRecovery.js.map +1 -1
- package/dist/sessiond/activeAgentProfile.js +27 -2
- package/dist/sessiond/activeAgentProfile.js.map +1 -1
- package/dist/sessiond/config.js +4 -3
- package/dist/sessiond/config.js.map +1 -1
- package/dist/sessiond/sessionDaemonClient.js +75 -19
- package/dist/sessiond/sessionDaemonClient.js.map +1 -1
- package/dist/sessiond/sessionDaemonErrors.js +49 -0
- package/dist/sessiond/sessionDaemonErrors.js.map +1 -0
- package/dist/shared/activeAgentProfile.js +2 -34
- package/dist/shared/activeAgentProfile.js.map +1 -1
- package/dist/shared/activity.js +0 -3
- package/dist/shared/activity.js.map +1 -1
- package/dist/shared/apiTypes.js +10 -3
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/capabilities.js +8 -0
- package/dist/shared/capabilities.js.map +1 -1
- package/dist/shared/federatedRoutes.js +77 -11
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/dist/shared/i18n.js +41 -0
- package/dist/shared/i18n.js.map +1 -0
- package/dist/shared/machinePluginIds.js +30 -7
- package/dist/shared/machinePluginIds.js.map +1 -1
- package/dist/shared/machineStatus.js +46 -3
- package/dist/shared/machineStatus.js.map +1 -1
- package/dist/shared/navigationPreferences.js +6 -0
- package/dist/shared/navigationPreferences.js.map +1 -0
- package/dist/shared/piWebConfigParsing.js +118 -49
- package/dist/shared/piWebConfigParsing.js.map +1 -1
- package/dist/shared/piWebStatusParsing.js +33 -0
- package/dist/shared/piWebStatusParsing.js.map +1 -1
- package/dist/shared/pluginApiTypes.d.ts +87 -8
- package/dist/shared/pluginApiTypes.js +2 -0
- package/dist/shared/pluginApiTypes.js.map +1 -0
- package/dist/shared/pluginBackendProtocol.js +218 -2
- package/dist/shared/pluginBackendProtocol.js.map +1 -1
- package/dist/shared/pluginCatalogTypes.d.ts +49 -0
- package/dist/shared/pluginCatalogTypes.js +156 -0
- package/dist/shared/pluginCatalogTypes.js.map +1 -0
- package/dist/shared/pluginIds.js +10 -1
- package/dist/shared/pluginIds.js.map +1 -1
- package/dist/shared/requiredTerminalPlugin.js +6 -0
- package/dist/shared/requiredTerminalPlugin.js.map +1 -0
- package/dist/shared/serverNoticeContract.js +88 -0
- package/dist/shared/serverNoticeContract.js.map +1 -0
- package/dist/shared/sessionDefaults.js +42 -0
- package/dist/shared/sessionDefaults.js.map +1 -0
- package/dist/shared/sessionMedia.js +12 -0
- package/dist/shared/sessionMedia.js.map +1 -0
- package/dist/shared/streamingBehavior.js +8 -0
- package/dist/shared/streamingBehavior.js.map +1 -0
- package/dist/shared/themePreference.js +24 -0
- package/dist/shared/themePreference.js.map +1 -0
- package/dist/shared/thinkingLevels.js +17 -16
- package/dist/shared/thinkingLevels.js.map +1 -1
- package/dist/shared/workspaceFiles.js.map +1 -1
- package/dist/workspaceNotificationCli.js +95 -0
- package/dist/workspaceNotificationCli.js.map +1 -0
- package/docs/README.md +31 -0
- package/docs/config.md +344 -277
- package/docs/plugins.md +204 -930
- package/examples/session-bridge-plugin/README.md +20 -0
- package/examples/session-bridge-plugin/docs/usage.md +54 -0
- package/examples/session-bridge-plugin/package.json +26 -0
- package/examples/session-bridge-plugin/src/browser/index.ts +87 -0
- package/examples/session-bridge-plugin/src/browser/protocol.ts +24 -0
- package/examples/session-bridge-plugin/src/companion.ts +65 -0
- package/examples/session-bridge-plugin/src/reviewRun.ts +39 -0
- package/examples/session-bridge-plugin/src/server.ts +85 -0
- package/examples/session-bridge-plugin/src/store.ts +80 -0
- package/examples/session-bridge-plugin/tsconfig.json +21 -0
- package/examples/workspace-provider-plugin/README.md +39 -0
- package/examples/workspace-provider-plugin/package.json +25 -0
- package/examples/workspace-provider-plugin/src/browser/index.ts +69 -0
- package/examples/workspace-provider-plugin/src/server.ts +68 -0
- package/examples/workspace-provider-plugin/tsconfig.json +21 -0
- package/extensions/pi-web.ts +3 -1
- package/package.json +59 -36
- package/skills/README.md +28 -2
- package/skills/relay/SKILL.md +24 -89
- package/skills/relay-runner/SKILL.md +74 -0
- package/dist/client/assets/CodeViewer-DCl56K0Z.js +0 -4
- package/dist/client/assets/TerminalPanel-DCvoEjUF.js +0 -187
- package/dist/client/assets/index-CMvms5cF.js +0 -4325
- package/dist/client/assets/vendor-editor-core-vUi74DnD.js +0 -12
- package/dist/client/assets/vendor-editor-languages-DoaXUodB.js +0 -46
- package/dist/client/assets/vendor-editor-legacy-CYBnW6ZU.js +0 -1
- package/dist/client/assets/vendor-terminal-BrP-ENHg.css +0 -1
- package/dist/client/assets/vendor-terminal-D8k4UKM2.js +0 -35
- package/dist/pi-web-plugins/relays/package.json +0 -9
- package/dist/pi-web-plugins/relays/pi-web-plugin.js +0 -44
- package/dist/server/git/gitService.js +0 -290
- package/dist/server/git/gitService.js.map +0 -1
- package/dist/server/gitRoutes.js +0 -23
- package/dist/server/gitRoutes.js.map +0 -1
- package/dist/server/sessions/pendingAskStore.js +0 -278
- package/dist/server/sessions/pendingAskStore.js.map +0 -1
- package/dist/server/terminalProxyRoutes.js +0 -178
- package/dist/server/terminalProxyRoutes.js.map +0 -1
- package/dist/server/terminals/terminalRoutes.js +0 -164
- package/dist/server/terminals/terminalRoutes.js.map +0 -1
- package/dist/server/terminals/terminalService.js.map +0 -1
- package/dist/server/terminals/terminalSize.js +0 -17
- package/dist/server/terminals/terminalSize.js.map +0 -1
- package/dist/server/workspaces/gitWorktreeDiscovery.js +0 -43
- package/dist/server/workspaces/gitWorktreeDiscovery.js.map +0 -1
- package/dist/server/workspaces/workspaceService.js +0 -52
- package/dist/server/workspaces/workspaceService.js.map +0 -1
- /package/dist/{pi-web-plugins → pi-packages}/relays/vendor/README.md +0 -0
- /package/dist/{pi-web-plugins → pi-packages}/relays/vendor/marked.esm.js +0 -0
package/docs/plugins.md
CHANGED
|
@@ -1,1060 +1,334 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 插件与 Pi 包
|
|
2
2
|
|
|
3
|
-
PI WEB
|
|
3
|
+
使用工作区工具、快捷操作和集成定制 PI WEB。可以安装现成的包,也可以让代理为具体工作流创建插件,无需修改 PI WEB 本身。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
本指南说明可实现的功能和使用方式;实现时请查阅[公开契约与示例](#agent-development),不要把本页作为第二份 API 声明。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- add workspace tools/panels next to Files, Git, and Terminal;
|
|
9
|
-
- add compact workspace-label items in the workspace list, panel header, and status bar;
|
|
10
|
-
- call browser APIs and documented PI WEB plugin context helpers;
|
|
11
|
-
- read workspace files and start workspace terminal commands through documented helpers;
|
|
12
|
-
- serve their own static assets from the plugin directory.
|
|
7
|
+
## 内置中文语言插件
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
`zh-cn` 随包提供且默认启用;在机器配置设置 `plugins["zh-cn"].enabled: false` 后恢复英文,无需额外语言文件。刷新网页、下次启动 CLI、重启服务后生效,详见[配置参考](config.md#chinese-language-plugin)。浏览器使用网关的语言,远端提示保持远端语言。
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
浏览器插件可通过激活上下文的可选 `translate(key, englishFallback, params)` 使用稳定消息键和命名参数;未提供翻译器或词条缺失时使用英文。语言插件以 `localizations` 贡献纯文本词典,不扫描 DOM 或注入 HTML。服务端激活上下文也可提供 `translate`,按所属机器配置格式化自有提示。旧插件 API 仍兼容;不要翻译用户输入、模型回复或代理转发的远端响应。Node 端只读取随包的 JSON 词典,不执行浏览器入口。
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
浏览器插件需要显式声明翻译类型时,可从公开入口 `@chainingintention/pi-web-cn/plugin-api` 使用 `import type` 导入 `Translator`、`TranslationParameters`、`TranslationMessages` 和 `LocalizationContribution`;服务端入口 `@chainingintention/pi-web-cn/server-plugin-api` 导出前两项。通过上下文调用翻译器,不要导入宿主内部的 `createTranslator` 或私有 `dist/` 路径。上下文的 `translate` 保持可选,兼容未提供该能力的旧宿主。
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
<a id="what-can-be-built"></a>
|
|
16
|
+
## 可实现的功能
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
| 目标 | 插件功能 |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| 展示项目健康状态、服务链接、环境信息 | 工作区标签与面板 |
|
|
21
|
+
| 添加仪表盘、文件查看器或项目工具 | 工作区面板、文件帮助方法与浏览器 UI |
|
|
22
|
+
| 方便查找常用操作 | 操作面板命令与快捷键 |
|
|
23
|
+
| 运行构建、测试或开发服务器 | 工作区终端命令 |
|
|
24
|
+
| 定制外观 | 主题及明暗主题组合 |
|
|
25
|
+
| 在聊天和文件中预览图表、文本格式 | 浏览器内容渲染器 |
|
|
26
|
+
| 读取或修改工作区文件 | 列出、读取、写入、移动、删除及上传文件 |
|
|
27
|
+
| 显示后端实时结果 | 浏览器入口与服务端入口之间的请求或流式通道 |
|
|
28
|
+
| 保存插件自己的结果和偏好 | 持久化服务端插件目录 |
|
|
29
|
+
| 发起 Pi 对话或与 Pi 扩展协作 | 宿主会话能力与会话内消息 |
|
|
30
|
+
| 使用其他系统替代 Git 工作区发现 | 工作区提供器 |
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
面板可支持直达链接和浏览器历史,并在文件变化或代理工作完成后刷新。文件和终端帮助方法始终针对面板所属机器与工作区,包括远端机器。
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
例如,可以请求代理创建“运行项目检查并显示结果的面板”“链接工作区预览部署的徽标”或“启动审查会话并保存结论的工具”。
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
<a id="pi-packages-extensions-and-plugins"></a>
|
|
37
|
+
## Pi 包、扩展与插件
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
- **Pi 包**是可安装的分发包,可以包含扩展、技能、提示词模板、主题和 PI WEB 插件。
|
|
40
|
+
- **Pi 扩展**定制代理的工具、命令、钩子、模型提供器及会话行为。
|
|
41
|
+
- **PI WEB 插件**定制 Web 应用及工作区集成。
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
一个包可包含上述三种定制。安装包与启用 PI WEB 插件是独立操作;禁用插件不会移除包里的 Pi 扩展、技能或提示词。
|
|
35
44
|
|
|
36
|
-
|
|
37
|
-
- **启动阶段的对话框可以回答。** 无论创建新会话还是打开已有会话,`session_start` 钩子发起的对话框都能在会话仍在启动时回答;对话框结束后启动流程继续。
|
|
38
|
-
- **浏览器刷新后可恢复,最先提交的回答生效。** 浏览器刷新后会根据会话状态重新显示打开的对话框。同一会话打开多个标签页时,最先提交的回答会结束对话框,其他标签页随后显示结束状态。
|
|
39
|
-
- **结束状态卡片会保留到用户关闭。** 已回答或已关闭的对话框会在会话记录中保留结果卡片。回答只会传给扩展,因此该卡片是这次交互唯一的可见记录。卡片属于浏览器本地状态:只有见过对话框打开的浏览器会显示它,切换会话或刷新页面后会清除。
|
|
40
|
-
- **超时。** 扩展自身的 `timeout` 仍然生效,守护进程还提供 `extensionDialogsTimeoutMs` 安全超时(默认 5 分钟,设为 `0` 时永久等待;见[扩展对话框](https://pi-web.dev/config#extension-dialogs))。最终期限取两者中较早的时间。没有回答就关闭的对话框会返回对应类型的取消值:确认框为 `false`,选择框和输入框为 `undefined`。
|
|
41
|
-
- **中止和运行时替换。** 中止当前运行时,本轮运行中打开的对话框会立即以取消值结束。替换会话运行时(例如 `/reload` 或销毁会话)也会结束所有仍打开的对话框;新运行时的钩子可以重新打开对话框。扩展传入的 `AbortSignal` 同样有效,中止信号会关闭对话框并返回取消值。
|
|
42
|
-
- **其他 UI 能力仍为空实现。** 除这三种对话框外,PI WEB 尚未实现 `ExtensionUIContext` 的其他方法(组件、状态、编辑器和 `custom`)。即使 `hasUI` 为 `true`,也不能仅凭它判断这些能力可用。
|
|
45
|
+
代理行为放在 Pi 扩展中,Web UI 放在 PI WEB 插件中。需要两者协作时一起发布,通过已托管会话的连接通信。
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
<a id="how-plugins-work"></a>
|
|
48
|
+
## 插件如何运行
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
包可以声明浏览器入口、服务端入口或双入口:
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
- **浏览器入口**贡献操作、面板、标签、主题与内容渲染器,使用宿主帮助方法访问文件、终端及提示词编辑器。
|
|
53
|
+
- **服务端入口**运行在会话守护进程中,可为浏览器入口服务、存储插件数据、使用宿主能力或提供工作区。
|
|
54
|
+
- **包内对等入口**连接同一插件的浏览器与服务端。宿主解析机器和工作区;插件不必拥有该工作区才能为其服务。
|
|
55
|
+
- **能力**声明所需的宿主或插件功能。启动前必须满足指定版本的依赖。
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
- they can read workspace files and start terminal commands through documented plugin helpers;
|
|
52
|
-
- they can render arbitrary Lit templates/custom elements in plugin contribution areas;
|
|
53
|
-
- they should not be installed from untrusted sources.
|
|
57
|
+
在 `activate()` 中声明贡献,在 `start()` 中初始化依赖支持的工作,在 `dispose()` 中释放资源。长时间工作遵循 `lifetimeSignal`。简单浏览器插件仅需返回贡献。
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
<a id="scoped-discovery-and-backend"></a>
|
|
60
|
+
### 作用域发现与后端
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
浏览器 API v5 的 `catalog` 固定到创建上下文时的机器,只读查询公开项目、工作区和会话投影,不返回 transcript 或内部会话路径。切换选择不会改变已保留 catalog 的目标;会话使用完整、区分大小写的精确 ID,不接受缩写。
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
可选 `backend` 指向同包配对的实际服务端入口:`backend.forScope({ kind: "machine" })`、`{ kind: "project", projectId }` 或 `{ kind: "workspace", projectId, workspaceId }` 返回请求/通道 peer。没有 session backend scope。宿主重新解析 authority,插件不传可信 cwd;机器与后端 revision 不匹配时拒绝,不静默使用网关同名后端。操作是否支持取决于实际 peer/capability,不由 API 版本单独保证。旧浏览器 v4 与服务端 v3 继续使用其原契约。
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
服务端可声明 `PI_WEB_HOST_CATALOG_CAPABILITY` 获取目标宿主的公开 catalog;Pi 配套扩展通过公开服务端入口的 `createCompanionBackend(pi.events, pluginId)` 发现本地配对 backend,要求在 PI WEB 已托管事件总线上运行。普通宿主会话连接不开放管理会话,完整特权也不取消该边界。普通 catalog 排除当前配置的管理 root;它不替历史文件补写耐久 scope,曾更换管理 root 的遗留文件需人工隔离。
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
- "Add an action-palette command that starts a standard code-review prompt."
|
|
66
|
-
- "Show whether the current workspace is a git worktree, main checkout, staging env, or feature branch."
|
|
67
|
-
- "Add a compact status badge based on a project health file or command output saved in the repo."
|
|
68
|
+
<a id="styles-highlighting-and-display"></a>
|
|
69
|
+
### 样式、高亮与显示文本
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
v5 `stylesheets` 贡献包含 `id`、HTTP(S) `url` 和可选 `order`(默认 `1000`,较小先加载,同序按限定贡献 ID)。使用模块相对 URL 生成 CSS 文件地址,文件内资产相对 CSS 地址解析;不支持内联 CSS 或运行时 `@import`。v5 主题使用样式表;需要共享样式的组件使用公开 `StylesheetIntegrationCapabilityV1` 注册 shadow root 或创建 Lit lifecycle controller,并在断开时释放。主题属于网关应用,浏览器设备偏好优先于网关默认值。
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
Build a PI WEB plugin for this project.
|
|
73
|
-
Goal: <describe the UI behavior>.
|
|
74
|
-
Before coding, read the PI WEB plugin docs:
|
|
75
|
-
https://pi-web.dev/plugins
|
|
76
|
-
Full API reference:
|
|
77
|
-
https://pi-web.dev/plugins.md
|
|
78
|
-
Create it as a local plugin under ~/.pi-web/plugins/<plugin-id>.
|
|
79
|
-
Use the appropriate extension points from the docs.
|
|
80
|
-
Validate by checking /pi-web-plugins/manifest.json and explain how to reload/debug it.
|
|
81
|
-
Do not modify PI WEB itself.
|
|
82
|
-
```
|
|
73
|
+
共享基础 UI 通过 `{ pluginId: "pi-web", id: "stylesheet-integration", version: 1, parse }` 声明依赖并在 `start` 中解析;组件使用 `createController(this, { sharedUi: true })` 或 `registerRoot(root, { sharedUi: true })`。省略 opt-in 只接收贡献样式,不接收共享按钮、选择器、工具栏、标签和文件行。宿主持有注入、排序与清理;原生事件、键盘交互、焦点与 ARIA 仍由消费者持有。共享 UI 不包含菜单、表单和对话框,插件不得深导入客户端私有样式。
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```text
|
|
87
|
-
Improve the PI WEB plugin at <path>.
|
|
88
|
-
Before coding, read the PI WEB plugin docs:
|
|
89
|
-
https://pi-web.dev/plugins
|
|
90
|
-
Full API reference:
|
|
91
|
-
https://pi-web.dev/plugins.md
|
|
92
|
-
Keep the plugin compatible with the documented v1 API.
|
|
93
|
-
After editing, check the manifest endpoint and browser-console failure cases.
|
|
94
|
-
```
|
|
75
|
+
`stylesheet-integration` 能力可由支持的浏览器 v4/v5 入口声明,能力版本与入口版本独立;这不使旧入口获得 v5 专属的 `stylesheets` 贡献字段。
|
|
95
76
|
|
|
96
|
-
|
|
77
|
+
基础主题同步提供默认布局与控件表现,主题 CSS 可扩展配色与布局;基础规则在 `pi-web-base` cascade layer,普通未分层主题规则遵循 CSS cascade 覆盖。内部选择器、共享类和外观仍属实验性,不因能力版本而冻结;具体控件入口见[共享 UI 导航](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/blob/main/docs/ui-primitives.md)。
|
|
97
78
|
|
|
98
|
-
|
|
79
|
+
v5 `syntaxHighlighters` 返回有序、不重叠的 UTF-16 范围 token,不返回 HTML;宿主负责安全显示,插件遵守输入 `signal`。v5 内容渲染器还可提供 `title`、同步 `supports(request)`,并接收机器、语言和文件路径提示;正文仍是不可信输入,净化与清理要求不变。精确签名以公开声明为准。
|
|
99
80
|
|
|
100
|
-
|
|
81
|
+
Pi 的 Markdown transformer 链在 daemon 的浏览器投影阶段运行,仅对完成及历史的用户、assistant 文本和 thinking 派生 `displayText`;部分流式文本完成后才应用,文件预览不受影响。canonical 消息、持久化历史、模型输入、审计原文和实际 `thinkingLevel` 不变。“复制消息”和消息操作使用原文;代码围栏的 Raw/Copy 使用变换后的围栏源码。
|
|
101
82
|
|
|
102
|
-
|
|
83
|
+
### 应用级面板与选择
|
|
103
84
|
|
|
104
|
-
|
|
105
|
-
pi-web-plugins/info/package.json
|
|
106
|
-
pi-web-plugins/info/pi-web-plugin.ts
|
|
107
|
-
pi-web-plugins/info/infoInternals.ts
|
|
108
|
-
```
|
|
85
|
+
`applicationPanels` 与 `workspacePanels` 由同一个浏览器工具区域装配。前者依附当前机器,无需先选项目、工作区或会话;后者需要已选工作区。应用级面板获得当前机器与公开选择快照,`workspace` 和工作区终端按可用性提供。内置 Info 使用应用级面板;无工作区时仍可显示机器和 PI WEB 状态。
|
|
109
86
|
|
|
110
|
-
`
|
|
87
|
+
激活上下文的可选 `selection` 服务由宿主持有。`getSnapshot()` 返回独立的基本选择快照;`subscribe()` 在选择改变后通知,不做首次回调,面板关闭后仍可订阅。返回的取消函数可提前结束订阅,插件生命周期结束时统一清理。快照不包含内部会话文件路径、消息正文或整份应用状态。
|
|
111
88
|
|
|
112
|
-
|
|
89
|
+
操作、应用级面板和工作区上下文的可选 `projects` 服务只读查询创建上下文时的机器:`listProjects()` 返回注册项目,`suggestDirectories(query)` 返回目录建议。保留的服务不会随之后的机器选择漂移;远端错误不会改查网关本机。旧宿主可能不提供这些可选服务。
|
|
113
90
|
|
|
114
|
-
|
|
115
|
-
dist/pi-web-plugins/info/pi-web-plugin.js
|
|
116
|
-
```
|
|
91
|
+
### 提示上下文 chip
|
|
117
92
|
|
|
118
|
-
|
|
93
|
+
`prompt.setChip({ id, label, text, onRemove? })` 将插件上下文暂存在该上下文捕获的机器和会话,作用域同时包含会话工作目录,不同工作区的同名会话不共享 chip;要求创建上下文时已有可用、非归档的会话。相同插件内的相同 `id` 替换内容与回调;`prompt.removeChip(id)` 可静默撤回。方法在旧宿主上可能不存在,不应从渲染回调中修改 chip。
|
|
119
94
|
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
"name": "@pi-web/info-plugin",
|
|
123
|
-
"private": true,
|
|
124
|
-
"piWeb": {
|
|
125
|
-
"plugins": [
|
|
126
|
-
{ "id": "info", "module": "pi-web-plugin.js" }
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
```
|
|
95
|
+
chip 由浏览器宿主持有,不是持久化会话数据;关闭面板、切换会话后仍保留各自内容,刷新页面后清除。发送时正文以空行分隔附加到消息,带 chip 的输入作为普通提示词而非斜杠或 shell 命令提交。只有服务端接受后才消费本次提交的版本,失败时保留以便重试,不删除发送期间的替换内容。用户移除和成功提交分别通知 `onRemove("user")` 与 `onRemove("submitted")`;程序撤回不通知。
|
|
131
96
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
export default {
|
|
136
|
-
apiVersion: 2,
|
|
137
|
-
name: "Info Plugin",
|
|
138
|
-
activate: ({ html, svg }) => ({
|
|
139
|
-
contributions: {
|
|
140
|
-
actions: [/* action definitions */],
|
|
141
|
-
workspaceLabels: [/* compact label definitions */],
|
|
142
|
-
workspacePanels: [/* panel definitions using html, optional icons using svg */],
|
|
143
|
-
},
|
|
144
|
-
}),
|
|
145
|
-
};
|
|
146
|
-
```
|
|
97
|
+
### 从聊天打开工作区文件
|
|
147
98
|
|
|
148
|
-
|
|
99
|
+
聊天 Markdown 中的相对文件链接(包括 `./file`)和会话工作区内的绝对路径会在内置文件面板中打开。修饰键、新标签页点击或没有面板接受链接时仍使用下载 URL。文件访问仍经过服务端工作区包含检查。
|
|
149
100
|
|
|
150
|
-
|
|
101
|
+
工作区面板通过同步 `fileOpenQuery(context, path)` 选择是否接受链接。上下文属于该贡献,路径是解码后的工作区相对路径;返回如 `{ file: path }` 的导航查询,或返回 `undefined` 拒绝。钩子不能产生副作用。宿主按面板 `order`、标题顺序打开当前机器上第一个可见、启用且接受链接的面板,通过普通导航设置命名空间查询。面板从 `context.navigation.query` 读取选择,不需要依赖文件插件。
|
|
151
102
|
|
|
152
|
-
|
|
103
|
+
### 面板与标签导航
|
|
153
104
|
|
|
154
|
-
|
|
105
|
+
URL 的 `view` 选择响应式面板:`navigation`、`chat` 或 `workspace`。独立的 `tool` 参数按贡献 ID 选择工作区标签。打开工具设置 `view=workspace` 和对应 `tool`;切换聊天保留工具选择。`view` 不接受贡献 ID。浏览器插件用 `selectMainView("workspace")` 显示工作区但不改变标签,或用 `selectWorkspaceTool(panelId)` 选择并显示工具。
|
|
155
106
|
|
|
156
|
-
|
|
107
|
+
无效值留在 URL 中,不自动重定向。无效 `view` 显示警告,移动布局展示导航;双列布局保留导航,并展示有效请求工具,否则展示聊天;桌面保留常规列。有效工作区视图配无效工具时显示标签不可用,不选择其他标签,也不重复警告。省略参数使用默认值,不是错误。
|
|
157
108
|
|
|
158
|
-
|
|
109
|
+
操作与工作区面板上下文提供完整目的地导航 `navigate(destination): Promise<void>`:
|
|
159
110
|
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
|
|
111
|
+
```ts
|
|
112
|
+
await context.navigate({
|
|
113
|
+
machineId: context.machine.id,
|
|
114
|
+
projectId: context.workspace.projectId,
|
|
115
|
+
workspaceId: context.workspace.id,
|
|
116
|
+
sessionId: sourceSessionId,
|
|
117
|
+
view: "chat",
|
|
118
|
+
});
|
|
163
119
|
```
|
|
164
120
|
|
|
165
|
-
|
|
121
|
+
所有字段都可省略:`machineId`、`projectId`、`workspaceId`、`sessionId`、`view` 及完整贡献 ID 的 `tool`。省略机器意味着调用时选中的机器。这不是路由补丁:省略字段使用宿主普通恢复默认值,不复制当前会话、工具或贡献查询;默认值可以恢复记忆中的会话。打开已知会话时提供项目和工作区作用域。宿主不会遍历查找 ID,也不会创建不存在的目的地。
|
|
166
122
|
|
|
167
|
-
|
|
123
|
+
Promise 在恢复完成时结束,也可在被较新导航取代时正常结束。缺失或不可用的目的地使用普通宿主 UI,不再额外拒绝 Promise。参数类型错误或无效 `view` 会在改变 URL/UI 前以 `TypeError` 拒绝。Captain's Log 用此接口打开结果记录的源会话。
|
|
168
124
|
|
|
169
|
-
|
|
125
|
+
### 聊天与文件内容预览
|
|
170
126
|
|
|
171
|
-
|
|
172
|
-
- plugin file and terminal helpers run against that machine;
|
|
173
|
-
- plugin code is loaded best-effort through the current gateway and cached for the browser page lifetime;
|
|
174
|
-
- if the gateway and remote machine both have an enabled plugin with the same original id, `machineSpecific` metadata decides whether the gateway copy is reused or only the selected machine's copy can appear;
|
|
175
|
-
- remote theme contributions are ignored for now because themes are app-wide;
|
|
176
|
-
- mixed PI WEB versions across federated machines are best-effort and not guaranteed compatible.
|
|
127
|
+
浏览器插件的 `contentRenderers` 提供 `id`、围栏 `languages` 或不含点的 `fileExtensions`,同步 `render(input)` 返回 Lit 模板。`renderMode` 默认为 `manual`,用户选择命名视图后才激活;`automatic` 可自动显示。v5 还可用 `title` 命名视图、同步 `supports(request)` 判断资格,并接收机器、语言和文件路径提示;旧 v4 输入不变。
|
|
177
128
|
|
|
178
|
-
|
|
129
|
+
同一渲染器用于聊天围栏、文件 Markdown 围栏和独立文本文件,并遵循所属机器可用性。浏览器先发现 bundled 默认插件,再发现 installed 覆盖,各组内部顺序保持不变。匹配项保持插件发现顺序,最后一个匹配的 automatic 渲染器是默认;后来的 manual 渲染器不抢占自动默认。异步加载完成顺序不决定优先级,用户显式选择优先。每个渲染器与“源码”(Raw)是单行横向滚动的命名按钮,同时仅挂载所选预览,不使用选择器菜单。
|
|
179
130
|
|
|
180
|
-
|
|
131
|
+
聊天按代码块在当前标签页记忆显式渲染器与源码选择:从最后一次显式选择起 **15 分钟**,最多 **128** 个最近选择块,作用域包含机器、会话、entry、part、块和精确源码。重新挂载不延长期限,源码变化或渲染器不可用时恢复默认;页面重载清除记忆。独立文件使用自己的浏览器源码/预览偏好,URL 模式优先,默认策略不自动变成用户偏好。
|
|
181
132
|
|
|
182
|
-
|
|
183
|
-
- `true`: the gateway copy only appears for the local machine. When a remote machine is selected, only that remote machine's copy can appear; if the remote machine does not expose the plugin, the plugin is hidden. This is best for plugins that report machine-local PI WEB status or depend on machine-local plugin code.
|
|
133
|
+
Raw 始终提供未高亮源码,Copy 复制当前代码块源码,即使正在预览也不复制图形。未闭合围栏、截断及超过 **100,000 UTF-16 码元**的输入不渲染;文件另有内联字节限制。渲染失败回退源码;追加正文不重启未变的闭合块,切换视图中止旧工作。Mermaid 图形保持手动激活,代码高亮与图形预览是独立视图。
|
|
184
134
|
|
|
185
|
-
|
|
135
|
+
`input` 的 `signal` 和 `fail(error)` 用于生命周期及异步错误;断开或中止时清理,过期错误不影响新视图。正文不可信,保留聊天和文件各自的净化器,不执行源码或放宽策略。
|
|
186
136
|
|
|
187
|
-
|
|
188
|
-
const url = new URL("./asset.json", import.meta.url);
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
If a remote plugin constructs absolute asset URLs, it should use the `pluginId` from `activate()` because PI WEB gives remote plugins a gateway-scoped runtime id. Hard-coded `/pi-web-plugins/<original-id>/...` URLs may point at the gateway instead of the remote machine.
|
|
137
|
+
消费者在 `requires` 声明 `{ pluginId: "pi-web", id: "content-rendering", version: 1, parse }`,在 `start` 解析。`ContentRenderingCapability` 提供 `listRenderers(request)`、`renderText(request)` 和 `renderMarkdown({ machineId, text, truncated?, toSafeHtml, allowManualPreview? })`。列表按发现顺序返回 `{ id, label, renderMode }`,不调用渲染器。
|
|
192
138
|
|
|
193
|
-
|
|
139
|
+
只有 `controls: "external"` 的 `renderText` 接受 `rendererId`,缺失或不可用时使用上述默认规则;内嵌控件自己拥有选择。消费者使用外部控件时自己提供视图选择、源码访问及移除预览。`allowManualPreview: true` 可授权手动预览,但不覆盖逐块 Raw 选择;文件与聊天各自持有用户意图,能力不持久化偏好。`renderMarkdown` 使用消费者可信净化器。精确签名见[公开浏览器契约](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/blob/main/src/plugin-api.ts)。
|
|
194
140
|
|
|
195
|
-
|
|
141
|
+
### 公开会话数据与消息操作
|
|
196
142
|
|
|
197
|
-
|
|
143
|
+
会话快照中的 `metadata` 只包含主动发布的 UI-safe 命名空间数据,不暴露任意 custom entries。命名空间不构成权限或所有权隔离,插件须校验自己的 schema 并安全显示;旧宿主可省略该字段。服务端发布与浏览器读取都不应放入秘密。
|
|
198
144
|
|
|
199
|
-
|
|
145
|
+
`messageActions` 默认针对持久 entry,调用时提供受保护的 `history.fork()`/`goBack()`;`target: "display"` 针对当前显示切片,可包含未持久化文本,但没有历史操作助手。两者提供的普通原文均排除 thinking/tool payload,不使用派生 `displayText`。可见性和可用性判断同步且无副作用,真正操作由调用上下文固定到原机器/会话;插件自己决定确认。
|
|
200
146
|
|
|
201
|
-
|
|
202
|
-
{
|
|
203
|
-
"plugins": {
|
|
204
|
-
"workspace-tasks": {
|
|
205
|
-
"enabled": true,
|
|
206
|
-
"settings": {}
|
|
207
|
-
},
|
|
208
|
-
"info": {
|
|
209
|
-
"enabled": false
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
147
|
+
### 会话与配套扩展
|
|
214
148
|
|
|
215
|
-
|
|
149
|
+
服务端插件可创建普通、可见的 Pi 会话,可带初始提示词,也可不带。配套 Pi 扩展可与后端交换消息,使用 Pi API 执行代理工作。
|
|
216
150
|
|
|
217
|
-
|
|
151
|
+
**会话一旦发布就属于用户。** 初始任务完成、浏览器关闭或发起插件销毁,都不会丢弃会话或停止用户后续工作;用户可以继续对话。
|
|
218
152
|
|
|
219
|
-
|
|
153
|
+
消息连接只针对该机器已托管的会话,不自动打开已保存会话。发送成功不能证明配套扩展已安装或工作成功,集成必须自己报告进度与结果。连接不重放启动消息;关闭连接不停止代理。
|
|
220
154
|
|
|
221
|
-
|
|
155
|
+
### 存储与后台工作
|
|
222
156
|
|
|
223
|
-
|
|
157
|
+
服务端插件获得独立于安装代码的持久化 `dataDirectory`,同一机器上该插件的各项目共享该目录。插件自己负责格式、迁移与清理,宿主不提供另一套存储 API。
|
|
224
158
|
|
|
225
|
-
|
|
159
|
+
请求和通道有界,可能失败、超时或断开。发送成功不保证送达,宿主不自动重试不确定工作。长任务应自行持久化状态,让 UI 重连时不重复启动任务。
|
|
226
160
|
|
|
227
|
-
|
|
228
|
-
**What it does:** adds a conditional **Updates** workspace tab with PI WEB update, restart, and installed-service guidance, plus a **Check for PI WEB Updates** action for the selected machine.
|
|
161
|
+
### 工作区提供器
|
|
229
162
|
|
|
230
|
-
|
|
163
|
+
提供器决定项目包含哪些工作区。主提供器可对它声明的项目替代内置 Git;Git 为后备,没有提供器认领时项目目录仍可作为工作区。
|
|
231
164
|
|
|
232
|
-
|
|
165
|
+
声明冲突会明确报错;认领后失败不会静默把所有权交给另一提供器。提供器也可声明工作区删除能力,删除作为可见终端操作运行。
|
|
233
166
|
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
"plugins": {
|
|
237
|
-
"updates": { "enabled": false }
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
```
|
|
167
|
+
工作区发现必须在宿主会话服务启动前就绪。包同时需要提供器和会话功能时,在同一个包中声明两个插件入口,无需拆分分发包。
|
|
241
168
|
|
|
242
|
-
|
|
169
|
+
<a id="install-and-manage"></a>
|
|
170
|
+
## 安装与管理
|
|
243
171
|
|
|
244
|
-
|
|
245
|
-
**Config file:** `.pi-web/tasks.json`
|
|
246
|
-
**What it does:** adds a **Tasks** workspace tab for running configured shell commands in dedicated PI WEB terminals.
|
|
172
|
+
在 **设置 → Pi 包** 安装、更新、移除 npm、git/URL 或本地来源的包;在 **设置 → PI WEB 插件** 启用/禁用集成,查看是否激活、是否需要重启。
|
|
247
173
|
|
|
248
|
-
|
|
174
|
+
可在[社区插件目录](https://pi-web.dev/community-plugins)搜索 npm 上的包,再复制 `npm:package-name` 到目标机器安装。目录由静态网页直接查询 npm,不是 PI WEB 服务端 catalog,也不会自动安装。社区包未经审查或背书,只安装可信作者的包;更多发布约定见目录的[分享插件](https://pi-web.dev/community-plugins#publish)。
|
|
249
175
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
```
|
|
176
|
+
| 变更 | 后续操作 |
|
|
177
|
+
| --- | --- |
|
|
178
|
+
| 安装或编辑纯浏览器插件 | 刷新浏览器 |
|
|
179
|
+
| 安装、更新、配置、启用、禁用服务端插件 | 重启目标机器会话守护进程,再刷新浏览器 |
|
|
180
|
+
| 改变普通 Pi 扩展、技能或提示词 | 在每个空闲会话执行 `/reload` |
|
|
181
|
+
| 改变注册模型提供器的扩展 | 遵循[提供器重启规则](https://pi-web.dev/config#pi-extension-provider-baseline) |
|
|
257
182
|
|
|
258
|
-
|
|
183
|
+
**重启会话守护进程可能中断活跃会话和终端。** 先检查活跃工作,从它托管的会话之外重启。原生 systemd 用户服务:
|
|
259
184
|
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
"version": 1,
|
|
263
|
-
"tasks": [
|
|
264
|
-
{
|
|
265
|
-
"id": "app.start",
|
|
266
|
-
"title": "Start app",
|
|
267
|
-
"group": "Development",
|
|
268
|
-
"description": "Start the local development server.",
|
|
269
|
-
"command": "npm run dev"
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
"id": "db.reset",
|
|
273
|
-
"title": "Reset DB",
|
|
274
|
-
"group": "Database",
|
|
275
|
-
"command": "go -C klingit-go run ./cli db reset",
|
|
276
|
-
"confirm": true
|
|
277
|
-
}
|
|
278
|
-
]
|
|
279
|
-
}
|
|
185
|
+
```sh
|
|
186
|
+
systemctl --user restart pi-web-sessiond
|
|
280
187
|
```
|
|
281
188
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
Task fields:
|
|
285
|
-
|
|
286
|
-
- `version`: must be `1`.
|
|
287
|
-
- `tasks`: array of task definitions.
|
|
288
|
-
- `id`: stable task id, matching `^[a-z][a-z0-9.-]*$`.
|
|
289
|
-
- `title`: button label.
|
|
290
|
-
- `command`: literal shell command sent to the terminal.
|
|
291
|
-
- `description`: optional explanatory text.
|
|
292
|
-
- `group`: optional group heading.
|
|
293
|
-
- `confirm`: optional boolean. When true, the browser asks before dispatching the command.
|
|
294
|
-
|
|
295
|
-
Review task configs before running them, especially in shared projects. Workspace Tasks runs trusted shell commands from your repositories.
|
|
189
|
+
浏览器刷新、Web/API 重启或 Pi `/reload` 不激活服务端插件变更。重启前“期望”与“实际”状态可能不同;浏览器入口与实际服务端不匹配时会暂缓提供,不运行不兼容代码。
|
|
296
190
|
|
|
297
|
-
|
|
191
|
+
多数插件默认启用,包可以默认关闭,设置可以覆盖。插件配置保存在普通 [PI WEB 配置](https://pi-web.dev/config),不是安装文件里。
|
|
298
192
|
|
|
299
|
-
|
|
300
|
-
**What it does:** adds a read-only **Relays** workspace tab for browsing the workspace's relays, plus an **Open Workspace Relays** action for the selected workspace that opens the same tab.
|
|
193
|
+
### 本地开发
|
|
301
194
|
|
|
302
|
-
|
|
195
|
+
代理可在任意目录开发包,再链接到本地插件目录:
|
|
303
196
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
Relays is enabled by default. To hide it, disable `relays` in **Settings → PI WEB plugins** or set:
|
|
309
|
-
|
|
310
|
-
```json
|
|
311
|
-
{
|
|
312
|
-
"plugins": {
|
|
313
|
-
"relays": { "enabled": false }
|
|
314
|
-
}
|
|
315
|
-
}
|
|
197
|
+
```sh
|
|
198
|
+
mkdir -p ~/.pi-web/plugins
|
|
199
|
+
ln -s /path/to/plugin-folder ~/.pi-web/plugins/my-plugin
|
|
316
200
|
```
|
|
317
201
|
|
|
318
|
-
|
|
202
|
+
设置 `PI_WEB_DATA_DIR` 时改用 `$PI_WEB_DATA_DIR/plugins`。无需重建 PI WEB,但包必须包含编译后的 JavaScript;宿主不编译任意已安装插件源码。
|
|
319
203
|
|
|
320
|
-
|
|
204
|
+
<a id="remote-machines"></a>
|
|
205
|
+
## 远端机器
|
|
321
206
|
|
|
322
|
-
|
|
207
|
+
安装与设置针对设置中选中的机器。远端服务端代码运行在远端,浏览器界面经网关显示。文件、终端、对等帮助方法保留机器作用域。机器专属插件使用该机器自身安装;便携的纯浏览器插件可复用网关副本。主题属于整个应用,远端主题贡献忽略。
|
|
323
208
|
|
|
324
|
-
|
|
325
|
-
pi-web-plugins/<plugin-package>/
|
|
326
|
-
```
|
|
209
|
+
此 API 迁移期间网关与目标一起升级,重启更新后的 Web/API 与相关会话守护进程,再刷新浏览器。混合版本会使远端插件(包括 Git)不可用,宿主不静默替换为网关后端。
|
|
327
210
|
|
|
328
|
-
|
|
211
|
+
<a id="included-tools-and-optional-packages"></a>
|
|
212
|
+
## 内置工具与可选包
|
|
329
213
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
214
|
+
- **终端**提供终端和命令运行,是普通启动的必需插件,仅紧急安全启动可跳过。
|
|
215
|
+
- **文件**提供文件浏览、预览、上传;禁用面板不移除其他插件的文件帮助方法。
|
|
216
|
+
- **Git**发现工作区并显示状态/差异;禁用后保留项目目录工作区,除非其他提供器认领。
|
|
217
|
+
- **Mermaid**默认手动模式,点击“渲染”预览 `mermaid` 围栏和 `.mmd`/`.mermaid` 文件。内置引擎在不透明来源、网络受阻的沙箱中本地运行,不发送源码给图表服务。交互链接和外部资源不可用。禁用后保持代码显示;纯浏览器插件只需刷新页面。
|
|
218
|
+
- **信息**作为应用级面板显示 PI WEB 状态与可复制诊断,无需先选择工作区。
|
|
219
|
+
- **更新**在需要时显示更新/重启建议,并提供手动检查。
|
|
220
|
+
- **工作区任务**将项目命令显示为可运行操作。
|
|
333
221
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
3. Installed Pi packages that expose PI WEB plugin metadata. Pi packages may be user or project scoped. Installing/removing/updating Pi packages is done from **Settings → Pi packages** (or Pi's package manager), not from the PI WEB plugin enable/disable list.
|
|
337
|
-
|
|
338
|
-
Remote machines expose their own manifests through the gateway at `/api/machines/<machine-id>/pi-web-plugins/manifest.json`. Those plugin modules are rewritten to gateway-scoped asset URLs and registered under machine-scoped runtime ids so duplicate plugin ids on different machines do not collide.
|
|
339
|
-
|
|
340
|
-
Plugin package directory names and plugin ids must be valid identifiers:
|
|
341
|
-
|
|
342
|
-
```text
|
|
343
|
-
^[a-z][a-z0-9.-]*$
|
|
344
|
-
```
|
|
222
|
+
### 工作区任务
|
|
345
223
|
|
|
346
|
-
|
|
224
|
+
在项目创建 `.pi-web/tasks.json`:
|
|
347
225
|
|
|
348
226
|
```json
|
|
349
227
|
{
|
|
350
|
-
"
|
|
351
|
-
"
|
|
352
|
-
"
|
|
353
|
-
|
|
354
|
-
{ "id": "dashboard", "module": "dist/dashboard.js", "machineSpecific": true }
|
|
355
|
-
]
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
Rules:
|
|
361
|
-
|
|
362
|
-
- `piWeb.plugins` must be an array of objects.
|
|
363
|
-
- Each entry must have an explicit `id` and `module`.
|
|
364
|
-
- `id` must match `^[a-z][a-z0-9.-]*$`.
|
|
365
|
-
- `module` must be a safe relative path inside the plugin package root.
|
|
366
|
-
- `machineSpecific` is optional and must be a boolean; omit it for the default portable gateway behavior.
|
|
367
|
-
- Duplicate plugin ids are not auto-renamed; later duplicates are skipped.
|
|
368
|
-
- Legacy shortcuts such as `piWeb.plugin`, string entries in `piWeb.plugins`, `piWeb.id` fallback ids, and no-`package.json` fallbacks are not supported.
|
|
369
|
-
|
|
370
|
-
### Manifest and assets
|
|
371
|
-
|
|
372
|
-
The manifest contains each discovered plugin module. Current PI WEB releases emit `module` as a leading application-root reference:
|
|
373
|
-
|
|
374
|
-
```json
|
|
375
|
-
{
|
|
376
|
-
"plugins": [
|
|
377
|
-
{
|
|
378
|
-
"id": "my-plugin",
|
|
379
|
-
"module": "/pi-web-plugins/my-plugin/pi-web-plugin.js?v=1234567890",
|
|
380
|
-
"source": "local",
|
|
381
|
-
"scope": "local",
|
|
382
|
-
"machineSpecific": false
|
|
383
|
-
}
|
|
228
|
+
"version": 1,
|
|
229
|
+
"tasks": [
|
|
230
|
+
{ "id": "app.start", "title": "启动应用", "command": "npm run dev" },
|
|
231
|
+
{ "id": "db.reset", "title": "重置数据库", "command": "npm run db:reset", "confirm": true }
|
|
384
232
|
]
|
|
385
233
|
}
|
|
386
234
|
```
|
|
387
235
|
|
|
388
|
-
|
|
236
|
+
从“任务”标签运行工作区终端命令。任务可带 `description`;尤其共享仓库中,运行前检查命令。禁用插件只隐藏标签,不修改项目文件。
|
|
389
237
|
|
|
390
|
-
|
|
238
|
+
### 中继
|
|
391
239
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
```text
|
|
395
|
-
/pi-web-plugins/<plugin-id>/<path-inside-plugin-root>
|
|
396
|
-
```
|
|
240
|
+
随包分发的 Relay 提供跨会话工作提示词和技能,并在只读“中继”标签展示 `.pi-web/relays/` 计划与进度,不从标签启动或编辑中继。
|
|
397
241
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
```js
|
|
401
|
-
const iconUrl = new URL("./assets/icon.svg", import.meta.url);
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
The final installed plugin package must contain `assets/icon.svg` at that path relative to the final built module. PI WEB serves files that already exist in the package; it does not copy a source `public/` directory or apply Vite-style public-directory semantics. Configure the plugin build and package contents to emit or copy the asset into its final module-relative location.
|
|
405
|
-
|
|
406
|
-
PI WEB prevents asset path traversal outside the plugin root. JavaScript, JSON, CSS, HTML, and SVG files get appropriate content types; unknown file types are served as octet-stream.
|
|
407
|
-
|
|
408
|
-
## Plugin module shape
|
|
409
|
-
|
|
410
|
-
The entry module must default-export a plugin object:
|
|
411
|
-
|
|
412
|
-
```ts
|
|
413
|
-
interface PiWebPlugin {
|
|
414
|
-
apiVersion: 2;
|
|
415
|
-
name: string;
|
|
416
|
-
activate: (context: PluginActivationContext) => PluginActivationResult;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
interface PluginActivationContext {
|
|
420
|
-
apiVersion: 2;
|
|
421
|
-
pluginId: string;
|
|
422
|
-
runtimePluginId?: string;
|
|
423
|
-
html: typeof import("lit").html;
|
|
424
|
-
svg: typeof import("lit").svg;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
interface PluginActivationResult {
|
|
428
|
-
contributions: PluginContributions;
|
|
429
|
-
}
|
|
430
|
-
```
|
|
242
|
+
普通模式在当前 agent 配置未安装时自动安装 Relay;从 **设置 → Pi 包** 移除会被记忆,不静默重装,可从“可用包”恢复。单独禁用中继插件只隐藏标签,不移除代理资源。管理嵌入的 `relay` 与 `relay-runner` 模板同步继续限定在授权工作区,不改变普通启动的技能文件。
|
|
431
243
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
```js
|
|
435
|
-
export default {
|
|
436
|
-
apiVersion: 2,
|
|
437
|
-
name: "My Plugin",
|
|
438
|
-
activate: ({ pluginId, html }) => ({
|
|
439
|
-
contributions: {
|
|
440
|
-
actions: [],
|
|
441
|
-
workspacePanels: [],
|
|
442
|
-
workspaceLabels: [],
|
|
443
|
-
},
|
|
444
|
-
}),
|
|
445
|
-
};
|
|
446
|
-
```
|
|
244
|
+
<a id="workflows"></a>
|
|
245
|
+
### 工作流(Workflows)
|
|
447
246
|
|
|
448
|
-
|
|
247
|
+
Workflows 随包提供 Pi 工作流提示词和工作树操作。普通 profile 缺少默认包时自动安装,用户移除会被记忆,可从“可用包”恢复;禁用浏览器插件不移除已安装的 Pi 提示词资源。
|
|
449
248
|
|
|
450
|
-
|
|
249
|
+
工作树操作选择 base 与用途后,由目标机器重验项目、工作区和 Git base 再派发;仅在普通模式及所需能力可用时提供。创建工作树、发布会话与打开页面是独立结果,派发结果不确定或导航失败时不自动重试,先查看目标机器已有结果,避免重复工作树。实现示例见 [Workflows 包](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/tree/main/pi-packages/workflows)。
|
|
451
250
|
|
|
452
|
-
|
|
251
|
+
### 试用 Captain's Log
|
|
453
252
|
|
|
454
|
-
|
|
455
|
-
<plugin-id>:<local-contribution-id>
|
|
456
|
-
```
|
|
253
|
+
Captain's Log 是可选示例,将会话最近的助手回复改写为海盗风格简报,演示浏览器面板、后端和 Pi 配套扩展协作。
|
|
457
254
|
|
|
458
|
-
|
|
255
|
+
1. 在目标机器的 **设置 → Pi 包 → 可用包** 安装 **船长日志**。
|
|
256
|
+
2. 在 **设置 → PI WEB 插件** 启用它。
|
|
257
|
+
3. 安全时重启目标机器会话守护进程,再刷新浏览器。
|
|
258
|
+
4. 选择会话,打开“船长日志”,点击“让船长来讲述”。
|
|
459
259
|
|
|
460
|
-
|
|
260
|
+
它随主包预构建发布,**默认不安装、不启用**,无需现场编译。读取源回复但不修改源会话,另建海盗会话;需要模型凭据,源文本会发给海盗会话的模型提供器,可能产生模型费用。已有结果会保存。守护进程重启后,可从“会话”打开已有海盗会话继续上下文。
|
|
461
261
|
|
|
462
|
-
|
|
262
|
+
详见[船长日志使用指南](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/blob/main/pi-packages/captains-log/docs/usage.md)。
|
|
463
263
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
actions?: PluginAction[];
|
|
467
|
-
workspacePanels?: WorkspacePanelContribution[];
|
|
468
|
-
workspaceLabels?: WorkspaceLabelContribution[];
|
|
469
|
-
}
|
|
470
|
-
```
|
|
264
|
+
<a id="pi-extension-dialogs"></a>
|
|
265
|
+
## Pi 扩展对话框
|
|
471
266
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
Actions appear in the action palette. They can inspect app state and call UI/runtime helpers.
|
|
475
|
-
|
|
476
|
-
```js
|
|
477
|
-
actions: [
|
|
478
|
-
{
|
|
479
|
-
id: "copy-diagnostics",
|
|
480
|
-
title: "Copy PI WEB Diagnostics",
|
|
481
|
-
description: "Copy version, installation, and status details for this machine",
|
|
482
|
-
group: "Info",
|
|
483
|
-
run: async (context) => {
|
|
484
|
-
const version = context.state.piWebStatus?.components.web.runtimeVersion ?? "unknown";
|
|
485
|
-
await navigator.clipboard.writeText(`PI WEB ${version}`);
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
]
|
|
489
|
-
```
|
|
267
|
+
Pi 扩展可请求确认、选择或文本输入;问题以内联方式展示,包括会话启动和工具等待阶段。刷新后仍可回答,多标签页最先回答生效。
|
|
490
268
|
|
|
491
|
-
|
|
269
|
+
有效期限取扩展超时和[宿主超时](https://pi-web.dev/config#extension-dialogs)中较早者。中止工作或替换运行时关闭相关问题。已回答卡片属于浏览器本地状态,不保证刷新后保留。新会话尚在创建时刷新可临时丢失卡片,但守护进程中的问题仍有期限。
|
|
492
270
|
|
|
493
|
-
|
|
494
|
-
interface PluginAction {
|
|
495
|
-
id: string;
|
|
496
|
-
title: string;
|
|
497
|
-
description?: string;
|
|
498
|
-
shortcut?: string;
|
|
499
|
-
group?: string;
|
|
500
|
-
enabled?: (context: PluginRuntimeContext) => boolean;
|
|
501
|
-
disabledReason?: (context: PluginRuntimeContext) => string | undefined;
|
|
502
|
-
run: (context: PluginRuntimeContext) => void | Promise<void>;
|
|
503
|
-
}
|
|
504
|
-
```
|
|
271
|
+
仅支持这三种对话框,不支持自定义编辑器或组件等其他 Pi UI;不要因为 `hasUI` 为真就假定所有 UI 可用。
|
|
505
272
|
|
|
506
|
-
|
|
273
|
+
<a id="agent-development"></a>
|
|
274
|
+
## 代理开发
|
|
507
275
|
|
|
508
|
-
|
|
276
|
+
给代理具体目标、数据来源及允许的动作:
|
|
509
277
|
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
prompt: PluginPromptEditor;
|
|
519
|
-
openActionPalette: () => void;
|
|
520
|
-
focusPrompt: () => void;
|
|
521
|
-
addProject: () => void | Promise<void>;
|
|
522
|
-
configureAuth: () => void | Promise<void>;
|
|
523
|
-
logoutAuth: () => void | Promise<void>;
|
|
524
|
-
selectWorkspaceTool: (tool: QualifiedContributionId) => void;
|
|
525
|
-
openTerminal: (options?: { terminalId?: string }) => void;
|
|
526
|
-
refreshFiles: () => void | Promise<void>;
|
|
527
|
-
refreshGit: () => void | Promise<void>;
|
|
528
|
-
checkForPiWebUpdates?: () => void | Promise<void>;
|
|
529
|
-
startSession: () => void | Promise<void>;
|
|
530
|
-
archiveSession: () => void | Promise<void>;
|
|
531
|
-
stopActiveWork: () => void | Promise<void>;
|
|
532
|
-
}
|
|
278
|
+
```text
|
|
279
|
+
为此项目创建 PI WEB 插件。
|
|
280
|
+
目标:<描述工作流和预期界面>。
|
|
281
|
+
先读 https://pi-web.dev/plugins.md,再按当前安装的 PI WEB 版本
|
|
282
|
+
查阅公开契约与示例。
|
|
283
|
+
只使用受支持的插件 API,不修改 PI WEB,不调用私有路由。
|
|
284
|
+
说明安装、权限或模型使用情况,以及刷新方式。
|
|
285
|
+
验证行为,包括失败和清理。
|
|
533
286
|
```
|
|
534
287
|
|
|
535
|
-
|
|
288
|
+
### 实现入口
|
|
536
289
|
|
|
537
|
-
|
|
538
|
-
- The stable state fields are `state.selectedMachine`, `state.selectedWorkspace`, `state.selectedSession`, and `state.piWebStatus`. `state.selectedMachine` identifies the currently selected machine. `state.piWebStatus` describes the currently selected machine's PI WEB runtime, or the gateway/local runtime when the local machine is selected.
|
|
539
|
-
- Other `state` fields may exist at runtime, but they are private PI WEB internals that may graduate into stable helpers, change shape, or disappear.
|
|
540
|
-
- `enabled` is evaluated when the action palette asks for actions.
|
|
541
|
-
- `selectWorkspaceTool()` expects a qualified panel id such as `my-plugin:workspace.info`.
|
|
542
|
-
- `openTerminal()` switches to the built-in terminal panel. Pass `{ terminalId }` to deep-link to a specific terminal.
|
|
543
|
-
- Only fields documented here and declared in `plugin-api.d.ts` are stable public browser plugin API. Runtime-only fields and private HTTP routes are not compatibility surfaces.
|
|
290
|
+
从符合目标的最小示例开始。以下源码链接跟随 `main`;对发布版开发时,**使用对应标签或已安装的公开声明**。
|
|
544
291
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
The `prompt` helper on `PluginRuntimeContext` and `WorkspacePanelContext` provides stable access to the chat prompt editor:
|
|
548
|
-
|
|
549
|
-
| Method | Description |
|
|
292
|
+
| 需求 | 入口 |
|
|
550
293
|
| --- | --- |
|
|
551
|
-
|
|
|
552
|
-
|
|
|
553
|
-
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
context.prompt.insertText("@file.txt");
|
|
560
|
-
|
|
561
|
-
// Read the current prompt and selection
|
|
562
|
-
const text = context.prompt.getText();
|
|
563
|
-
const selection = context.prompt.getSelection(); // { start, end, text } | null
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
Use `focusPrompt()` on `PluginRuntimeContext` to move focus to the prompt editor. Workspace panels can call `context.prompt.insertText()` from explicit user interactions such as button clicks; panel contexts target the currently selected session's mounted prompt editor.
|
|
567
|
-
|
|
568
|
-
#### Keyboard shortcuts
|
|
569
|
-
|
|
570
|
-
- App-level keyboard shortcuts must be attached to actions. PI WEB does not support standalone plugin keyboard commands; contribute an action first, then add a `shortcut` if it needs a keybinding.
|
|
571
|
-
- `shortcut` is the action's default keybinding. It is displayed in the action palette and handled by the global shortcut dispatcher when the action is enabled.
|
|
572
|
-
- Use modified shortcuts such as `mod+shift+p`; plain letter shortcuts are intentionally ignored so normal typing is never captured.
|
|
573
|
-
- Future PI WEB versions may allow users to override or disable action shortcuts by action id, so plugins should treat `shortcut` as a default rather than a guaranteed final binding.
|
|
574
|
-
- Choose shortcuts carefully to avoid conflicts. There is no user-facing shortcut override or conflict resolver yet.
|
|
575
|
-
- Local text input, terminal input, list navigation, and dialog keys such as Enter, Escape, and arrow keys do not need to be plugin actions unless they are app-level commands.
|
|
576
|
-
|
|
577
|
-
### Workspace panels
|
|
578
|
-
|
|
579
|
-
Workspace panels add tools next to built-in workspace tools. They render inside the workspace side panel on desktop and as mobile tabs on smaller screens.
|
|
580
|
-
|
|
581
|
-
```js
|
|
582
|
-
workspacePanels: [
|
|
583
|
-
{
|
|
584
|
-
id: "workspace.info",
|
|
585
|
-
title: "Info",
|
|
586
|
-
icon: svg`
|
|
587
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
588
|
-
<circle cx="12" cy="12" r="9"></circle>
|
|
589
|
-
<path d="M12 10v6"></path>
|
|
590
|
-
<path d="M12 7h.01"></path>
|
|
591
|
-
</svg>
|
|
592
|
-
`,
|
|
593
|
-
order: 100,
|
|
594
|
-
visible: ({ workspace }) => workspace.isGitRepo,
|
|
595
|
-
render: ({ workspace }) => html`
|
|
596
|
-
<section class="toolbar"><strong>Info</strong></section>
|
|
597
|
-
<section class="viewer">
|
|
598
|
-
<p class="muted">${workspace.label}</p>
|
|
599
|
-
<p class="muted">${workspace.path}</p>
|
|
600
|
-
</section>
|
|
601
|
-
`,
|
|
602
|
-
},
|
|
603
|
-
]
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
Panel type:
|
|
607
|
-
|
|
608
|
-
```ts
|
|
609
|
-
interface WorkspacePanelContribution {
|
|
610
|
-
id: string;
|
|
611
|
-
title: string;
|
|
612
|
-
icon?: TemplateResult;
|
|
613
|
-
order?: number;
|
|
614
|
-
visible?: (context: WorkspacePanelContext) => boolean;
|
|
615
|
-
badge?: (context: WorkspacePanelContext) => string | number | TemplateResult | undefined;
|
|
616
|
-
render: (context: WorkspacePanelContext) => TemplateResult;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
interface WorkspacePanelContext {
|
|
620
|
-
machine: PluginMachine;
|
|
621
|
-
workspace: Workspace;
|
|
622
|
-
state?: PluginRuntimeState;
|
|
623
|
-
files: {
|
|
624
|
-
readFile(path: string): Promise<FileContentResponse>;
|
|
625
|
-
listFiles(path: string): Promise<FileTreeResponse>;
|
|
626
|
-
writeFile(path: string, content: string | Uint8Array, options?: WriteWorkspaceFileOptions): Promise<WriteWorkspaceFileResponse>;
|
|
627
|
-
deleteFile(path: string): Promise<DeleteWorkspaceFileResponse>;
|
|
628
|
-
moveFile(fromPath: string, toPath: string, options?: MoveWorkspaceFileOptions): Promise<MoveWorkspaceFileResponse>;
|
|
629
|
-
};
|
|
630
|
-
prompt: PluginPromptEditor;
|
|
631
|
-
terminal: {
|
|
632
|
-
open(options?: { terminalId?: string }): void;
|
|
633
|
-
runCommand(input: {
|
|
634
|
-
title: string;
|
|
635
|
-
command: string;
|
|
636
|
-
metadata?: Record<string, string>;
|
|
637
|
-
open?: boolean;
|
|
638
|
-
}): Promise<TerminalCommandRunHandle>;
|
|
639
|
-
};
|
|
640
|
-
host: {
|
|
641
|
-
requestRender(): void;
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
`icon` is optional and is used in the compact mobile tab bar. Prefer an SVG rendered with the `svg` helper from `PluginActivationContext`; use `currentColor` so PI WEB themes can style it. If `icon` is omitted, mobile tabs fall back to initials from the panel title, or to the full title when initials collide.
|
|
647
|
-
|
|
648
|
-
`machine`, `workspace`, `files`, `prompt`, `terminal`, and `host` are documented as stable for panel callbacks. The `files` helper supports `readFile`, `listFiles`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files), [Listing workspace files](#listing-workspace-files), and [Writing workspace files](#writing-workspace-files). The `prompt` helper supports panel interactions that insert workspace context into the current prompt — see [Prompt editor API](#prompt-editor-api). Use `terminal.open()` to switch to the built-in terminal panel; pass `{ terminalId }` to deep-link to a specific terminal. Call `host.requestRender()` when async plugin-owned state changes should make PI WEB re-evaluate panel callbacks such as `badge`, `visible`, or `render`.
|
|
649
|
-
|
|
650
|
-
For compatibility, PI WEB still provides the old `context.openTerminal()` workspace-panel helper at runtime. It is deprecated, intentionally omitted from the public TypeScript declarations, and planned for removal in v2. Existing JavaScript plugins keep working, while typed plugins should migrate to `context.terminal.open()`.
|
|
651
|
-
|
|
652
|
-
Useful workspace and machine shapes:
|
|
653
|
-
|
|
654
|
-
```ts
|
|
655
|
-
interface PluginMachine {
|
|
656
|
-
id: string;
|
|
657
|
-
name: string;
|
|
658
|
-
kind: "local" | "remote";
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
interface Workspace {
|
|
662
|
-
id: string;
|
|
663
|
-
projectId: string;
|
|
664
|
-
path: string;
|
|
665
|
-
label: string;
|
|
666
|
-
branch?: string;
|
|
667
|
-
isMain: boolean;
|
|
668
|
-
isGitRepo: boolean;
|
|
669
|
-
isGitWorktree: boolean;
|
|
670
|
-
}
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
`machine.id` is included in panel contexts so plugins can keep caches machine-scoped. Do not infer the selected machine from global browser state.
|
|
674
|
-
|
|
675
|
-
Use existing classes such as `toolbar`, `viewer`, `empty`, and `muted` for panel content when possible. Do not assume a panel owns the whole page; keep layout contained.
|
|
294
|
+
| 浏览器贡献与帮助方法 | [plugin-api.ts](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/blob/main/src/plugin-api.ts),公开为 `@chainingintention/pi-web-cn/plugin-api` |
|
|
295
|
+
| 服务端生命周期、对等入口、提供器与宿主能力 | [server-plugin-api.ts](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/blob/main/src/server-plugin-api.ts),公开为 `@chainingintention/pi-web-cn/server-plugin-api` |
|
|
296
|
+
| 小型浏览器插件 | [信息](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/tree/main/pi-web-plugins/info) |
|
|
297
|
+
| 独立浏览器/服务端包 | [工作区提供器示例](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/tree/main/examples/workspace-provider-plugin) |
|
|
298
|
+
| 生产工作区提供器与配套 UI | [Git](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/tree/main/pi-web-plugins/git) |
|
|
299
|
+
| 已托管会话、实时更新与 Pi 配套扩展 | [Captain's Log](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/tree/main/pi-packages/captains-log) |
|
|
300
|
+
| 简单初始提示词工作流 | [工作区审查示例](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/tree/main/examples/session-bridge-plugin) |
|
|
301
|
+
| 发现规则与诊断 | [插件目录](https://github.com/nayuto-wakusei/pi-web-ChineseTranslation/blob/main/src/server/piWebPluginCatalog.ts) |
|
|
676
302
|
|
|
677
|
-
|
|
303
|
+
当前浏览器与服务端契约均为 **API v5**;宿主继续支持浏览器 **API v4** 和服务端 **API v3**,旧类型名兼容保留。catalog、作用域 backend 及 v5 贡献需使用对应 v5 入口,不将新功能直接塞进旧版本贡献。公开源码契约和已安装声明是签名、验证、限制与生命周期的依据。
|
|
678
304
|
|
|
679
|
-
|
|
305
|
+
- 在 `package.json` 的 `piWeb.plugins` 声明入口,参考独立示例的打包方式;同一包可含多个入口。
|
|
306
|
+
- 仅使用公开包入口,内部路由、服务及 `dist/**` 导入不是受支持 API。
|
|
307
|
+
- `browserRoot` 尽量窄,里面所有内容都对浏览器公开。包含所需依赖与资产,秘密放在之外。安装插件包限制为 **4,096** 项、**16 MiB**,不计 `.git`/`node_modules`。
|
|
308
|
+
- 机器/工作区操作使用宿主帮助方法,插件资产使用模块相对 URL,不硬编码应用路径。
|
|
309
|
+
- 面板没有重新挂载时也可能重复渲染。自己管理异步状态,组件生命周期清理连接、计时器与监听器。
|
|
310
|
+
- 工作区发现与会话支持功能分离,代理行为放在 Pi 配套扩展,而不是导入宿主内部模块。
|
|
680
311
|
|
|
681
|
-
|
|
312
|
+
<a id="trust-and-recovery"></a>
|
|
313
|
+
## 信任与恢复
|
|
682
314
|
|
|
683
|
-
|
|
684
|
-
workspaceLabels: [
|
|
685
|
-
{
|
|
686
|
-
id: "dev-url",
|
|
687
|
-
order: 10,
|
|
688
|
-
visible: ({ workspace }) => workspace.path.includes("my-app"),
|
|
689
|
-
items: () => [{
|
|
690
|
-
type: "link",
|
|
691
|
-
text: "web:5173",
|
|
692
|
-
href: "http://localhost:5173",
|
|
693
|
-
title: "Open dev server",
|
|
694
|
-
target: "_blank",
|
|
695
|
-
}],
|
|
696
|
-
},
|
|
697
|
-
]
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
Label contribution type:
|
|
701
|
-
|
|
702
|
-
```ts
|
|
703
|
-
interface WorkspaceLabelContribution {
|
|
704
|
-
id: string;
|
|
705
|
-
order?: number;
|
|
706
|
-
visible?: (context: WorkspaceLabelContext) => boolean;
|
|
707
|
-
items: (context: WorkspaceLabelContext) => WorkspaceLabelItem[];
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
interface WorkspaceLabelContext {
|
|
711
|
-
machine: PluginMachine;
|
|
712
|
-
workspace: Workspace;
|
|
713
|
-
state?: PluginRuntimeState;
|
|
714
|
-
files: {
|
|
715
|
-
readFile(path: string): Promise<FileContentResponse>;
|
|
716
|
-
listFiles(path: string): Promise<FileTreeResponse>;
|
|
717
|
-
writeFile(path: string, content: string | Uint8Array, options?: WriteWorkspaceFileOptions): Promise<WriteWorkspaceFileResponse>;
|
|
718
|
-
deleteFile(path: string): Promise<DeleteWorkspaceFileResponse>;
|
|
719
|
-
moveFile(fromPath: string, toPath: string, options?: MoveWorkspaceFileOptions): Promise<MoveWorkspaceFileResponse>;
|
|
720
|
-
};
|
|
721
|
-
host: {
|
|
722
|
-
requestRender(): void;
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
```
|
|
726
|
-
|
|
727
|
-
`machine`, `workspace`, `files`, and `host` are documented as stable for label callbacks. The `files` helper supports `readFile`, `listFiles`, `writeFile`, `deleteFile`, and `moveFile` — see [Reading workspace files](#reading-workspace-files), [Listing workspace files](#listing-workspace-files), and [Writing workspace files](#writing-workspace-files). Include `machine.id` in any label caches that depend on workspace data. Call `host.requestRender()` when async plugin-owned state changes should make PI WEB re-evaluate label `visible` or `items` callbacks.
|
|
315
|
+
**仅安装可信插件。** 浏览器入口在页面内运行;服务端入口在守护进程内使用其文件系统、环境及进程权限,没有独立沙箱。阻塞或故障服务端代码可影响同一守护进程所有会话;超时只能帮助配合取消的工作,不能停止阻塞代码。管理嵌入继续保留独立认证、授权资源、能力与审计边界,不向插件放开普通模式能力。
|
|
728
316
|
|
|
729
|
-
|
|
317
|
+
先在目标机器 **设置 → PI WEB 插件** 检查安装、启用、兼容和激活状态。浏览器失败看控制台,服务端失败在目标机器执行 `pi-web logs`。过期或需重启状态通常需要重启守护进程后刷新浏览器。
|
|
730
318
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
```js
|
|
734
|
-
{ type: "text", text: "staging", title: "Staging workspace" }
|
|
735
|
-
```
|
|
319
|
+
UI 无法恢复时,在目标机器直接运行:
|
|
736
320
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
href: "http://localhost:5173",
|
|
744
|
-
title: "Open dev server",
|
|
745
|
-
target: "_blank"
|
|
746
|
-
}
|
|
321
|
+
```sh
|
|
322
|
+
pi-web plugins disable <plugin-id> --restart
|
|
323
|
+
pi-web plugins safe-start show
|
|
324
|
+
pi-web plugins safe-start set bundled-only --restart
|
|
325
|
+
pi-web plugins safe-start set none --restart
|
|
326
|
+
pi-web plugins safe-start clear --restart
|
|
747
327
|
```
|
|
748
328
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
Use render items when a label contribution needs custom UI, async data, or caching. Render items should stay compact and inline.
|
|
754
|
-
|
|
755
|
-
```js
|
|
756
|
-
class MyWorkspaceBadge extends HTMLElement {
|
|
757
|
-
set workspace(value) {
|
|
758
|
-
this._workspace = value;
|
|
759
|
-
this.textContent = value?.branch === "main" ? "main" : "branch";
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
if (!customElements.get("my-workspace-badge")) {
|
|
764
|
-
customElements.define("my-workspace-badge", MyWorkspaceBadge);
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
export default {
|
|
768
|
-
apiVersion: 2,
|
|
769
|
-
name: "My Plugin",
|
|
770
|
-
activate: ({ html }) => ({
|
|
771
|
-
contributions: {
|
|
772
|
-
workspaceLabels: [
|
|
773
|
-
{
|
|
774
|
-
id: "badge",
|
|
775
|
-
order: 10,
|
|
776
|
-
items: ({ workspace }) => [{
|
|
777
|
-
type: "render",
|
|
778
|
-
render: () => html`<my-workspace-badge .workspace=${workspace}></my-workspace-badge>`,
|
|
779
|
-
}],
|
|
780
|
-
},
|
|
781
|
-
],
|
|
782
|
-
},
|
|
783
|
-
}),
|
|
784
|
-
};
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
## Reading workspace files
|
|
788
|
-
|
|
789
|
-
Workspace panels and workspace labels can read files through the documented `files` helper. PI WEB binds this helper to the callback's machine and workspace, so it works the same for local and federated machines.
|
|
790
|
-
|
|
791
|
-
```js
|
|
792
|
-
workspacePanels: [
|
|
793
|
-
{
|
|
794
|
-
id: "workspace.env",
|
|
795
|
-
title: "Env",
|
|
796
|
-
render: ({ files }) => html`
|
|
797
|
-
<my-env-viewer .files=${files}></my-env-viewer>
|
|
798
|
-
`,
|
|
799
|
-
},
|
|
800
|
-
]
|
|
801
|
-
|
|
802
|
-
class MyEnvViewer extends HTMLElement {
|
|
803
|
-
set files(value) {
|
|
804
|
-
this._files = value;
|
|
805
|
-
void this.load();
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
async load() {
|
|
809
|
-
try {
|
|
810
|
-
const file = await this._files.readFile(".env.example");
|
|
811
|
-
this.textContent = file.binary ? "Binary file" : file.content;
|
|
812
|
-
} catch (error) {
|
|
813
|
-
this.textContent = error instanceof Error ? error.message : String(error);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
```
|
|
818
|
-
|
|
819
|
-
Labels should use the same helper through a plugin-owned cache because `items()` itself must return synchronously:
|
|
820
|
-
|
|
821
|
-
```js
|
|
822
|
-
const envCache = new Map();
|
|
823
|
-
|
|
824
|
-
function envKey(machine, workspace) {
|
|
825
|
-
return `${machine.id}:${workspace.id}:.env.local`;
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
function loadEnvLabel(context) {
|
|
829
|
-
const key = envKey(context.machine, context.workspace);
|
|
830
|
-
const cached = envCache.get(key);
|
|
831
|
-
if (cached !== undefined) return cached;
|
|
832
|
-
|
|
833
|
-
const pending = { status: "loading", label: undefined };
|
|
834
|
-
envCache.set(key, pending);
|
|
835
|
-
context.files.readFile(".env.local")
|
|
836
|
-
.then((file) => {
|
|
837
|
-
pending.status = "ready";
|
|
838
|
-
pending.label = file.content.match(/^DEV_URL=(.+)$/m)?.[1];
|
|
839
|
-
context.host.requestRender();
|
|
840
|
-
})
|
|
841
|
-
.catch(() => {
|
|
842
|
-
pending.status = "missing";
|
|
843
|
-
context.host.requestRender();
|
|
844
|
-
});
|
|
845
|
-
return pending;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
workspaceLabels: [
|
|
849
|
-
{
|
|
850
|
-
id: "dev-url",
|
|
851
|
-
items: (context) => {
|
|
852
|
-
const cached = loadEnvLabel(context);
|
|
853
|
-
return cached.label === undefined ? [] : [{
|
|
854
|
-
type: "link",
|
|
855
|
-
text: cached.label,
|
|
856
|
-
href: cached.label,
|
|
857
|
-
target: "_blank",
|
|
858
|
-
}];
|
|
859
|
-
},
|
|
860
|
-
},
|
|
861
|
-
]
|
|
862
|
-
```
|
|
863
|
-
|
|
864
|
-
The file response includes fields such as `path`, `content`, `truncated`, and `binary`. Be careful with sensitive files such as `.env`: plugins are trusted browser code, and file contents are exposed to the plugin.
|
|
865
|
-
|
|
866
|
-
## Listing workspace files
|
|
867
|
-
|
|
868
|
-
`files.listFiles(path)` lists the entries of a workspace directory. Pass `""` for the workspace root. Like `readFile`, PI WEB binds the call to the callback's machine and workspace, so it works the same for local and federated machines.
|
|
869
|
-
|
|
870
|
-
```js
|
|
871
|
-
const listing = await context.files.listFiles("src");
|
|
872
|
-
for (const entry of listing.entries) {
|
|
873
|
-
// entry: { name, path, type: "file" | "directory" | "symlink", size?, modifiedAt? }
|
|
874
|
-
}
|
|
875
|
-
```
|
|
876
|
-
|
|
877
|
-
The listing response includes `path`, `entries`, `scannedAt`, and `truncated`. When `truncated` is true, the server cut the listing short, so treat the entries as partial.
|
|
878
|
-
|
|
879
|
-
`listFiles` rejects when the directory does not exist or cannot be read, matching `readFile` error behavior. When a directory is optional, catch the error and treat it as an empty listing:
|
|
880
|
-
|
|
881
|
-
```js
|
|
882
|
-
async function listSubdirectoryNames(context, path) {
|
|
883
|
-
try {
|
|
884
|
-
const listing = await context.files.listFiles(path);
|
|
885
|
-
return listing.entries.filter((entry) => entry.type === "directory").map((entry) => entry.name);
|
|
886
|
-
} catch {
|
|
887
|
-
return [];
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
```
|
|
891
|
-
|
|
892
|
-
## Writing, deleting, and moving workspace files
|
|
893
|
-
|
|
894
|
-
Workspace panels and workspace labels can write, delete, and move files through the documented `files` helper. Like `readFile`, PI WEB binds these helpers to the callback's machine and workspace, so they work the same for local and federated machines.
|
|
895
|
-
|
|
896
|
-
### Writing files
|
|
897
|
-
|
|
898
|
-
```js
|
|
899
|
-
workspacePanels: [
|
|
900
|
-
{
|
|
901
|
-
id: "workspace.generate",
|
|
902
|
-
title: "Generate",
|
|
903
|
-
render: ({ files }) => html`
|
|
904
|
-
<button @click=${async () => {
|
|
905
|
-
const result = await files.writeFile("output/result.txt", "Generated content\n");
|
|
906
|
-
console.log("Wrote", result.path, result.size, "bytes");
|
|
907
|
-
}}>Generate</button>
|
|
908
|
-
`,
|
|
909
|
-
},
|
|
910
|
-
]
|
|
911
|
-
```
|
|
912
|
-
|
|
913
|
-
### Binary writes
|
|
914
|
-
|
|
915
|
-
Pass a `Uint8Array` for binary content such as images:
|
|
916
|
-
|
|
917
|
-
```js
|
|
918
|
-
const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a]);
|
|
919
|
-
await files.writeFile("screenshots/thumb.png", png);
|
|
920
|
-
```
|
|
921
|
-
|
|
922
|
-
### Options
|
|
923
|
-
|
|
924
|
-
`files.writeFile` accepts an optional third argument:
|
|
925
|
-
|
|
926
|
-
- `createDirs` (default `true`): create intermediate directories, like `mkdir -p`.
|
|
927
|
-
- `overwrite` (default `true`): overwrite existing files. Set to `false` to throw if the file already exists.
|
|
928
|
-
|
|
929
|
-
```js
|
|
930
|
-
// Create only — throw if the file already exists
|
|
931
|
-
await files.writeFile("config/new-config.json", jsonContent, { overwrite: false });
|
|
932
|
-
```
|
|
933
|
-
|
|
934
|
-
### Deleting files
|
|
935
|
-
|
|
936
|
-
`files.deleteFile` removes a workspace file. It is idempotent: deleting a file that does not exist returns `{ existed: false }` instead of throwing.
|
|
937
|
-
|
|
938
|
-
```js
|
|
939
|
-
const result = await files.deleteFile("temp/cache.json");
|
|
940
|
-
console.log(result.existed ? "File deleted" : "File did not exist");
|
|
941
|
-
```
|
|
942
|
-
|
|
943
|
-
### Moving files
|
|
944
|
-
|
|
945
|
-
`files.moveFile` renames or moves a file within the workspace, like `mv`. The default is safe: it will not overwrite an existing target file.
|
|
946
|
-
|
|
947
|
-
```js
|
|
948
|
-
// Rename a file
|
|
949
|
-
await files.moveFile("old-name.txt", "new-name.txt");
|
|
950
|
-
|
|
951
|
-
// Move into a subdirectory (creates intermediate dirs by default)
|
|
952
|
-
await files.moveFile("file.txt", "archive/file.txt");
|
|
953
|
-
|
|
954
|
-
// Overwrite an existing target
|
|
955
|
-
await files.moveFile("incoming.txt", "current.txt", { overwrite: true });
|
|
956
|
-
|
|
957
|
-
// Move without creating intermediate directories
|
|
958
|
-
await files.moveFile("file.txt", "deep/nested/file.txt", { createDirs: false }); // throws if dirs don't exist
|
|
959
|
-
```
|
|
960
|
-
|
|
961
|
-
`files.moveFile` accepts an optional third argument:
|
|
962
|
-
|
|
963
|
-
- `createDirs` (default `true`): create intermediate directories for the target path.
|
|
964
|
-
- `overwrite` (default `false`): overwrite the target file if it exists. The default is safer than `writeFile` because moving is a more destructive operation.
|
|
965
|
-
|
|
966
|
-
### Error handling
|
|
967
|
-
|
|
968
|
-
All file mutations share the same safety layer:
|
|
969
|
-
|
|
970
|
-
- `overwrite: false` on `writeFile` or existing target on `moveFile` (default) throws if the file already exists.
|
|
971
|
-
- Path traversal (e.g., `../../etc/passwd`) is blocked by the workspace safety layer.
|
|
972
|
-
- Writing to or moving to a path that is a directory returns an error.
|
|
973
|
-
- Deleting a directory returns an error.
|
|
974
|
-
- Intermediate directory creation with `createDirs: false` fails if the parent directory does not exist.
|
|
975
|
-
|
|
976
|
-
After any mutation (`writeFile`, `deleteFile`, or `moveFile`), the File Explorer updates automatically. No explicit `refreshFiles()` call is needed from plugin code. For label and badge updates, call `context.host.requestRender()` if the UI should reflect the change.
|
|
977
|
-
|
|
978
|
-
### Security
|
|
979
|
-
|
|
980
|
-
Plugins are trusted browser code. File writes go through the same path safety validation as reads — paths are resolved and checked to stay inside the workspace root.
|
|
981
|
-
|
|
982
|
-
## Running workspace terminal commands
|
|
983
|
-
|
|
984
|
-
Workspace panels can start terminal commands through the documented `terminal` helper. Commands run in the current workspace on the panel's machine.
|
|
985
|
-
|
|
986
|
-
```js
|
|
987
|
-
render: ({ terminal }) => html`
|
|
988
|
-
<button @click=${() => terminal.runCommand({
|
|
989
|
-
title: "Build",
|
|
990
|
-
command: "npm run build",
|
|
991
|
-
open: true,
|
|
992
|
-
metadata: { "my-plugin.task": "build" },
|
|
993
|
-
})}>Build</button>
|
|
994
|
-
`
|
|
995
|
-
```
|
|
996
|
-
|
|
997
|
-
Review command strings carefully. They are trusted shell commands executed in the workspace terminal.
|
|
998
|
-
|
|
999
|
-
## Private and experimental PI WEB APIs
|
|
1000
|
-
|
|
1001
|
-
PI WEB's `/api/...` HTTP and WebSocket routes and runtime-only fields are private implementation details. They exist because plugins are trusted browser code, and because some capabilities may be evaluated there before they are designed as stable helpers.
|
|
1002
|
-
|
|
1003
|
-
The stable browser API is the documented helper surface and the type-only `@chainingintention/pi-web-cn/plugin-api` export. The stable server API is the separate type-only `@chainingintention/pi-web-cn/server-plugin-api` export. The former browser `plugin-api/unstable` entry is not part of API v2 and is no longer exported. Code that deliberately depends on another private runtime surface must keep that dependency local and expect to revisit it after PI WEB upgrades.
|
|
1004
|
-
|
|
1005
|
-
## Async data and caching
|
|
1006
|
-
|
|
1007
|
-
PI WEB does not provide a plugin cache/invalidation framework. Keep host callbacks cheap:
|
|
1008
|
-
|
|
1009
|
-
- simple contributions should be synchronous and cheap;
|
|
1010
|
-
- expensive or async work should live inside the plugin;
|
|
1011
|
-
- custom elements in `type: "render"` label items or panels are a good place to own async loading;
|
|
1012
|
-
- dedupe async reads/commands and avoid unbounded polling;
|
|
1013
|
-
- clean up intervals/event listeners in custom elements' `disconnectedCallback()`.
|
|
1014
|
-
|
|
1015
|
-
## Agent implementation checklist
|
|
1016
|
-
|
|
1017
|
-
If you are an AI agent building or editing a PI WEB plugin, follow this checklist:
|
|
1018
|
-
|
|
1019
|
-
1. Create or update a plugin folder with `package.json` and a JavaScript module such as `pi-web-plugin.js`.
|
|
1020
|
-
2. Use the single supported package metadata shape: `piWeb.plugins` array with `{ id, module, machineSpecific? }` entries.
|
|
1021
|
-
3. Default-export `{ apiVersion: 2, name, activate }` from a browser module. Server modules use server-plugin API v1.
|
|
1022
|
-
4. Return `{ contributions: { actions, workspacePanels, workspaceLabels } }` from `activate()`.
|
|
1023
|
-
5. Use ids matching `^[a-z][a-z0-9.-]*$`.
|
|
1024
|
-
6. Use the activation context's `html` function for Lit templates.
|
|
1025
|
-
7. Keep `activate()` synchronous and cheap; return contribution definitions only.
|
|
1026
|
-
8. Add actions for command-palette operations.
|
|
1027
|
-
9. Add workspace panels for larger workspace UI.
|
|
1028
|
-
10. Add workspace labels for compact inline metadata.
|
|
1029
|
-
11. Return arrays from workspace label `items()`; return an empty array to render nothing.
|
|
1030
|
-
12. Use documented context helpers first: `files`, `terminal`, `host.requestRender`, `workspace`, `machine`, `state.selectedWorkspace`, `state.selectedSession`, `state.piWebStatus`, and `prompt`.
|
|
1031
|
-
13. Do not fetch PI WEB `/api/...` endpoints directly unless you intentionally accept private API churn; prefer documented helpers such as the paired workspace `backend` bridge.
|
|
1032
|
-
14. Treat plugins as trusted code and avoid reading or displaying secrets unless intentional.
|
|
1033
|
-
15. After local edits, tell the user to hard reload the browser and check the console for plugin errors.
|
|
1034
|
-
|
|
1035
|
-
## Troubleshooting
|
|
1036
|
-
|
|
1037
|
-
Check discovery:
|
|
1038
|
-
|
|
1039
|
-
```bash
|
|
1040
|
-
curl http://127.0.0.1:8504/pi-web-plugins/manifest.json
|
|
1041
|
-
```
|
|
1042
|
-
|
|
1043
|
-
Check a plugin module:
|
|
1044
|
-
|
|
1045
|
-
```bash
|
|
1046
|
-
curl http://127.0.0.1:8504/pi-web-plugins/my-plugin/pi-web-plugin.js
|
|
1047
|
-
```
|
|
329
|
+
- **disable** 禁止指定可选插件在下次启动加载,拒绝禁用必需终端。
|
|
330
|
+
- **bundled-only** 排除外部服务端插件,保留内置工具及必需终端。
|
|
331
|
+
- **none** 不导入任何服务端插件;诊断和项目目录工作区仍可用,但终端与依赖终端的工作流不可用。
|
|
332
|
+
- **clear** 修复或移除故障包后恢复普通启动。
|
|
1048
333
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
- invalid plugin id or contribution id;
|
|
1052
|
-
- missing default export;
|
|
1053
|
-
- missing browser `apiVersion: 2`, `name`, or `activate` function;
|
|
1054
|
-
- missing `package.json` or incorrect `piWeb.plugins` metadata;
|
|
1055
|
-
- legacy shortcuts such as `piWeb.plugin`, string plugin entries, or no-`package.json` fallback;
|
|
1056
|
-
- duplicate plugin ids; later duplicates are skipped rather than renamed;
|
|
1057
|
-
- entry module path points outside the plugin root or file does not exist;
|
|
1058
|
-
- browser cache not refreshed after editing;
|
|
1059
|
-
- plugin directory is not under `~/.pi-web/plugins` or symlinked there;
|
|
1060
|
-
- plugin throws during module import, `activate()`, `visible()`, `enabled()`, `items()`, or `render()`; check the browser console.
|
|
334
|
+
安全启动持久保留直到清除。`--restart` 仅在识别到安全的已安装服务操作时重启,否则给出手动指引;配置在尝试重启前持久保存。命令离线编辑配置,不导入插件代码。自定义配置加 `--config /path/to/config.json`。有效 JSON 中不支持的 `serverPlugins.safeStart` 形状/值按 `none` 失败关闭;通过 `show`、`set` 或 `clear` 修复。重启前检查活跃工作。
|