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,53 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* hashline-engine.ts — 基于内容哈希锚定与语法块解析的高可靠 Patch 引擎。
|
|
3
|
-
*
|
|
4
|
-
* 核心设计(借鉴 @oh-my-pi/hashline):
|
|
5
|
-
* 1. [path#TAG] 内容哈希锚点:每个 hunk 绑定文件内容的 4-hex 校验和,杜绝模型基于陈旧行号盲改。
|
|
6
|
-
* 2. PUT N*= 语法块级替换:通过括号嵌套(Brace matching)与缩进(Indentation)自动识别代码块闭合,
|
|
7
|
-
* 模型无需数行号,消除最常见的行号漂移问题。
|
|
8
|
-
* 3. 3-Way Merge 冲突自愈:若磁盘文件已被修改导致哈希不匹配,通过快照与 diff 进行三方合并,
|
|
9
|
-
* 无重叠冲突时平滑合入,冲突时提供带行号的准确定位提示。
|
|
10
|
-
* 4. 寄存器支持(CUT / PUT @reg):支持在跨文件或同文件内部移动代码段。
|
|
11
|
-
*/
|
|
12
1
|
import { createHash } from "node:crypto";
|
|
13
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
14
3
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
15
4
|
export const HL_HASH_LENGTH = 4;
|
|
16
|
-
/** 归一化文本换行符与尾随空白(确保哈希跨平台一致) */
|
|
17
5
|
export function normalizeLineEndings(text) {
|
|
18
6
|
return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
19
7
|
}
|
|
20
|
-
/** 计算文件的 4 位十六进制内容哈希(大写) */
|
|
21
8
|
export function computeFileHash(text) {
|
|
22
9
|
const normalized = normalizeLineEndings(text).replace(/[ \t]+(?=\n|$)/g, "");
|
|
23
10
|
const hash = createHash("sha256").update(normalized, "utf8").digest("hex");
|
|
24
11
|
return hash.slice(0, HL_HASH_LENGTH).toUpperCase();
|
|
25
12
|
}
|
|
26
|
-
/** 为文件生成带哈希的段头:[src/app.ts#A1B2] */
|
|
27
13
|
export function formatHashlineHeader(filePath, hash) {
|
|
28
14
|
return `[${filePath}#${hash}]`;
|
|
29
15
|
}
|
|
30
|
-
/** 为文本输出带行号的展示视图:1:line1\n2:line2 */
|
|
31
16
|
export function formatNumberedLines(text, startLine = 1) {
|
|
32
17
|
const lines = normalizeLineEndings(text).split("\n");
|
|
33
18
|
return lines.map((l, i) => `${startLine + i}:${l}`).join("\n");
|
|
34
19
|
}
|
|
35
|
-
// ----------------------------------------------------------------------------
|
|
36
|
-
// 语法块解析(Block Resolver)
|
|
37
|
-
// ----------------------------------------------------------------------------
|
|
38
|
-
/**
|
|
39
|
-
* 启发式语法块边界解析:从 startLine(1-indexed)开始,定位该语句块的闭合行。
|
|
40
|
-
* 支持:
|
|
41
|
-
* 1. 括号/大括号嵌套语言(JS/TS/Rust/Go/C/C++/Java/PHP):匹配同深度闭合 '}'。
|
|
42
|
-
* 2. 缩进敏感语言(Python/YAML/Makefile):匹配缩进回退的边界。
|
|
43
|
-
* 3. Markdown 标题:匹配同级或更高级标题的边界。
|
|
44
|
-
*/
|
|
45
20
|
export function resolveBlockSpan(lines, startLine, filePath = "") {
|
|
46
21
|
const n = lines.length;
|
|
47
22
|
const sIdx = Math.max(0, Math.min(n - 1, startLine - 1));
|
|
48
23
|
const startContent = lines[sIdx] ?? "";
|
|
49
24
|
const trimmedStart = startContent.trim();
|
|
50
|
-
// 1. Markdown 标题:## Title -> 下一个同级或更高级标题
|
|
51
25
|
const isMd = /\.(md|markdown|mdx)$/i.test(filePath);
|
|
52
26
|
const mdHeaderMatch = trimmedStart.match(/^(#{1,6})\s+/);
|
|
53
27
|
if (isMd && mdHeaderMatch) {
|
|
@@ -62,7 +36,6 @@ export function resolveBlockSpan(lines, startLine, filePath = "") {
|
|
|
62
36
|
}
|
|
63
37
|
return { start: sIdx + 1, end: endIdx + 1 };
|
|
64
38
|
}
|
|
65
|
-
// 2. 缩进语言判定(Python、YAML、Make)
|
|
66
39
|
const isIndentLang = /\.(py|yaml|yml|makefile|dockerfile)$/i.test(filePath) || !startContent.includes("{");
|
|
67
40
|
if (isIndentLang && (trimmedStart.endsWith(":") || !trimmedStart.includes("{"))) {
|
|
68
41
|
const baseIndent = startContent.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
@@ -70,7 +43,6 @@ export function resolveBlockSpan(lines, startLine, filePath = "") {
|
|
|
70
43
|
for (let i = sIdx + 1; i < n; i++) {
|
|
71
44
|
const line = lines[i];
|
|
72
45
|
if (line.trim().length === 0) {
|
|
73
|
-
// 空行不打断块,只要后面还有更深缩进
|
|
74
46
|
continue;
|
|
75
47
|
}
|
|
76
48
|
const curIndent = line.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
@@ -81,7 +53,6 @@ export function resolveBlockSpan(lines, startLine, filePath = "") {
|
|
|
81
53
|
}
|
|
82
54
|
return { start: sIdx + 1, end: endIdx + 1 };
|
|
83
55
|
}
|
|
84
|
-
// 3. 大括号 / 括号计数解析(JS/TS/Rust/Go/C/C++ 等)
|
|
85
56
|
let braceDepth = 0;
|
|
86
57
|
let parenDepth = 0;
|
|
87
58
|
let bracketDepth = 0;
|
|
@@ -111,7 +82,6 @@ export function resolveBlockSpan(lines, startLine, filePath = "") {
|
|
|
111
82
|
inString = char;
|
|
112
83
|
continue;
|
|
113
84
|
}
|
|
114
|
-
// 单行注释
|
|
115
85
|
if (char === "/" && next === "/")
|
|
116
86
|
break;
|
|
117
87
|
if (char === "{") {
|
|
@@ -141,9 +111,6 @@ export function resolveBlockSpan(lines, startLine, filePath = "") {
|
|
|
141
111
|
}
|
|
142
112
|
return { start: sIdx + 1, end: endIdx + 1 };
|
|
143
113
|
}
|
|
144
|
-
/**
|
|
145
|
-
* 解析 Hashline 补丁文本
|
|
146
|
-
*/
|
|
147
114
|
export function parseHashlinePatch(patchText) {
|
|
148
115
|
const lines = normalizeLineEndings(patchText).split("\n");
|
|
149
116
|
const sections = [];
|
|
@@ -165,7 +132,6 @@ export function parseHashlinePatch(patchText) {
|
|
|
165
132
|
for (let i = 0; i < lines.length; i++) {
|
|
166
133
|
const rawLine = lines[i];
|
|
167
134
|
const trimmed = rawLine.trim();
|
|
168
|
-
// 1. 段落头: [path#TAG] 或 [path]
|
|
169
135
|
const secMatch = rawLine.match(/^\s*\[([^#\]]+)(?:#([0-9a-fA-F]{4}))?\]\s*$/);
|
|
170
136
|
if (secMatch) {
|
|
171
137
|
flushSection();
|
|
@@ -177,23 +143,19 @@ export function parseHashlinePatch(patchText) {
|
|
|
177
143
|
continue;
|
|
178
144
|
}
|
|
179
145
|
if (!currentSection) {
|
|
180
|
-
// 未进入段落前的空白或注释跳过
|
|
181
146
|
continue;
|
|
182
147
|
}
|
|
183
|
-
// 2. 文件级指令: REM (删除当前文件)
|
|
184
148
|
if (/^REM\b/i.test(trimmed)) {
|
|
185
149
|
flushHunk();
|
|
186
150
|
currentSection.hunks.push({ kind: "remove_file", bodyLines: [] });
|
|
187
151
|
continue;
|
|
188
152
|
}
|
|
189
|
-
// 3. 文件级指令: MV dest (重命名/移动当前文件)
|
|
190
153
|
const mvMatch = trimmed.match(/^MV\s+([^\s]+)/i);
|
|
191
154
|
if (mvMatch) {
|
|
192
155
|
flushHunk();
|
|
193
156
|
currentSection.hunks.push({ kind: "move_file", targetPath: mvMatch[1], bodyLines: [] });
|
|
194
157
|
continue;
|
|
195
158
|
}
|
|
196
|
-
// 4. CUT 指令: CUT N.=M [@reg] 或 CUT N* [@reg]
|
|
197
159
|
const cutMatch = trimmed.match(/^CUT\s+(\d+)(?:\.=(\d+)|\*)\s*(?:@([a-zA-Z0-9_-]+))?/);
|
|
198
160
|
if (cutMatch) {
|
|
199
161
|
flushHunk();
|
|
@@ -210,11 +172,10 @@ export function parseHashlinePatch(patchText) {
|
|
|
210
172
|
});
|
|
211
173
|
continue;
|
|
212
174
|
}
|
|
213
|
-
// 5. 粘贴指令 (无冒号头): PUT <N @reg / PUT >N @reg / PUT N.=M @reg / PUT N* @reg
|
|
214
175
|
const pasteMatch = trimmed.match(/^PUT\s+(<|>)?(\d+)(?:\.=(\d+)|\*)?\s+@([a-zA-Z0-9_-]+)/);
|
|
215
176
|
if (pasteMatch && !trimmed.endsWith(":")) {
|
|
216
177
|
flushHunk();
|
|
217
|
-
const prefix = pasteMatch[1];
|
|
178
|
+
const prefix = pasteMatch[1];
|
|
218
179
|
const num = parseInt(pasteMatch[2], 10);
|
|
219
180
|
const endNum = pasteMatch[3] ? parseInt(pasteMatch[3], 10) : num;
|
|
220
181
|
const isBlock = trimmed.includes("*");
|
|
@@ -241,8 +202,6 @@ export function parseHashlinePatch(patchText) {
|
|
|
241
202
|
});
|
|
242
203
|
continue;
|
|
243
204
|
}
|
|
244
|
-
// 6. 替换或插入指令头 (带冒号):
|
|
245
|
-
// PUT N.=M: / PUT N*: / PUT <N: / PUT >N: / PUT >N*: / PUT <$: / PUT >$:
|
|
246
205
|
const putHeaderMatch = trimmed.match(/^PUT\s+(<|>)?(\d+|\$)(?:\.=(\d+)|\*)?:$/);
|
|
247
206
|
if (putHeaderMatch) {
|
|
248
207
|
flushHunk();
|
|
@@ -272,7 +231,6 @@ export function parseHashlinePatch(patchText) {
|
|
|
272
231
|
};
|
|
273
232
|
continue;
|
|
274
233
|
}
|
|
275
|
-
// 7. 内容行 (以 '+' 开头)
|
|
276
234
|
if (rawLine.startsWith("+")) {
|
|
277
235
|
if (currentHunk) {
|
|
278
236
|
currentHunk.bodyLines.push(rawLine.slice(1));
|
|
@@ -283,14 +241,9 @@ export function parseHashlinePatch(patchText) {
|
|
|
283
241
|
flushSection();
|
|
284
242
|
return sections;
|
|
285
243
|
}
|
|
286
|
-
// ----------------------------------------------------------------------------
|
|
287
|
-
// 快照存储与三方合并恢复(Snapshot Store & 3-Way Merge Recovery)
|
|
288
|
-
// ----------------------------------------------------------------------------
|
|
289
244
|
export class HashlineSnapshotStore {
|
|
290
|
-
/** 单个文件保留的快照代数上限(LRU):全局单例会跨整个会话存活,反复编辑
|
|
291
|
-
* 同一文件会让快照按编辑次数无界增长,必须驱逐最旧一代。 */
|
|
292
245
|
static MAX_PER_FILE = 200;
|
|
293
|
-
snapshots = new Map();
|
|
246
|
+
snapshots = new Map();
|
|
294
247
|
record(filePath, text) {
|
|
295
248
|
const hash = computeFileHash(text);
|
|
296
249
|
let fileMap = this.snapshots.get(filePath);
|
|
@@ -298,7 +251,6 @@ export class HashlineSnapshotStore {
|
|
|
298
251
|
fileMap = new Map();
|
|
299
252
|
this.snapshots.set(filePath, fileMap);
|
|
300
253
|
}
|
|
301
|
-
// 先删后插:覆盖同代快照的同时把访问序刷到尾部(Map 插入序即 LRU 序)
|
|
302
254
|
fileMap.delete(hash);
|
|
303
255
|
fileMap.set(hash, text);
|
|
304
256
|
while (fileMap.size > HashlineSnapshotStore.MAX_PER_FILE) {
|
|
@@ -316,30 +268,18 @@ export class HashlineSnapshotStore {
|
|
|
316
268
|
const key = hash.toUpperCase();
|
|
317
269
|
const hit = fileMap.get(key);
|
|
318
270
|
if (hit !== undefined) {
|
|
319
|
-
// get 命中即 refresh:重插到尾部,正在参与三方合并的快照不被 LRU 驱逐
|
|
320
271
|
fileMap.delete(key);
|
|
321
272
|
fileMap.set(key, hit);
|
|
322
273
|
}
|
|
323
274
|
return hit;
|
|
324
275
|
}
|
|
325
276
|
}
|
|
326
|
-
/** 全局会话级快照单例 */
|
|
327
277
|
export const globalSnapshotStore = new HashlineSnapshotStore();
|
|
328
|
-
/**
|
|
329
|
-
* 启发式三方行合并:
|
|
330
|
-
* baseLines: 制作补丁时的原始文件快照
|
|
331
|
-
* currentLines: 磁盘当前的最新文件
|
|
332
|
-
* targetHunks: 针对 baseLines 计算出的目标改动行区间
|
|
333
|
-
*
|
|
334
|
-
* 核心逻辑:若磁盘文件的改动未侵入 targetHunks 所在的锚点行,则将锚点行映射到最新文件的对应行,安全完成合并。
|
|
335
|
-
*/
|
|
336
278
|
export function tryRecoverEdits(baseText, currentText, hunks, _filePath) {
|
|
337
279
|
const baseLines = normalizeLineEndings(baseText).split("\n");
|
|
338
280
|
const curLines = normalizeLineEndings(currentText).split("\n");
|
|
339
|
-
// 若内容完全相同,无需恢复
|
|
340
281
|
if (baseText === currentText)
|
|
341
282
|
return { success: true, remappedHunks: hunks };
|
|
342
|
-
// 简单行偏移探测:计算首个不一致行与行数差
|
|
343
283
|
let firstDiff = -1;
|
|
344
284
|
for (let i = 0; i < Math.max(baseLines.length, curLines.length); i++) {
|
|
345
285
|
if (baseLines[i] !== curLines[i]) {
|
|
@@ -349,21 +289,17 @@ export function tryRecoverEdits(baseText, currentText, hunks, _filePath) {
|
|
|
349
289
|
}
|
|
350
290
|
if (firstDiff === -1)
|
|
351
291
|
return { success: true, remappedHunks: hunks };
|
|
352
|
-
// 检查是否有 hunk 的锚点位于差异产生点之前或之后
|
|
353
292
|
const delta = curLines.length - baseLines.length;
|
|
354
293
|
const remapped = [];
|
|
355
294
|
for (const hunk of hunks) {
|
|
356
295
|
const start = hunk.lineStart ?? 1;
|
|
357
296
|
const end = hunk.lineEnd ?? start;
|
|
358
297
|
if (start < firstDiff && end < firstDiff) {
|
|
359
|
-
// 在差异行之前,行号保持不变
|
|
360
298
|
remapped.push({ ...hunk });
|
|
361
299
|
}
|
|
362
300
|
else {
|
|
363
|
-
// 差异行之后,尝试应用行号平移 delta
|
|
364
301
|
const shiftedStart = Math.max(1, start + delta);
|
|
365
302
|
const shiftedEnd = Math.max(1, end + delta);
|
|
366
|
-
// 校验平移后的周围文本是否与 base 时的上下文匹配
|
|
367
303
|
const baseSnippet = baseLines.slice(Math.max(0, start - 2), Math.min(baseLines.length, end + 1)).join("\n");
|
|
368
304
|
const curSnippet = curLines
|
|
369
305
|
.slice(Math.max(0, shiftedStart - 2), Math.min(curLines.length, shiftedEnd + 1))
|
|
@@ -376,7 +312,6 @@ export function tryRecoverEdits(baseText, currentText, hunks, _filePath) {
|
|
|
376
312
|
});
|
|
377
313
|
}
|
|
378
314
|
else {
|
|
379
|
-
// 平移后上下文仍不匹配:±6 行窗口内做 trim 归一化重锚定
|
|
380
315
|
const baseCtx = baseLines
|
|
381
316
|
.slice(Math.max(0, start - 2), Math.min(baseLines.length, end + 1))
|
|
382
317
|
.join("\n")
|
|
@@ -416,14 +351,10 @@ export function tryRecoverEdits(baseText, currentText, hunks, _filePath) {
|
|
|
416
351
|
}
|
|
417
352
|
return { success: true, remappedHunks: remapped };
|
|
418
353
|
}
|
|
419
|
-
/**
|
|
420
|
-
* 错误消息附带当前内容摘录(行号: 内容,锚点附近 ±2 行),
|
|
421
|
-
* 让模型基于现内容一次重试到位,而不是被迫整文件重读。
|
|
422
|
-
*/
|
|
423
354
|
function patchFileExcerpt(lines, aroundLine, filePath, hash) {
|
|
424
355
|
let n = lines.length;
|
|
425
356
|
if (n > 0 && lines[n - 1] === "")
|
|
426
|
-
n--;
|
|
357
|
+
n--;
|
|
427
358
|
const head = `当前共 ${n} 行,最新锚点:[${filePath}#${hash}]`;
|
|
428
359
|
if (n === 0)
|
|
429
360
|
return `${head}(空文件)`;
|
|
@@ -435,7 +366,6 @@ function patchFileExcerpt(lines, aroundLine, filePath, hash) {
|
|
|
435
366
|
rows.push(`${i}: ${String(lines[i - 1]).slice(0, 160)}`);
|
|
436
367
|
return `${head};第 ${lo}-${hi} 行现内容:\n${rows.join("\n")}`;
|
|
437
368
|
}
|
|
438
|
-
/** 同名文件解析时跳过的高风险/重目录 */
|
|
439
369
|
const SAME_BASENAME_SKIP_DIRS = new Set([
|
|
440
370
|
"node_modules",
|
|
441
371
|
".git",
|
|
@@ -449,10 +379,6 @@ const SAME_BASENAME_SKIP_DIRS = new Set([
|
|
|
449
379
|
"target",
|
|
450
380
|
".next",
|
|
451
381
|
]);
|
|
452
|
-
/**
|
|
453
|
-
* 带锚头但文件读不到时:工作区内找同名唯一文件(典型场景:模型写错目录层级)。
|
|
454
|
-
* 只接受唯一命中;歧义/无命中交回原错误路径并附候选清单。
|
|
455
|
-
*/
|
|
456
382
|
function findUniqueSameBasename(cwd, targetPath) {
|
|
457
383
|
const base = basename(targetPath);
|
|
458
384
|
if (!base || base.startsWith("."))
|
|
@@ -491,10 +417,6 @@ function findUniqueSameBasename(cwd, targetPath) {
|
|
|
491
417
|
return { status: "resolved", path: relative(cwd, ci[0]) || ci[0], candidates: ci };
|
|
492
418
|
return { status: same.length + ci.length > 1 ? "ambiguous" : "none", candidates: [...same, ...ci].slice(0, 8) };
|
|
493
419
|
}
|
|
494
|
-
/**
|
|
495
|
-
* 应用 Hashline 补丁
|
|
496
|
-
* 支持传入虚拟或物理文件读写器(便于单元测试或沙箱执行)
|
|
497
|
-
*/
|
|
498
420
|
export function applyHashlinePatch(patchText, options = {}) {
|
|
499
421
|
const cwd = options.cwd ?? process.cwd();
|
|
500
422
|
const store = options.snapshotStore ?? globalSnapshotStore;
|
|
@@ -525,17 +447,13 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
525
447
|
if (sections.length === 0) {
|
|
526
448
|
return { ok: false, summary: "未能从输入中解析出有效的 [path#TAG] 补丁段", results: [] };
|
|
527
449
|
}
|
|
528
|
-
const clipboard = new Map();
|
|
529
|
-
const plannedWrites = new Map();
|
|
450
|
+
const clipboard = new Map();
|
|
451
|
+
const plannedWrites = new Map();
|
|
530
452
|
const plannedDeletes = new Set();
|
|
531
|
-
// Windows 文件系统大小写不敏感:键做大小写折叠,避免 [a]/[A] 变体绕过路径归一化造成双写覆盖;
|
|
532
|
-
// plannedPaths 记录首次见到的原始路径(保持相对/绝对形态)供落盘与自定义读写器使用。
|
|
533
453
|
const foldKey = (abs) => (process.platform === "win32" ? abs.toLowerCase() : abs);
|
|
534
454
|
const plannedPaths = new Map();
|
|
535
455
|
const results = [];
|
|
536
|
-
// ===== 阶段 1: 预检所有文件并计算目标内容 =====
|
|
537
456
|
for (const sec of sections) {
|
|
538
|
-
// 越界安全防护
|
|
539
457
|
const rel = relative(cwd, resolve(cwd, sec.filePath));
|
|
540
458
|
if (rel === ".." ||
|
|
541
459
|
rel.startsWith(".." + sep) ||
|
|
@@ -549,12 +467,9 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
549
467
|
error: `Path traversal denied: ${sec.filePath}`,
|
|
550
468
|
};
|
|
551
469
|
}
|
|
552
|
-
// 同一次 patch 内对同文件的后续段落,优先使用前面段落生成的新内容。
|
|
553
|
-
// plannedWrites/plannedDeletes 一律按折叠绝对路径做键:[a] 与 [./a]、大小写变体视为同一文件。
|
|
554
470
|
let currentText = plannedWrites.get(foldKey(resolve(cwd, sec.filePath))) ?? read(sec.filePath);
|
|
555
471
|
let fuzzyNote = "";
|
|
556
472
|
if (currentText === null && sec.expectedHash) {
|
|
557
|
-
// 带 #TAG 却读不到:先尝试工作区内同名唯一文件解析(典型:模型写错目录层级)
|
|
558
473
|
const cand = findUniqueSameBasename(cwd, sec.filePath);
|
|
559
474
|
if (cand.status === "resolved" && cand.path) {
|
|
560
475
|
fuzzyNote = `(路径 ${sec.filePath} 不存在,已解析为同名文件 ${cand.path})`;
|
|
@@ -564,7 +479,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
564
479
|
}
|
|
565
480
|
const isNewFile = currentText === null;
|
|
566
481
|
if (currentText === null) {
|
|
567
|
-
// [path] 段头(无 #TAG)+ 内容 hunk = 创建新文件
|
|
568
482
|
if (sec.hunks.some((h) => h.kind === "remove_file" || h.kind === "move_file")) {
|
|
569
483
|
return {
|
|
570
484
|
ok: false,
|
|
@@ -574,7 +488,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
574
488
|
};
|
|
575
489
|
}
|
|
576
490
|
if (sec.expectedHash) {
|
|
577
|
-
// 附工作区相近文件候选(相对路径),有候选时不建议新建遮蔽
|
|
578
491
|
const cand = findUniqueSameBasename(cwd, sec.filePath);
|
|
579
492
|
const candRel = cand.candidates.map((c) => relative(cwd, c) || c);
|
|
580
493
|
const advice = candRel.length
|
|
@@ -587,14 +500,13 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
587
500
|
error: `Tagged header on nonexistent file: ${sec.filePath}`,
|
|
588
501
|
};
|
|
589
502
|
}
|
|
590
|
-
currentText = "";
|
|
503
|
+
currentText = "";
|
|
591
504
|
}
|
|
592
505
|
const isCrlf = currentText.includes("\r\n");
|
|
593
506
|
const eol = isCrlf ? "\r\n" : "\n";
|
|
594
507
|
const liveHash = computeFileHash(currentText);
|
|
595
508
|
let workingText = currentText;
|
|
596
509
|
let isRecovered = false;
|
|
597
|
-
// 哈希校验与三方冲突自愈(快照按绝对路径优先隔离,兼容相对路径回退)
|
|
598
510
|
const absFilePath = resolve(cwd, sec.filePath);
|
|
599
511
|
if (sec.expectedHash && sec.expectedHash !== liveHash) {
|
|
600
512
|
const snapshot = store.get(absFilePath, sec.expectedHash) ?? store.get(sec.filePath, sec.expectedHash);
|
|
@@ -605,7 +517,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
605
517
|
isRecovered = true;
|
|
606
518
|
}
|
|
607
519
|
else {
|
|
608
|
-
// 附现内容摘录,模型可基于现内容一次重锚定
|
|
609
520
|
const excerptLines = normalizeLineEndings(currentText).split("\n");
|
|
610
521
|
const firstHunk = sec.hunks.find((h) => h.kind !== "remove_file" && h.kind !== "move_file");
|
|
611
522
|
return {
|
|
@@ -617,7 +528,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
617
528
|
}
|
|
618
529
|
}
|
|
619
530
|
else {
|
|
620
|
-
// 附现内容摘录,模型可基于现内容一次重锚定
|
|
621
531
|
const excerptLines = normalizeLineEndings(currentText).split("\n");
|
|
622
532
|
const firstHunk = sec.hunks.find((h) => h.kind !== "remove_file" && h.kind !== "move_file");
|
|
623
533
|
return {
|
|
@@ -634,12 +544,10 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
634
544
|
lines.pop();
|
|
635
545
|
}
|
|
636
546
|
if (isNewFile) {
|
|
637
|
-
lines = [];
|
|
547
|
+
lines = [];
|
|
638
548
|
}
|
|
639
549
|
let isDeleted = false;
|
|
640
550
|
let moveDest = undefined;
|
|
641
|
-
// 倒序/顺序处理 hunks。为了保证行号不受前面 hunk 影响,从后往前执行行号替换;
|
|
642
|
-
// 但先提取 CUT 的内容到寄存器
|
|
643
551
|
for (const h of sec.hunks) {
|
|
644
552
|
if (h.kind === "remove_file") {
|
|
645
553
|
isDeleted = true;
|
|
@@ -664,7 +572,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
664
572
|
moveDest = h.targetPath;
|
|
665
573
|
continue;
|
|
666
574
|
}
|
|
667
|
-
// 语法块展开
|
|
668
575
|
if (h.kind === "put_block" || h.kind === "cut_block" || h.kind === "paste_over_block") {
|
|
669
576
|
const span = resolveBlockSpan(lines, h.lineStart ?? 1, sec.filePath);
|
|
670
577
|
h.lineStart = span.start;
|
|
@@ -675,7 +582,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
675
582
|
h.lineStart = span.end;
|
|
676
583
|
h.kind = "insert_after";
|
|
677
584
|
}
|
|
678
|
-
// 捕获到寄存器
|
|
679
585
|
if (h.kind === "cut_range" || h.kind === "cut_block") {
|
|
680
586
|
const start = Math.max(1, h.lineStart ?? 1);
|
|
681
587
|
const end = Math.min(lines.length, h.lineEnd ?? start);
|
|
@@ -696,13 +602,11 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
696
602
|
});
|
|
697
603
|
continue;
|
|
698
604
|
}
|
|
699
|
-
// 行号越界校验与重叠校验
|
|
700
605
|
for (const h of sec.hunks) {
|
|
701
606
|
if (h.kind === "remove_file" || h.kind === "move_file")
|
|
702
607
|
continue;
|
|
703
608
|
if (h.lineStart !== -1 && typeof h.lineStart === "number") {
|
|
704
609
|
if (h.lineStart < 1 || h.lineStart > Math.max(1, lines.length)) {
|
|
705
|
-
// 附文件尾部摘录,模型可自行改用 PUT >$ 或修正行号
|
|
706
610
|
return {
|
|
707
611
|
ok: false,
|
|
708
612
|
summary: `行号越界:${sec.filePath} 第 ${h.lineStart} 行(文件总共只有 ${lines.length} 行)。${patchFileExcerpt(lines, lines.length, sec.filePath, liveHash)}`,
|
|
@@ -725,10 +629,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
725
629
|
let s;
|
|
726
630
|
let e;
|
|
727
631
|
if (h.kind === "insert_before" || h.kind === "insert_after") {
|
|
728
|
-
// insert 类 hunk 也纳入重叠校验(锚点单行):执行时按行号降序 splice,
|
|
729
|
-
// 若锚点行被同补丁的 replace/cut 覆盖删除、或与其它 insert 锚点重合,
|
|
730
|
-
// 插入位置会随前面的改动串位,产出与模型意图不符的内容。保守策略:
|
|
731
|
-
// 锚点行与任何 replace span / 其它 insert 锚点重叠即报错。
|
|
732
632
|
s = h.lineStart === -1 ? lines.length : (h.lineStart ?? 1);
|
|
733
633
|
e = s;
|
|
734
634
|
}
|
|
@@ -756,7 +656,6 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
756
656
|
}
|
|
757
657
|
replacementSpans.push({ start: s, end: e });
|
|
758
658
|
}
|
|
759
|
-
// 按行号从大到小排序执行,避免前方修改引起后续行号错位
|
|
760
659
|
const sortedHunks = [...sec.hunks]
|
|
761
660
|
.filter((h) => h.kind !== "remove_file" && h.kind !== "move_file")
|
|
762
661
|
.sort((a, b) => {
|
|
@@ -778,7 +677,7 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
778
677
|
}
|
|
779
678
|
let start = h.lineStart ?? 1;
|
|
780
679
|
if (start === -1)
|
|
781
|
-
start = lines.length;
|
|
680
|
+
start = lines.length;
|
|
782
681
|
if (h.kind === "insert_before") {
|
|
783
682
|
const idx = Math.max(0, Math.min(lines.length, start - 1));
|
|
784
683
|
lines.splice(idx, 0, ...contentToInsert);
|
|
@@ -840,12 +739,9 @@ export function applyHashlinePatch(patchText, options = {}) {
|
|
|
840
739
|
});
|
|
841
740
|
}
|
|
842
741
|
}
|
|
843
|
-
// ===== 阶段 2: 全部校验通过,统一落盘 =====
|
|
844
|
-
// 先执行所有写入,确保新文件与移动目标成功落盘,避免先删后写异常时永久丢失源文件
|
|
845
742
|
for (const [key, content] of plannedWrites.entries()) {
|
|
846
743
|
const p = plannedPaths.get(key) ?? key;
|
|
847
744
|
write(p, content);
|
|
848
|
-
// 记住新快照(统一采用绝对路径隔离多工作区)
|
|
849
745
|
store.record(resolve(cwd, p), content);
|
|
850
746
|
}
|
|
851
747
|
for (const key of plannedDeletes) {
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Host 白名单守卫(防 DNS rebinding,审查跟踪 issue #352)。
|
|
3
|
-
*
|
|
4
|
-
* 此前 Host/Origin 校验只覆盖 WS 升级,HTTP 路由完全不校验 Host;而
|
|
5
|
-
* originAllowed 的「Origin 与 Host 自比」在 rebinding 下必然相等——恶意网页
|
|
6
|
-
* 让自己的域名解析到 127.0.0.1(或私网 IP)后,浏览器发出的请求 Host 就是
|
|
7
|
-
* 攻击者域名,无 token 默认部署即可获得与本地用户等价的 API 面。
|
|
8
|
-
*
|
|
9
|
-
* 规则(纯函数,便于单测):
|
|
10
|
-
* - `hasAuthToken` 为真 → 直接放行(token 本身就是鉴权,rebinding 拿不到口令);
|
|
11
|
-
* - 显式白名单 PI_WEB_ALLOW_HOSTS 非空 → 严格模式,只认白名单(与 WS 侧
|
|
12
|
-
* 旧行为一致,回环/私网兜底不再生效);
|
|
13
|
-
* - Host 是回环(localhost / 127.0.0.0-127.255.255.255 / [::1])→ 放行;
|
|
14
|
-
* - Host 是私网/链路本地(10/8、172.16/12、192.168/16、169.254/16、
|
|
15
|
-
* ::ffff: 映射的上述段、fe80::/10、fc00::/7)→ 放行,保留「局域网用 IP
|
|
16
|
-
* 直接访问」的既有用法(rebinding 的 Host 是公网域名,不会命中这些段);
|
|
17
|
-
* - 其余(公网域名等)→ 拒绝。
|
|
18
|
-
*/
|
|
19
|
-
/** 拆掉 Host 头里的端口与 IPv6 方括号,返回小写 hostname。 */
|
|
20
1
|
export function hostWithoutPort(authority) {
|
|
21
2
|
let a = authority.trim().toLowerCase();
|
|
22
3
|
if (a.startsWith("[")) {
|
|
@@ -25,7 +6,6 @@ export function hostWithoutPort(authority) {
|
|
|
25
6
|
return "";
|
|
26
7
|
return a.slice(1, end);
|
|
27
8
|
}
|
|
28
|
-
// IPv6 裸形式(无方括号的 Host 头不合规,但容忍):含多个冒号时整体当 hostname。
|
|
29
9
|
const colon = a.lastIndexOf(":");
|
|
30
10
|
if (colon !== -1 && a.indexOf(":") === colon)
|
|
31
11
|
a = a.slice(0, colon);
|
|
@@ -46,7 +26,6 @@ function isIpv4Literal(host) {
|
|
|
46
26
|
}
|
|
47
27
|
return octets;
|
|
48
28
|
}
|
|
49
|
-
/** 归一 IPv4-mapped IPv6(::ffff:a.b.c.d)为点分 IPv4,便于按段判断。 */
|
|
50
29
|
function unwrapIpv4Mapped(host) {
|
|
51
30
|
const m = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(host);
|
|
52
31
|
return m ? m[1] : host;
|
|
@@ -63,7 +42,6 @@ export function isLoopbackHost(host) {
|
|
|
63
42
|
export function isPrivateLanHost(host) {
|
|
64
43
|
const h = unwrapIpv4Mapped(host);
|
|
65
44
|
if (h.includes(":")) {
|
|
66
|
-
// fe80::/10 链路本地;fc00::/7 (fc/fd 开头) ULA 私网。
|
|
67
45
|
return /^fe[89ab]/.test(h) || /^f[cd]/.test(h);
|
|
68
46
|
}
|
|
69
47
|
const o = isIpv4Literal(h);
|
|
@@ -86,8 +64,6 @@ export function httpHostAllowed(hostHeader, opts) {
|
|
|
86
64
|
const host = hostWithoutPort(hostHeader);
|
|
87
65
|
if (!host)
|
|
88
66
|
return false;
|
|
89
|
-
// PI_WEB_ALLOW_HOSTS 是文档化的「严格模式」:设置了就只认白名单(与 WS
|
|
90
|
-
// 侧旧行为一致),回环/私网兜底仅在未设置时生效。
|
|
91
67
|
if (opts.allowHosts.length > 0)
|
|
92
68
|
return opts.allowHosts.includes(host);
|
|
93
69
|
return isLoopbackHost(host) || isPrivateLanHost(host);
|
|
@@ -34,11 +34,7 @@ export function calculateHostMetrics(previous, current) {
|
|
|
34
34
|
memoryPercent,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
/** CPU 平滑窗口:上报最近 N 次有效读数的均值。心跳 2s 一次,默认 5 次 ≈ 10s 平均
|
|
38
|
-
* —— 单次 2s 采样的毛刺(编译/构建抖动)不再直接上底栏,观感与任务管理器的
|
|
39
|
-
* 曲线对齐。内存变化慢,不平滑,沿用瞬时值。 */
|
|
40
37
|
export const CPU_SMOOTH_WINDOW = 5;
|
|
41
|
-
/** 有效 CPU 读数序列的均值(空序列 → null,前端显示 —)。纯函数,可单测。 */
|
|
42
38
|
export function meanCpuPercent(readings) {
|
|
43
39
|
if (readings.length === 0)
|
|
44
40
|
return null;
|
|
@@ -54,10 +50,8 @@ export function createHostMetricsSampler(readSnapshot = defaultReadSnapshot, win
|
|
|
54
50
|
previous = readSnapshot();
|
|
55
51
|
}
|
|
56
52
|
catch {
|
|
57
|
-
// 初始基线读取异常时不击穿服务启动,待后续心跳重试
|
|
58
53
|
previous = null;
|
|
59
54
|
}
|
|
60
|
-
/** 最近 window 次有效 CPU 读数(totalDelta<=0 的 null 读数不进序列,避免空洞拉低均值)。 */
|
|
61
55
|
const history = [];
|
|
62
56
|
return () => {
|
|
63
57
|
const current = readSnapshot();
|
|
@@ -17,7 +17,6 @@ export function proxyForwardPath(hit, url) {
|
|
|
17
17
|
fwd = `/${fwd}`;
|
|
18
18
|
return fwd || "/";
|
|
19
19
|
}
|
|
20
|
-
/** Forward plugin traffic and propagate cancellation without truncating successful responses. */
|
|
21
20
|
export function proxyHttp(hit, req, res) {
|
|
22
21
|
if (hit.pluginId === "live-preview" && req.path === hit.prefix) {
|
|
23
22
|
res.redirect(302, `${hit.prefix}/${req.url.slice(req.path.length)}`);
|
|
@@ -130,7 +129,6 @@ export function proxyHttp(hit, req, res) {
|
|
|
130
129
|
else
|
|
131
130
|
req.pipe(up);
|
|
132
131
|
}
|
|
133
|
-
/** Read proxy settings from settings.json and environment. */
|
|
134
132
|
export function resolveProxySettings(agentDir) {
|
|
135
133
|
let httpProxy;
|
|
136
134
|
const settingsPath = join(agentDir, "settings.json");
|
|
@@ -141,9 +139,7 @@ export function resolveProxySettings(agentDir) {
|
|
|
141
139
|
httpProxy = parsed.httpProxy.trim();
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
|
-
catch {
|
|
145
|
-
/* ignore parse error */
|
|
146
|
-
}
|
|
142
|
+
catch { }
|
|
147
143
|
}
|
|
148
144
|
return {
|
|
149
145
|
httpProxy,
|
|
@@ -169,8 +165,6 @@ export function initHttpProxy(agentDir) {
|
|
|
169
165
|
return { active: false };
|
|
170
166
|
}
|
|
171
167
|
try {
|
|
172
|
-
// Lazy-load undici so a missing optional dep never crashes server startup;
|
|
173
|
-
// proxy simply stays inactive with a warning.
|
|
174
168
|
let undici;
|
|
175
169
|
try {
|
|
176
170
|
undici = createRequire(import.meta.url)("undici");
|