pi-web-ui 0.117.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -2
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +147 -43
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +56 -444
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +160 -374
- package/dist/server/agent-service.js +875 -2978
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +26 -30
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +6 -213
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +3 -76
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +0 -82
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +0 -8
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +1 -3
- package/dist/server/device-center/collab-tool.js +0 -10
- package/dist/server/device-center/connector.js +21 -11
- package/dist/server/device-center/delivery-authority.js +0 -3
- package/dist/server/device-center/delivery-subject.js +0 -1
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +1 -27
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +0 -1
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +0 -27
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +0 -12
- package/dist/server/device-center/hub-deliveries.js +0 -1
- package/dist/server/device-center/hub-integration.js +0 -8
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +25 -7
- package/dist/server/device-center/hub-setup.js +0 -6
- package/dist/server/device-center/hub-transaction-log.js +0 -22
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +210 -86
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +0 -2
- package/dist/server/device-center/local-hub.js +0 -2
- package/dist/server/device-center/local-publication.js +1 -8
- package/dist/server/device-center/local-verification-job.js +0 -2
- package/dist/server/device-center/local-verification.js +0 -1
- package/dist/server/device-center/local.js +267 -39
- package/dist/server/device-center/main.js +14 -1
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +0 -31
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +0 -7
- package/dist/server/device-center/publish-intent.js +0 -5
- package/dist/server/device-center/relay.js +85 -30
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +1 -18
- package/dist/server/device-center/store.js +13 -33
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +0 -13
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +5 -88
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +0 -18
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +0 -50
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +0 -1
- package/dist/server/device-center/work-contract.js +1 -73
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +190 -32
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +69 -599
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +177 -680
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +3 -43
- package/dist/server/patch-remote-catalog.js +1 -32
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +9 -62
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +3 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +34 -1
- package/dist/server/quick-ask.js +123 -27
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +0 -26
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +3 -54
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +17 -25
- package/dist/server/session-open.js +2 -26
- package/dist/server/session-parser.js +1 -55
- package/dist/server/session-scan.js +1 -17
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +11 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +0 -42
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +1 -19
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +12 -172
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +26 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +1 -56
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +37 -1
- package/docs/device-center.md +28 -2
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +7 -3
- package/plugin-sdk/README.md +6 -0
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +0 -1
- package/plugin-sdk/client.mjs +1 -31
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +120 -119
- package/plugin-sdk/index.mjs +0 -6
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +0 -1
- package/plugin-sdk/testing.mjs +31 -86
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +1 -9
- package/themes/flow-ink.css +1 -10
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +1 -10
- package/themes/flow-zurich.css +1 -10
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BjNRIUIc.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-CQtstPGv.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-ChTW8o1m.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BX5rUuoI.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/{SCMPanel-DPAyY2sW.js → SCMPanel-CuEgzAlO.js} +2 -2
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-Dzi-eEyE.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/web/dist/assets/BgTasksModal-C0zuU8FE.js +0 -1
- package/web/dist/assets/CanvasStudio-BWvdmJ0M.js +0 -1579
- package/web/dist/assets/CanvasStudio-VQFjmTGq.js +0 -1579
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +0 -3
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +0 -1
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +0 -1
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +0 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +0 -2
- package/web/dist/assets/FilePreview-RGFQUbJo.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BM5wxiqU.js +0 -1
- package/web/dist/assets/GlobalSearchModal-DGv_WINq.js +0 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +0 -61
- package/web/dist/assets/GroupConversation-Dda69q-2.js +0 -61
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +0 -2
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-DY4SCfXg.js +0 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +0 -2
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +0 -32
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +0 -32
- package/web/dist/assets/TerminalPanel-D4By_RVc.js +0 -3
- package/web/dist/assets/TerminalPanel-lZw8-i3j.js +0 -3
- package/web/dist/assets/TuiOverlayModal-C3pAVuC8.js +0 -1
- package/web/dist/assets/TuiOverlayModal-D7_rEXcJ.js +0 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +0 -123
- package/web/dist/assets/canvas-client-BY6ojmle.js +0 -1
- package/web/dist/assets/desktop-CV6KKp9R.js +0 -1
- package/web/dist/assets/index-BawF7ZP5.js +0 -397
- package/web/dist/assets/index-BoGCoq5X.js +0 -397
- package/web/dist/assets/index-CVW9FoY2.css +0 -1
- package/web/dist/assets/plugin-host-Dn8Dd6SC.js +0 -1
- package/web/dist/assets/theme-D_bihpdN.js +0 -1
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI commit-message generation — pure prompt assembly + response cleanup.
|
|
3
|
-
*
|
|
4
|
-
* The git gathering lives in scm.ts (scmCommitContext); the one-off model
|
|
5
|
-
* call lives in agent-service (ClientSession.scmGenCommitMessage, same
|
|
6
|
-
* completeSimple path as the vision bridge). This module owns everything
|
|
7
|
-
* deterministic so it stays unit-testable:
|
|
8
|
-
*
|
|
9
|
-
* buildCommitMsgInput(ctx, fallbackLang) → user message (null = nothing
|
|
10
|
-
* to commit — the caller turns that into a friendly error)
|
|
11
|
-
* COMMITMSG_SYSTEM_PROMPT → system prompt
|
|
12
|
-
* sanitizeCommitMessage(raw) → the single-line subject that
|
|
13
|
-
* ends up in the commit input (models are told to emit exactly that, but
|
|
14
|
-
* fences/labels/quotes/newlines are stripped defensively)
|
|
15
|
-
*
|
|
16
|
-
* Language policy: the generated message follows the repository's own commit
|
|
17
|
-
* subjects (style AND language — a repo writing "feat(xxx): 描述" keeps
|
|
18
|
-
* getting that). Only a repo with no commits yet falls back to the UI
|
|
19
|
-
* language passed as fallbackLang.
|
|
20
|
-
*/
|
|
21
1
|
import { isNotRepoError, scmCommitContext } from "./scm.js";
|
|
22
2
|
import { pick } from "./i18n.js";
|
|
23
|
-
/** SCM AI 提交信息生成超时时间(毫秒) */
|
|
24
3
|
export const SCM_COMMITMSG_TIMEOUT_MS = 60_000;
|
|
25
|
-
/** Hard cap for the generated subject — the commit input is single-line and
|
|
26
|
-
* this keeps a chatty model from filling the whole header row. */
|
|
27
4
|
export const MAX_COMMITMSG_LEN = 200;
|
|
28
|
-
/** File list cap inside the prompt (porcelain lines); the diffs carry the
|
|
29
|
-
* details, the list is orientation only. */
|
|
30
5
|
const MAX_FILE_LINES = 200;
|
|
31
6
|
export const COMMITMSG_SYSTEM_PROMPT = `You write git commit messages. You receive the pending changes of a repository and output exactly one commit message: a single subject line.
|
|
32
7
|
|
|
@@ -39,13 +14,6 @@ Rules:
|
|
|
39
14
|
6. If the repository has no commits yet, write the message in the language stated in the request.
|
|
40
15
|
|
|
41
16
|
Output ONLY the subject line.`;
|
|
42
|
-
/**
|
|
43
|
-
* Assemble the effective system prompt from the settings-panel prefs (same
|
|
44
|
-
* contract as the vision bridge's buildVisionBridgePrompt): mode "append"
|
|
45
|
-
* puts custom text after the built-in default (empty custom = pure default);
|
|
46
|
-
* mode "replace" swaps in the custom text, but an empty custom still falls
|
|
47
|
-
* back to the default (never send an empty system prompt).
|
|
48
|
-
*/
|
|
49
17
|
export function buildCommitMsgPrompt(mode, custom) {
|
|
50
18
|
const text = custom?.trim() ?? "";
|
|
51
19
|
if (mode === "replace" && text)
|
|
@@ -54,17 +22,11 @@ export function buildCommitMsgPrompt(mode, custom) {
|
|
|
54
22
|
return `${COMMITMSG_SYSTEM_PROMPT}\n\n${text}`;
|
|
55
23
|
return COMMITMSG_SYSTEM_PROMPT;
|
|
56
24
|
}
|
|
57
|
-
/** "path → [add,del]" map → compact "+12/-3 path" lines (sorted by path). */
|
|
58
25
|
function formatNumStat(stat) {
|
|
59
26
|
return Object.keys(stat)
|
|
60
27
|
.sort()
|
|
61
28
|
.map((p) => `+${stat[p][0]}/-${stat[p][1]} ${p}`);
|
|
62
29
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Assemble the user message from the gathered context. Returns null when
|
|
65
|
-
* there is nothing to describe (no staged/unstaged diff and no untracked
|
|
66
|
-
* files) — the caller replies "no changes" instead of calling the model.
|
|
67
|
-
*/
|
|
68
30
|
export function buildCommitMsgInput(ctx, fallbackLang) {
|
|
69
31
|
const parts = [];
|
|
70
32
|
if (ctx.subjects.length > 0) {
|
|
@@ -100,8 +62,6 @@ export function buildCommitMsgInput(ctx, fallbackLang) {
|
|
|
100
62
|
}
|
|
101
63
|
const untracked = ctx.files.filter((f) => f.x === "?" && f.y === "?");
|
|
102
64
|
if (untracked.length > 0 && !ctx.stagedPatch.trim()) {
|
|
103
|
-
// Untracked content never appears in `git diff` — name the files so
|
|
104
|
-
// the model knows they are part of the change set (commit-all flow).
|
|
105
65
|
parts.push(`Untracked files (new, content not shown): ${untracked
|
|
106
66
|
.map((f) => f.path)
|
|
107
67
|
.join(", ")
|
|
@@ -111,26 +71,17 @@ export function buildCommitMsgInput(ctx, fallbackLang) {
|
|
|
111
71
|
return null;
|
|
112
72
|
return parts.join("\n");
|
|
113
73
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Normalize whatever the model emitted into the single-line subject that goes
|
|
116
|
-
* into the commit input: drop fences, labels and wrapping quotes, keep only
|
|
117
|
-
* the first non-empty line, collapse whitespace, cap the length.
|
|
118
|
-
*/
|
|
119
74
|
export function sanitizeCommitMessage(raw) {
|
|
120
75
|
let text = raw.trim();
|
|
121
|
-
// ```…``` fences wrapping the whole answer.
|
|
122
76
|
const fence = text.match(/^```[a-zA-Z]*\s*\n?([\s\S]*?)\n?```$/);
|
|
123
77
|
if (fence)
|
|
124
78
|
text = fence[1].trim();
|
|
125
|
-
// Leading labels some models add despite the instructions.
|
|
126
79
|
text = text.replace(/^(commit(\s+message)?|subject|提交信息|提交消息|提交说明)\s*[::]\s*/i, "");
|
|
127
|
-
// First non-empty line only — the input field is single-line by design.
|
|
128
80
|
const firstLine = text
|
|
129
81
|
.split("\n")
|
|
130
82
|
.map((l) => l.trim())
|
|
131
83
|
.find((l) => l.length > 0) ?? "";
|
|
132
84
|
let out = firstLine.replace(/\s+/g, " ").trim();
|
|
133
|
-
// Matching wrapping quotes.
|
|
134
85
|
if (out.length >= 2) {
|
|
135
86
|
const a = out[0];
|
|
136
87
|
const b = out[out.length - 1];
|
|
@@ -142,10 +93,6 @@ export function sanitizeCommitMessage(raw) {
|
|
|
142
93
|
out = `${out.slice(0, MAX_COMMITMSG_LEN - 1).trimEnd()}…`;
|
|
143
94
|
return out;
|
|
144
95
|
}
|
|
145
|
-
/**
|
|
146
|
-
* 完整的 SCM AI 提交信息生成逻辑封装:
|
|
147
|
-
* 提取 git 差异上下文 -> 组装 prompt -> 调用模型 completeSimple -> 结果清洗校验
|
|
148
|
-
*/
|
|
149
96
|
export async function generateScmCommitMessage(opts) {
|
|
150
97
|
const { cwd, model, runtime, lang, promptMode = "append", customPrompt = "", timeoutMs = SCM_COMMITMSG_TIMEOUT_MS, } = opts;
|
|
151
98
|
try {
|
package/dist/server/scm.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read-only git queries backing the source-control panel.
|
|
3
|
-
*
|
|
4
|
-
* Replaces the old hidden-PTY + text-scraping approach: every query is a
|
|
5
|
-
* plain `execFile("git", …)` — no shell, no prompts, no echo, no sentinel
|
|
6
|
-
* parsing. Output is parsed into structured JSON on the server; the client
|
|
7
|
-
* just renders it.
|
|
8
|
-
*/
|
|
9
1
|
import { execFile } from "node:child_process";
|
|
10
2
|
import { promisify } from "node:util";
|
|
11
3
|
import { pick } from "./i18n.js";
|
|
12
4
|
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, shellQuotePosix } from "./remote-ssh-service.js";
|
|
13
5
|
const exec = promisify(execFile);
|
|
14
|
-
/** Per-command timeout / output cap — a stuck repo must not hang the panel. */
|
|
15
6
|
const GIT_TIMEOUT_MS = 15_000;
|
|
16
7
|
const MAX_GIT_OUTPUT = 16 * 1024 * 1024;
|
|
17
|
-
/** Run one git command; throws Error with a readable message on failure. */
|
|
18
8
|
async function git(cwd, args, lang) {
|
|
19
9
|
const l = lang?.() ?? "en";
|
|
20
10
|
if (isRemoteWorkspaceUri(cwd)) {
|
|
@@ -49,8 +39,6 @@ async function git(cwd, args, lang) {
|
|
|
49
39
|
throw new Error(detail || pick(l, "git 命令失败", "git command failed", "scm.git.failed"));
|
|
50
40
|
}
|
|
51
41
|
}
|
|
52
|
-
/** Absolute path of the repo's git dir (handles worktrees/submodules), or
|
|
53
|
-
* null when cwd isn't inside a repository. */
|
|
54
42
|
export async function gitDirOf(cwd) {
|
|
55
43
|
if (isRemoteWorkspaceUri(cwd))
|
|
56
44
|
return null;
|
|
@@ -66,15 +54,9 @@ export async function gitDirOf(cwd) {
|
|
|
66
54
|
return null;
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
|
-
/** True when the error is "this directory isn't a git repository". */
|
|
70
57
|
export function isNotRepoError(err) {
|
|
71
58
|
return /not a git repository/i.test(err instanceof Error ? err.message : String(err));
|
|
72
59
|
}
|
|
73
|
-
/* ------------------------------------------------------------------ */
|
|
74
|
-
/* parsers */
|
|
75
|
-
/* ------------------------------------------------------------------ */
|
|
76
|
-
/** Undo git's C-style quoting for unusual file names ("a\tb" → a<TAB>b).
|
|
77
|
-
* core.quotepath=false already handles non-ASCII; this covers control chars. */
|
|
78
60
|
function unquotePath(s) {
|
|
79
61
|
if (!s.startsWith('"'))
|
|
80
62
|
return s;
|
|
@@ -163,7 +145,7 @@ function parseStatusFiles(text) {
|
|
|
163
145
|
continue;
|
|
164
146
|
if (line.length >= 3) {
|
|
165
147
|
let path = line.slice(3);
|
|
166
|
-
const arrow = path.indexOf(" -> ");
|
|
148
|
+
const arrow = path.indexOf(" -> ");
|
|
167
149
|
if (arrow >= 0)
|
|
168
150
|
path = path.slice(arrow + 4);
|
|
169
151
|
out.push({ path: unquotePath(path), x: line[0], y: line[1] });
|
|
@@ -184,7 +166,6 @@ function parseBranches(text) {
|
|
|
184
166
|
}
|
|
185
167
|
else if (ref.startsWith("refs/remotes/")) {
|
|
186
168
|
const short = ref.slice("refs/remotes/".length);
|
|
187
|
-
// Skip the "origin/HEAD -> origin/main" symlink.
|
|
188
169
|
if (short.endsWith("/HEAD"))
|
|
189
170
|
continue;
|
|
190
171
|
const slash = short.indexOf("/");
|
|
@@ -197,20 +178,17 @@ function parseBranches(text) {
|
|
|
197
178
|
}
|
|
198
179
|
return out;
|
|
199
180
|
}
|
|
200
|
-
/** Parse `git log --graph --pretty=format:%H%x09…` preserving graph prefixes. */
|
|
201
181
|
function parseCommitHistory(text) {
|
|
202
182
|
const out = [];
|
|
203
183
|
for (const line of text.split("\n")) {
|
|
204
184
|
const tab = line.indexOf("\t");
|
|
205
185
|
if (tab < 0)
|
|
206
|
-
continue;
|
|
186
|
+
continue;
|
|
207
187
|
const prefixAndHash = line.slice(0, tab);
|
|
208
188
|
const match = prefixAndHash.match(/([0-9a-f]{7,40})$/i);
|
|
209
189
|
if (!match || match.index === undefined)
|
|
210
190
|
continue;
|
|
211
191
|
const fields = line.slice(tab + 1).split("\t");
|
|
212
|
-
// An empty decoration field removes the final tab — four fields is a
|
|
213
|
-
// valid undecorated commit.
|
|
214
192
|
if (fields.length < 4)
|
|
215
193
|
continue;
|
|
216
194
|
out.push({
|
|
@@ -225,7 +203,6 @@ function parseCommitHistory(text) {
|
|
|
225
203
|
}
|
|
226
204
|
return out;
|
|
227
205
|
}
|
|
228
|
-
/** Parse `git diff --numstat` output: "12\t3\tpath" → { path: [add, del] }. */
|
|
229
206
|
function parseNumStat(text) {
|
|
230
207
|
const stats = {};
|
|
231
208
|
for (const line of text.split("\n")) {
|
|
@@ -238,7 +215,7 @@ function parseNumStat(text) {
|
|
|
238
215
|
let add = Number(line.slice(0, tab1));
|
|
239
216
|
let del = Number(line.slice(tab1 + 1, tab2));
|
|
240
217
|
if (!Number.isFinite(add))
|
|
241
|
-
add = 0;
|
|
218
|
+
add = 0;
|
|
242
219
|
if (!Number.isFinite(del))
|
|
243
220
|
del = 0;
|
|
244
221
|
const path = unquotePath(line.slice(tab2 + 1).trim());
|
|
@@ -247,9 +224,6 @@ function parseNumStat(text) {
|
|
|
247
224
|
}
|
|
248
225
|
return stats;
|
|
249
226
|
}
|
|
250
|
-
/* ------------------------------------------------------------------ */
|
|
251
|
-
/* queries */
|
|
252
|
-
/* ------------------------------------------------------------------ */
|
|
253
227
|
const HISTORY_ARGS = [
|
|
254
228
|
"log",
|
|
255
229
|
"--all",
|
|
@@ -260,12 +234,9 @@ const HISTORY_ARGS = [
|
|
|
260
234
|
"-n",
|
|
261
235
|
"120",
|
|
262
236
|
];
|
|
263
|
-
/** Commit graph for the history tab — fetched lazily so the common
|
|
264
|
-
* "changes" view never pays for it on huge repos. */
|
|
265
237
|
export async function scmHistory(cwd, lang) {
|
|
266
238
|
return parseCommitHistory(await git(cwd, HISTORY_ARGS, lang));
|
|
267
239
|
}
|
|
268
|
-
/** Status refresh payload (status + branches + numstat) — parallel. */
|
|
269
240
|
export async function scmStatus(cwd, lang) {
|
|
270
241
|
const [statusText, branchText, statText, cachedStatText] = await Promise.all([
|
|
271
242
|
git(cwd, ["status", "--porcelain=v1", "-b", "--find-renames"], lang),
|
|
@@ -277,7 +248,6 @@ export async function scmStatus(cwd, lang) {
|
|
|
277
248
|
.split("\n")
|
|
278
249
|
.find((l) => l.startsWith("## "))
|
|
279
250
|
?.slice(3) ?? "");
|
|
280
|
-
// Worktree + staged line counts, merged per path.
|
|
281
251
|
const merged = {};
|
|
282
252
|
for (const [path, pair] of Object.entries(parseNumStat(statText))) {
|
|
283
253
|
merged[path] = pair;
|
|
@@ -299,7 +269,6 @@ export async function scmStatus(cwd, lang) {
|
|
|
299
269
|
stats: merged,
|
|
300
270
|
};
|
|
301
271
|
}
|
|
302
|
-
/** Staged + worktree diffs for one file (empty strings when no diff). */
|
|
303
272
|
export async function scmFileDiff(cwd, path, lang) {
|
|
304
273
|
const [staged, worktree] = await Promise.all([
|
|
305
274
|
git(cwd, ["diff", "--cached", "--no-color", "--no-ext-diff", "--", path], lang).catch(() => ""),
|
|
@@ -307,27 +276,15 @@ export async function scmFileDiff(cwd, path, lang) {
|
|
|
307
276
|
]);
|
|
308
277
|
return { staged, worktree };
|
|
309
278
|
}
|
|
310
|
-
/** Full patch of one commit (`git show`). */
|
|
311
279
|
export async function scmCommitDetail(cwd, hash, lang) {
|
|
312
280
|
return git(cwd, ["show", "--no-color", "--no-ext-diff", "--find-renames", "--format=fuller", "--stat", "--patch", hash], lang);
|
|
313
281
|
}
|
|
314
|
-
/* ------------------------------------------------------------------ */
|
|
315
|
-
/* AI commit-message context */
|
|
316
|
-
/* ------------------------------------------------------------------ */
|
|
317
|
-
/** Cap per patch (staged / worktree) fed to the commit-message prompt —
|
|
318
|
-
* enough for the model to see what most commits are about without letting
|
|
319
|
-
* one huge repo blow up the one-off completion request. */
|
|
320
282
|
const MAX_COMMITMSG_PATCH_CHARS = 12_000;
|
|
321
|
-
/** Cap one patch at MAX_COMMITMSG_PATCH_CHARS, keeping the head (early files
|
|
322
|
-
* matter most for a commit message) and marking the cut. */
|
|
323
283
|
function capPatch(text) {
|
|
324
284
|
if (text.length <= MAX_COMMITMSG_PATCH_CHARS)
|
|
325
285
|
return text;
|
|
326
286
|
return `${text.slice(0, MAX_COMMITMSG_PATCH_CHARS)}\n… (diff truncated)`;
|
|
327
287
|
}
|
|
328
|
-
/** Gather staged/worktree patches, numstats, status and recent subjects for
|
|
329
|
-
* the AI commit-message generator. Throws the usual git errors (including
|
|
330
|
-
* "not a git repository") — the caller maps them to friendly replies. */
|
|
331
288
|
export async function scmCommitContext(cwd, lang) {
|
|
332
289
|
const [stagedPatch, worktreePatch, stagedStatText, worktreeStatText, statusText, subjectText] = await Promise.all([
|
|
333
290
|
git(cwd, ["diff", "--cached", "--no-color", "--no-ext-diff", "--find-renames"], lang).catch(() => ""),
|
|
@@ -335,8 +292,6 @@ export async function scmCommitContext(cwd, lang) {
|
|
|
335
292
|
git(cwd, ["diff", "--cached", "--numstat"], lang).catch(() => ""),
|
|
336
293
|
git(cwd, ["diff", "--numstat"], lang).catch(() => ""),
|
|
337
294
|
git(cwd, ["status", "--porcelain=v1", "--find-renames"], lang),
|
|
338
|
-
// Empty repos (no commits yet) make `git log` fail — that's a valid
|
|
339
|
-
// "no style reference" answer, not an error worth failing the request.
|
|
340
295
|
git(cwd, ["log", "-n", "15", "--pretty=format:%s"], lang).then((s) => s, () => ""),
|
|
341
296
|
]);
|
|
342
297
|
const subjects = subjectText
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sdk-builtin-extensions.ts — 动态装配与筛选 @earendil-works/pi-coding-agent SDK 内置扩展。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 1. 继承 SDK 原生内置扩展(如 builtin:llama.cpp、builtin:codemode、builtin:tool-search);
|
|
6
|
-
* 2. 精准隔离 SDK 内置 MCP 扩展(pi-web-ui 统一使用专属 McpBridge 管理,防止 MCP 进程双重派生);
|
|
7
|
-
* 3. 严格保留 builtin: true 与 replaceable 等元数据,确保 SDK DefaultResourceLoader 正确建立
|
|
8
|
-
* builtin:<name> 字典索引(解决 Issue #755:GUI 无法发现和使用 llama.cpp 本地模型的问题);
|
|
9
|
-
* 4. 遵循与 resolve-global-sdk / patch-remote-catalog 相同的事实源,兼容全局 SDK 与自带副本。
|
|
10
|
-
*/
|
|
11
1
|
import { existsSync } from "node:fs";
|
|
12
2
|
import { dirname, join } from "node:path";
|
|
13
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
4
|
import { createCodemodeExtension, createToolSearchExtension } from "@earendil-works/pi-coding-agent";
|
|
15
5
|
let cachedEntries = null;
|
|
16
|
-
/**
|
|
17
|
-
* 解析当前生效 SDK 的 extensions/index.js 文件绝对路径。
|
|
18
|
-
*/
|
|
19
6
|
export function resolveSdkExtensionsIndexPath() {
|
|
20
7
|
try {
|
|
21
8
|
const entry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
|
|
@@ -23,16 +10,9 @@ export function resolveSdkExtensionsIndexPath() {
|
|
|
23
10
|
if (existsSync(candidate))
|
|
24
11
|
return candidate;
|
|
25
12
|
}
|
|
26
|
-
catch {
|
|
27
|
-
/* ignore resolve failure */
|
|
28
|
-
}
|
|
13
|
+
catch { }
|
|
29
14
|
return null;
|
|
30
15
|
}
|
|
31
|
-
/**
|
|
32
|
-
* 获取经过宿主门禁过滤后的 SDK 内置扩展工厂列表(带内存缓存)。
|
|
33
|
-
* - 包含:llama.cpp、codemode、tool-search(以及未来 SDK 官方新增的提供商扩展)
|
|
34
|
-
* - 剔除:mcp(由 WebUI 独立 McpBridge 接管)
|
|
35
|
-
*/
|
|
36
16
|
export async function getSdkBuiltinExtensionFactories() {
|
|
37
17
|
if (cachedEntries)
|
|
38
18
|
return cachedEntries;
|
|
@@ -43,7 +23,6 @@ export async function getSdkBuiltinExtensionFactories() {
|
|
|
43
23
|
const mod = (await import(pathToFileURL(indexPath).href));
|
|
44
24
|
if (Array.isArray(mod.builtInExtensions)) {
|
|
45
25
|
for (const ext of mod.builtInExtensions) {
|
|
46
|
-
// 严格屏蔽 SDK 内置 mcp:避免与宿主 McpBridge 重复连接和拉起 stdio 进程
|
|
47
26
|
if (ext.name === "mcp")
|
|
48
27
|
continue;
|
|
49
28
|
factories.push({
|
|
@@ -56,11 +35,8 @@ export async function getSdkBuiltinExtensionFactories() {
|
|
|
56
35
|
}
|
|
57
36
|
}
|
|
58
37
|
}
|
|
59
|
-
catch {
|
|
60
|
-
/* dynamic load failed, fall back below */
|
|
61
|
-
}
|
|
38
|
+
catch { }
|
|
62
39
|
}
|
|
63
|
-
// 兜底回退:若未成功加载任何工厂,保证核心基础设施扩展可用
|
|
64
40
|
if (factories.length === 0) {
|
|
65
41
|
factories.push({
|
|
66
42
|
name: "codemode",
|
|
@@ -79,7 +55,4 @@ export async function getSdkBuiltinExtensionFactories() {
|
|
|
79
55
|
cachedEntries = factories;
|
|
80
56
|
return factories;
|
|
81
57
|
}
|
|
82
|
-
/**
|
|
83
|
-
* 宿主层需禁用的 SDK 内置扩展名称清单(双保险,传给 disabledBuiltinExtensions)。
|
|
84
|
-
*/
|
|
85
58
|
export const SDK_DISABLED_BUILTIN_EXTENSIONS = ["mcp"];
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sdk-origin — 本进程实际加载的是哪一份 pi SDK,以及被它遮蔽的副本(issue #260)。
|
|
3
|
-
*
|
|
4
|
-
* 背景:npm 全局安装会把依赖**嵌在** `<npm root -g>/pi-web-ui/node_modules/`(不 hoist,
|
|
5
|
-
* 实测),而 Node 的解析顺序是「嵌套优先于祖先」。于是用户按更新面板/README 的提示
|
|
6
|
-
* `npm i -g @earendil-works/pi-coding-agent@latest` 升级全局那份时,服务实际加载的
|
|
7
|
-
* 仍是自带副本 —— 表现为「升了 0.86.1,横幅和 /api/health 还显示 0.85.1」。
|
|
8
|
-
*
|
|
9
|
-
* 这里把「所有能被解析到的副本」按 Node 的顺序算出来([0] = 生效的那份),
|
|
10
|
-
* 让启动横幅与健康检查说实话,而不是让用户去猜。
|
|
11
|
-
*
|
|
12
|
-
* 纯函数 + 零副作用,便于单测(见 tests/unit/sdk-origin.test.ts)。
|
|
13
|
-
*/
|
|
14
1
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
15
2
|
import { dirname, join, delimiter, isAbsolute } from "node:path";
|
|
16
3
|
import { fileURLToPath } from "node:url";
|
|
@@ -32,7 +19,6 @@ function addCopy(pjPath, out, requireName = false) {
|
|
|
32
19
|
}
|
|
33
20
|
catch { }
|
|
34
21
|
}
|
|
35
|
-
/** 探测 PATH 上的 pi 可执行文件反推其包根(issue #559, #562)。 */
|
|
36
22
|
function scanPathForPi(out, env = process.env) {
|
|
37
23
|
const rawPath = env.PATH || "";
|
|
38
24
|
if (!rawPath)
|
|
@@ -45,7 +31,6 @@ function scanPathForPi(out, env = process.env) {
|
|
|
45
31
|
const candidate = join(dir, name);
|
|
46
32
|
if (!existsSync(candidate))
|
|
47
33
|
continue;
|
|
48
|
-
// 1. 尝试 realpathSync 解析符号链接(Unix 下 npm/pnpm 全局 bin 标准布局)
|
|
49
34
|
try {
|
|
50
35
|
const real = realpathSync(candidate);
|
|
51
36
|
let cur = dirname(real);
|
|
@@ -59,11 +44,9 @@ function scanPathForPi(out, env = process.env) {
|
|
|
59
44
|
}
|
|
60
45
|
}
|
|
61
46
|
catch { }
|
|
62
|
-
// 2. 检查常见同级/相对 node_modules 目录(Windows npm 全局 bin 同级 node_modules 等)
|
|
63
47
|
addCopy(join(dir, "node_modules", PKG, "package.json"), out);
|
|
64
48
|
addCopy(join(dir, "..", "lib", "node_modules", PKG, "package.json"), out);
|
|
65
49
|
addCopy(join(dir, "..", "node_modules", PKG, "package.json"), out);
|
|
66
|
-
// 3. 脚本包装内容解析(Windows 下 .cmd / .ps1 或 Unix 下 shell 包装脚本)
|
|
67
50
|
try {
|
|
68
51
|
const head = readFileSync(candidate, "utf8").slice(0, 4096);
|
|
69
52
|
const m = head.match(/[^\r\n"']*@earendil-works[/\\]pi-coding-agent[^\r\n"']*/);
|
|
@@ -84,16 +67,13 @@ function scanPathForPi(out, env = process.env) {
|
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
}
|
|
87
|
-
/** 探测 npm / pnpm 全局 prefix 目录(issue #559)。 */
|
|
88
70
|
function scanGlobalPrefixes(out, env = process.env) {
|
|
89
71
|
const home = env.HOME || env.USERPROFILE || "";
|
|
90
|
-
// 1. NPM_CONFIG_PREFIX / npm_config_prefix / PREFIX
|
|
91
72
|
const prefix = env.NPM_CONFIG_PREFIX || env.npm_config_prefix || env.PREFIX;
|
|
92
73
|
if (prefix) {
|
|
93
74
|
addCopy(join(prefix, "lib", "node_modules", PKG, "package.json"), out);
|
|
94
75
|
addCopy(join(prefix, "node_modules", PKG, "package.json"), out);
|
|
95
76
|
}
|
|
96
|
-
// 2. 用户级 npm 全局 (~/.npm-global, %APPDATA%\npm)
|
|
97
77
|
if (home) {
|
|
98
78
|
addCopy(join(home, ".npm-global", "lib", "node_modules", PKG, "package.json"), out);
|
|
99
79
|
addCopy(join(home, ".npm-global", "node_modules", PKG, "package.json"), out);
|
|
@@ -101,12 +81,10 @@ function scanGlobalPrefixes(out, env = process.env) {
|
|
|
101
81
|
if (env.APPDATA) {
|
|
102
82
|
addCopy(join(env.APPDATA, "npm", "node_modules", PKG, "package.json"), out);
|
|
103
83
|
}
|
|
104
|
-
// 3. POSIX 系统级 npm 全局
|
|
105
84
|
if (process.platform !== "win32") {
|
|
106
85
|
addCopy(join("/usr", "local", "lib", "node_modules", PKG, "package.json"), out);
|
|
107
86
|
addCopy(join("/usr", "lib", "node_modules", PKG, "package.json"), out);
|
|
108
87
|
}
|
|
109
|
-
// 4. pnpm 全局目录 (PNPM_HOME, ~/.local/share/pnpm/global, %LOCALAPPDATA%\pnpm\global)
|
|
110
88
|
if (env.PNPM_HOME) {
|
|
111
89
|
addCopy(join(env.PNPM_HOME, "node_modules", PKG, "package.json"), out);
|
|
112
90
|
addCopy(join(env.PNPM_HOME, "global", "node_modules", PKG, "package.json"), out);
|
|
@@ -118,9 +96,6 @@ function scanGlobalPrefixes(out, env = process.env) {
|
|
|
118
96
|
addCopy(join(env.LOCALAPPDATA, "pnpm", "global", "node_modules", PKG, "package.json"), out);
|
|
119
97
|
}
|
|
120
98
|
}
|
|
121
|
-
/** 从某个文件出发,逐级向上查找 `<dir>/node_modules/<pkg>/package.json`,
|
|
122
|
-
* 并探测系统/全局已安装的 pi SDK 副本(issue #260, #321, #559, #562)。
|
|
123
|
-
* `fromFile` 收 URL(`import.meta.url`)或普通文件路径(便于单测)。 */
|
|
124
99
|
export function sdkCopies(fromFile = import.meta.url, options = {}) {
|
|
125
100
|
const env = options.env ?? process.env;
|
|
126
101
|
const includeGlobal = options.includeGlobal ?? (options.env ? true : !process.env.VITEST);
|
|
@@ -134,24 +109,19 @@ export function sdkCopies(fromFile = import.meta.url, options = {}) {
|
|
|
134
109
|
break;
|
|
135
110
|
dir = parent;
|
|
136
111
|
}
|
|
137
|
-
// 显式透传的宿主 SDK 路径(如 extensions/webui.ts 宿主传递,issue #482)
|
|
138
112
|
if (env.PI_WEB_SDK_DIR) {
|
|
139
113
|
addCopy(join(env.PI_WEB_SDK_DIR, "package.json"), out);
|
|
140
114
|
}
|
|
141
|
-
// 宿主 Pi Node 路径探测(~/.local/share/pi-node/current/...,issue #482)
|
|
142
115
|
const home = env.HOME || env.USERPROFILE;
|
|
143
116
|
if (home) {
|
|
144
117
|
addCopy(join(home, ".local", "share", "pi-node", "current", "lib", "node_modules", PKG, "package.json"), out);
|
|
145
118
|
}
|
|
146
119
|
if (includeGlobal) {
|
|
147
|
-
// PATH 上的 pi 可执行文件反推(issue #559)
|
|
148
120
|
scanPathForPi(out, env);
|
|
149
|
-
// npm / pnpm 全局 prefix 目录探测(issue #559)
|
|
150
121
|
scanGlobalPrefixes(out, env);
|
|
151
122
|
}
|
|
152
123
|
return out;
|
|
153
124
|
}
|
|
154
|
-
/** 点分版本号比较(够用即可:只比数字段,缺位当 0)。 */
|
|
155
125
|
export function compareVersions(a, b) {
|
|
156
126
|
const pa = a.split(".");
|
|
157
127
|
const pb = b.split(".");
|
|
@@ -163,27 +133,12 @@ export function compareVersions(a, b) {
|
|
|
163
133
|
}
|
|
164
134
|
return 0;
|
|
165
135
|
}
|
|
166
|
-
/**
|
|
167
|
-
* 本进程实际加载的是否为**随包自带**的那份(未被钩子重定向到祖先链副本)。
|
|
168
|
-
* 判据:自带副本是解析顺序上的第一份,且钩子只在祖先副本**严格更新**时才重定向
|
|
169
|
-
* (同版本继续用自带),所以 running == copies[0] ⟺ 自带在用。copies 为空
|
|
170
|
-
* (如部分桌面/容器布局)时按自带算 —— 那本来就是唯一能加载的份。
|
|
171
|
-
* UI 用它决定是否亮「安装全局引擎并切换」入口(issue #321)。
|
|
172
|
-
*/
|
|
173
136
|
export function isBundledInUse(copies, effectiveVersion, bundledCopy) {
|
|
174
137
|
if (bundledCopy !== undefined) {
|
|
175
138
|
return bundledCopy !== null && effectiveVersion === bundledCopy.version;
|
|
176
139
|
}
|
|
177
140
|
return copies.length === 0 || effectiveVersion === copies[0].version;
|
|
178
141
|
}
|
|
179
|
-
/**
|
|
180
|
-
* 启动横幅要打印的一行(不含前缀),以及是否需要提示「本进程在用的不是最新的那份」。
|
|
181
|
-
* `effective` 为空时(没找到副本)返回空串,调用方照旧只打印版本号。
|
|
182
|
-
*
|
|
183
|
-
* #321 起默认会自动跟随更新的那份(resolve-global-sdk),所以这条提示出现即意味着:
|
|
184
|
-
* 进程启动时没跟上(升级发生在启动后 / 旧构建没注入钩子),或用户显式
|
|
185
|
-
* PI_WEB_SDK=bundled 钉死了自带副本 —— 文案把两种出路都写明。
|
|
186
|
-
*/
|
|
187
142
|
export function sdkOriginNote(copies, effectiveVersion) {
|
|
188
143
|
const shadowed = copies.slice(1);
|
|
189
144
|
const newer = shadowed.filter((c) => compareVersions(c.version, effectiveVersion) > 0);
|