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,38 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* skill-discovery.ts — 通用跨智能体技能(Universal Multi-Agent Skills)全源扫描、解析与整合引擎。
|
|
3
|
-
*
|
|
4
|
-
* 覆盖生态与目录规范:
|
|
5
|
-
* 1. Pi Coding Agent:
|
|
6
|
-
* - 全局:$PI_CODING_AGENT_DIR/skills 或 ~/.pi/agent/skills/
|
|
7
|
-
* - 本地:<cwd>/.pi/skills/ 及多根工作区 <root>/.pi/skills/
|
|
8
|
-
* - 祖先:沿工作区向上回溯的父级 .pi/skills/
|
|
9
|
-
* - npm 包:<agentDir>/npm/node_modules/<pkg>/skills 与 <cwd>/.pi/npm/node_modules/<pkg>/skills
|
|
10
|
-
* 2. Universal Agent Skills 规范 (issue #669 / OpenAI Codex / Anthropic 标准):
|
|
11
|
-
* - 全局:~/.agents/skills/
|
|
12
|
-
* - 本地:<cwd>/.agents/skills/
|
|
13
|
-
* - 祖先:沿工作区向上回溯的最多 6 层 .agents/skills/
|
|
14
|
-
* 3. Claude Code:
|
|
15
|
-
* - 全局:~/.claude/skills/
|
|
16
|
-
* - 本地:<cwd>/.claude/skills/ 与祖先 .claude/skills/
|
|
17
|
-
* 4. Cursor / Windsurf / GitHub Copilot / OpenCode / Cline / Roo Code:
|
|
18
|
-
* - 本地/全局的 .cursor/skills, .windsurf/skills, .github/skills, .opencode/skills 等
|
|
19
|
-
* 5. WebUI 本地数据目录:
|
|
20
|
-
* - <dataDir>/skills/ (例如 ~/.pi-web/skills/)
|
|
21
|
-
*
|
|
22
|
-
* 技能结构:
|
|
23
|
-
* 1. 目录形式(标准):<skill-name>/SKILL.md
|
|
24
|
-
* 2. 独立文件形式:<skill-name>.md
|
|
25
|
-
* 3. 嵌套分类目录:<category>/<skill-name>/SKILL.md
|
|
26
|
-
*
|
|
27
|
-
* 优先级与冲突决议:
|
|
28
|
-
* Scope 优先级:本地项目 (project) > 祖先目录 (ancestor, 深度越浅越优) > 用户全局 (global) > npm包 (package)
|
|
29
|
-
* 同 Scope 来源优先级:pi > agents > claude > cursor > windsurf > github > opencode > 其他
|
|
30
|
-
*/
|
|
31
1
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
32
2
|
import { homedir } from "node:os";
|
|
33
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
34
4
|
import { decodeText } from "./text-sniff.js";
|
|
35
|
-
/** 解析 SKILL.md 的 YAML frontmatter 提取 name, description 与元数据配置 */
|
|
36
5
|
export function parseSkillFrontmatter(content, fallbackName) {
|
|
37
6
|
const trimmed = content.trim();
|
|
38
7
|
let name = fallbackName;
|
|
@@ -68,7 +37,6 @@ export function parseSkillFrontmatter(content, fallbackName) {
|
|
|
68
37
|
.filter(Boolean);
|
|
69
38
|
}
|
|
70
39
|
}
|
|
71
|
-
// 若 frontmatter 缺 description,取正文第一行非标题段落
|
|
72
40
|
if (!description) {
|
|
73
41
|
const rest = trimmed.slice(secondDash + 4).trim();
|
|
74
42
|
const firstLine = rest.split("\n").find((l) => l.trim() && !l.trim().startsWith("#"));
|
|
@@ -88,7 +56,6 @@ export function parseSkillFrontmatter(content, fallbackName) {
|
|
|
88
56
|
}
|
|
89
57
|
return { name, description, disableModelInvocation, allowedTools };
|
|
90
58
|
}
|
|
91
|
-
/** 规范化计算全局 Agent 目录 */
|
|
92
59
|
export function resolveGlobalAgentDir(explicitAgentDir) {
|
|
93
60
|
if (explicitAgentDir?.trim())
|
|
94
61
|
return explicitAgentDir.trim();
|
|
@@ -96,9 +63,6 @@ export function resolveGlobalAgentDir(explicitAgentDir) {
|
|
|
96
63
|
return process.env.PI_CODING_AGENT_DIR.trim();
|
|
97
64
|
return join(homedir(), ".pi", "agent");
|
|
98
65
|
}
|
|
99
|
-
/**
|
|
100
|
-
* 收集当前环境所有可能存在技能的候选目录。
|
|
101
|
-
*/
|
|
102
66
|
export function getMultiAgentSkillCandidateDirs(opts) {
|
|
103
67
|
const dirs = [];
|
|
104
68
|
const seenPaths = new Set();
|
|
@@ -112,7 +76,6 @@ export function getMultiAgentSkillCandidateDirs(opts) {
|
|
|
112
76
|
const cwd = opts.cwd ? resolve(opts.cwd) : "";
|
|
113
77
|
const home = opts.homeDir ? resolve(opts.homeDir) : homedir();
|
|
114
78
|
const agentDir = resolveGlobalAgentDir(opts.agentDir);
|
|
115
|
-
// 1. 本地工作区(CWD 及其声明的多根工作区)
|
|
116
79
|
const rootDirs = [cwd];
|
|
117
80
|
if (Array.isArray(opts.workspaceRoots)) {
|
|
118
81
|
for (const r of opts.workspaceRoots) {
|
|
@@ -123,7 +86,6 @@ export function getMultiAgentSkillCandidateDirs(opts) {
|
|
|
123
86
|
for (const r of rootDirs) {
|
|
124
87
|
if (!r)
|
|
125
88
|
continue;
|
|
126
|
-
// 优先级最高的各 Agent 本地目录
|
|
127
89
|
add(join(r, ".pi", "skills"), "pi", "project", 0);
|
|
128
90
|
add(join(r, ".agents", "skills"), "agents", "project", 0);
|
|
129
91
|
add(join(r, ".claude", "skills"), "claude", "project", 0);
|
|
@@ -132,47 +94,35 @@ export function getMultiAgentSkillCandidateDirs(opts) {
|
|
|
132
94
|
add(join(r, ".github", "skills"), "github", "project", 0);
|
|
133
95
|
add(join(r, ".opencode", "skills"), "opencode", "project", 0);
|
|
134
96
|
}
|
|
135
|
-
// 2. 祖先目录链回溯(向上最多 6 层,直到文件系统根、用户主目录或 git 根)
|
|
136
97
|
if (cwd && opts.scanAncestors !== false) {
|
|
137
98
|
const maxDepth = typeof opts.maxAncestorDepth === "number" ? opts.maxAncestorDepth : 6;
|
|
138
99
|
let cur = dirname(cwd);
|
|
139
100
|
for (let i = 1; i <= maxDepth && cur && cur !== dirname(cur); i++, cur = dirname(cur)) {
|
|
140
|
-
// 若回溯到了用户家目录,祖先扫描终止(家目录层级归属于 opts.includeHome 管辖,避免污染祖先 scope)
|
|
141
101
|
if (cur === home)
|
|
142
102
|
break;
|
|
143
103
|
add(join(cur, ".pi", "skills"), "pi", "ancestor", i);
|
|
144
104
|
add(join(cur, ".agents", "skills"), "agents", "ancestor", i);
|
|
145
105
|
add(join(cur, ".claude", "skills"), "claude", "ancestor", i);
|
|
146
106
|
add(join(cur, ".cursor", "skills"), "cursor", "ancestor", i);
|
|
147
|
-
// 遇到 .git 目录说明已达仓库顶层,再上一层通常不是同个项目
|
|
148
107
|
if (existsSync(join(cur, ".git"))) {
|
|
149
108
|
break;
|
|
150
109
|
}
|
|
151
110
|
}
|
|
152
111
|
}
|
|
153
|
-
// 3. 用户全局主目录(各类 Agent 的全局配置区)
|
|
154
|
-
// 注意:agentDir 作为显式传入或配置的全局 Agent 目录,不受 includeHome 控制(includeHome 仅控制是否扫描系统 ~ 家目录下的各第三方 agent 目录)
|
|
155
112
|
add(join(agentDir, "skills"), "pi", "global", 0);
|
|
156
113
|
if (opts.includeHome !== false) {
|
|
157
|
-
// 通用 Agent 规范全局目录 (issue #669)
|
|
158
114
|
add(join(home, ".agents", "skills"), "agents", "global", 0);
|
|
159
|
-
// Claude Code 全局目录
|
|
160
115
|
add(join(home, ".claude", "skills"), "claude", "global", 0);
|
|
161
|
-
// Cursor 全局目录
|
|
162
116
|
add(join(home, ".cursor", "skills"), "cursor", "global", 0);
|
|
163
|
-
// Windsurf / Codeium 全局目录
|
|
164
117
|
add(join(home, ".windsurf", "skills"), "windsurf", "global", 0);
|
|
165
118
|
add(join(home, ".codeium", "windsurf", "skills"), "windsurf", "global", 0);
|
|
166
|
-
// OpenCode / Cline / Roo Code 全局目录
|
|
167
119
|
add(join(home, ".config", "opencode", "skills"), "opencode", "global", 0);
|
|
168
120
|
add(join(home, ".cline", "skills"), "cline", "global", 0);
|
|
169
121
|
add(join(home, ".roo-code", "skills"), "roo", "global", 0);
|
|
170
|
-
// WebUI 本地数据目录
|
|
171
122
|
if (opts.dataDir) {
|
|
172
123
|
add(join(opts.dataDir, "skills"), "data-dir", "global", 0);
|
|
173
124
|
}
|
|
174
125
|
}
|
|
175
|
-
// 4. npm 技能包目录(已安装的插件与技能包)
|
|
176
126
|
if (opts.includeNpm !== false) {
|
|
177
127
|
const npmRoots = [join(agentDir, "npm", "node_modules")];
|
|
178
128
|
if (cwd) {
|
|
@@ -190,7 +140,6 @@ export function getMultiAgentSkillCandidateDirs(opts) {
|
|
|
190
140
|
add(join(npmRoot, entry.name, "skills"), "npm", "package", 0);
|
|
191
141
|
}
|
|
192
142
|
else {
|
|
193
|
-
// scoped package: @org/pkg/skills
|
|
194
143
|
try {
|
|
195
144
|
const subEntries = readdirSync(join(npmRoot, entry.name), { withFileTypes: true });
|
|
196
145
|
for (const sub of subEntries) {
|
|
@@ -199,22 +148,16 @@ export function getMultiAgentSkillCandidateDirs(opts) {
|
|
|
199
148
|
}
|
|
200
149
|
}
|
|
201
150
|
}
|
|
202
|
-
catch {
|
|
203
|
-
/* 忽略坏目录 */
|
|
204
|
-
}
|
|
151
|
+
catch { }
|
|
205
152
|
}
|
|
206
153
|
}
|
|
207
154
|
}
|
|
208
|
-
catch {
|
|
209
|
-
/* 忽略读取错误 */
|
|
210
|
-
}
|
|
155
|
+
catch { }
|
|
211
156
|
}
|
|
212
157
|
}
|
|
213
158
|
return dirs;
|
|
214
159
|
}
|
|
215
|
-
/** 计算技能来源条目的综合排序得分(用于同名决议:高分优先覆盖) */
|
|
216
160
|
function getSkillPriorityScore(skill) {
|
|
217
|
-
// Scope 基础分
|
|
218
161
|
let scopeScore = 0;
|
|
219
162
|
if (skill.scope === "project")
|
|
220
163
|
scopeScore = 1000;
|
|
@@ -224,7 +167,6 @@ function getSkillPriorityScore(skill) {
|
|
|
224
167
|
scopeScore = 500;
|
|
225
168
|
else if (skill.scope === "package")
|
|
226
169
|
scopeScore = 200;
|
|
227
|
-
// Source 优先分(同 scope 下优先级)
|
|
228
170
|
let sourceScore = 0;
|
|
229
171
|
switch (skill.source) {
|
|
230
172
|
case "pi":
|
|
@@ -260,12 +202,8 @@ function getSkillPriorityScore(skill) {
|
|
|
260
202
|
}
|
|
261
203
|
return scopeScore + sourceScore;
|
|
262
204
|
}
|
|
263
|
-
/**
|
|
264
|
-
* 递归/顺序扫描全源各候选目录,发现并整合来自所有 Agent 的技能。
|
|
265
|
-
*/
|
|
266
205
|
export function discoverDiskSkills(opts) {
|
|
267
206
|
const candidateDirs = getMultiAgentSkillCandidateDirs(opts);
|
|
268
|
-
// key: skillName.toLowerCase() -> 候选列表
|
|
269
207
|
const skillCandidates = new Map();
|
|
270
208
|
for (const candidate of candidateDirs) {
|
|
271
209
|
if (!existsSync(candidate.path))
|
|
@@ -276,7 +214,6 @@ export function discoverDiskSkills(opts) {
|
|
|
276
214
|
if (entry.name.startsWith("."))
|
|
277
215
|
continue;
|
|
278
216
|
if (entry.isDirectory()) {
|
|
279
|
-
// 1. 目录型标准结构:<baseDir>/<entry>/SKILL.md
|
|
280
217
|
const skillMd = join(candidate.path, entry.name, "SKILL.md");
|
|
281
218
|
if (existsSync(skillMd)) {
|
|
282
219
|
try {
|
|
@@ -298,12 +235,9 @@ export function discoverDiskSkills(opts) {
|
|
|
298
235
|
list.push(item);
|
|
299
236
|
skillCandidates.set(key, list);
|
|
300
237
|
}
|
|
301
|
-
catch {
|
|
302
|
-
/* 忽略单文件损坏 */
|
|
303
|
-
}
|
|
238
|
+
catch { }
|
|
304
239
|
}
|
|
305
240
|
else {
|
|
306
|
-
// 2. 检查单层分类子目录:<baseDir>/<category>/<skill>/SKILL.md
|
|
307
241
|
try {
|
|
308
242
|
const subEntries = readdirSync(join(candidate.path, entry.name), { withFileTypes: true });
|
|
309
243
|
for (const sub of subEntries) {
|
|
@@ -338,7 +272,6 @@ export function discoverDiskSkills(opts) {
|
|
|
338
272
|
}
|
|
339
273
|
}
|
|
340
274
|
else if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
341
|
-
// 3. 单文件 Markdown 形式:<baseDir>/<name>.md
|
|
342
275
|
const filePath = join(candidate.path, entry.name);
|
|
343
276
|
const base = basename(entry.name, ".md");
|
|
344
277
|
try {
|
|
@@ -360,21 +293,16 @@ export function discoverDiskSkills(opts) {
|
|
|
360
293
|
list.push(item);
|
|
361
294
|
skillCandidates.set(key, list);
|
|
362
295
|
}
|
|
363
|
-
catch {
|
|
364
|
-
/* 忽略单文件损坏 */
|
|
365
|
-
}
|
|
296
|
+
catch { }
|
|
366
297
|
}
|
|
367
298
|
}
|
|
368
299
|
}
|
|
369
|
-
catch {
|
|
370
|
-
/* 目录读取异常静默跳过 */
|
|
371
|
-
}
|
|
300
|
+
catch { }
|
|
372
301
|
}
|
|
373
302
|
const results = [];
|
|
374
303
|
for (const list of skillCandidates.values()) {
|
|
375
304
|
if (list.length === 0)
|
|
376
305
|
continue;
|
|
377
|
-
// 按照优先级得分降序排序,取最高分的作为主技能
|
|
378
306
|
list.sort((a, b) => getSkillPriorityScore(b) - getSkillPriorityScore(a));
|
|
379
307
|
if (opts.includeConflicts) {
|
|
380
308
|
results.push(...list);
|
|
@@ -383,11 +311,9 @@ export function discoverDiskSkills(opts) {
|
|
|
383
311
|
results.push(list[0]);
|
|
384
312
|
}
|
|
385
313
|
}
|
|
386
|
-
// 保持名称排序以提供稳定确定性
|
|
387
314
|
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
388
315
|
return results;
|
|
389
316
|
}
|
|
390
|
-
/** 读取技能完整指令正文(若含 frontmatter,保留或剥离后返回有效指令) */
|
|
391
317
|
export function readSkillInstruction(filePath) {
|
|
392
318
|
if (!existsSync(filePath))
|
|
393
319
|
return "";
|
|
@@ -399,17 +325,11 @@ export function readSkillInstruction(filePath) {
|
|
|
399
325
|
return "";
|
|
400
326
|
}
|
|
401
327
|
}
|
|
402
|
-
/**
|
|
403
|
-
* 跨 Agent 技能与 SDK 原生技能集合并器。
|
|
404
|
-
* 将从磁盘多来源扫描整合出的技能,注入到现有技能列表中(按 name 去重,已存在的保留原有对象并补齐 filePath)。
|
|
405
|
-
*/
|
|
406
328
|
export function mergeSkillCollections(existingSkills, discoveredSkills) {
|
|
407
329
|
const map = new Map();
|
|
408
|
-
// 1. 先加入已有技能
|
|
409
330
|
for (const s of existingSkills) {
|
|
410
331
|
map.set(s.name.toLowerCase(), { ...s });
|
|
411
332
|
}
|
|
412
|
-
// 2. 将发现的新技能合并进来
|
|
413
333
|
for (const d of discoveredSkills) {
|
|
414
334
|
const key = d.name.toLowerCase();
|
|
415
335
|
const current = map.get(key);
|
|
@@ -425,16 +345,11 @@ export function mergeSkillCollections(existingSkills, discoveredSkills) {
|
|
|
425
345
|
});
|
|
426
346
|
}
|
|
427
347
|
else if (!current.filePath && d.filePath) {
|
|
428
|
-
// 如果已有技能缺少物理路径,补齐物理路径
|
|
429
348
|
current.filePath = d.filePath;
|
|
430
349
|
}
|
|
431
350
|
}
|
|
432
351
|
return [...map.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
433
352
|
}
|
|
434
|
-
/**
|
|
435
|
-
* 判断指定 skill 名称是否仍物理存在于任意可用 Agent 来源目录中。
|
|
436
|
-
* 供 settings-service 的清理逻辑与验证逻辑使用,替代手写的固定目录判断。
|
|
437
|
-
*/
|
|
438
353
|
export function isSkillStillOnDisk(skillName, opts) {
|
|
439
354
|
const n = skillName.trim().toLowerCase();
|
|
440
355
|
if (!n)
|
|
@@ -450,11 +365,9 @@ export function isSkillStillOnDisk(skillName, opts) {
|
|
|
450
365
|
for (const candidate of candidateDirs) {
|
|
451
366
|
if (!existsSync(candidate.path))
|
|
452
367
|
continue;
|
|
453
|
-
// 检查目录结构: <dir>/<skillName>/SKILL.md
|
|
454
368
|
const dirSkill = join(candidate.path, skillName, "SKILL.md");
|
|
455
369
|
if (existsSync(dirSkill))
|
|
456
370
|
return true;
|
|
457
|
-
// 检查单文件结构: <dir>/<skillName>.md
|
|
458
371
|
const mdSkill = join(candidate.path, `${skillName}.md`);
|
|
459
372
|
if (existsSync(mdSkill))
|
|
460
373
|
return true;
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* skill-maintenance.ts — 通用多智能体技能(Universal Multi-Agent Skills)维护管理工具。
|
|
3
|
-
*
|
|
4
|
-
* 功能定位:
|
|
5
|
-
* 1. 跨智能体全源技能扫描与结构化维护报告(输出各生态覆盖、作用域、同名覆盖冲突);
|
|
6
|
-
* 2. 技能文件合规性与健康检查(文件大小、8KB 上限、frontmatter 规范等);
|
|
7
|
-
* 3. 跨 Agent 技能物理同步/软链维护(一键汇聚外部技能至当前工作区或全局目录)。
|
|
8
|
-
*/
|
|
9
1
|
import { closeSync, constants, copyFileSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync, } from "node:fs";
|
|
10
2
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
11
3
|
import { discoverDiskSkills, getMultiAgentSkillCandidateDirs, parseSkillFrontmatter, } from "./skill-discovery.js";
|
|
12
4
|
import { decodeText } from "./text-sniff.js";
|
|
13
|
-
/** 执行全源技能扫描与维护统计 */
|
|
14
5
|
export function scanAllAgentSkills(opts) {
|
|
15
6
|
const allDirs = getMultiAgentSkillCandidateDirs(opts);
|
|
16
7
|
const existingDirs = allDirs.filter((d) => existsSync(d.path)).map((d) => d.path);
|
|
17
|
-
// 获取胜出的主技能
|
|
18
8
|
const primarySkills = discoverDiskSkills({ ...opts, includeConflicts: false });
|
|
19
|
-
// 获取所有发现的候选技能(包含同名被覆盖的)
|
|
20
9
|
const allSkills = discoverDiskSkills({ ...opts, includeConflicts: true });
|
|
21
10
|
const bySource = {
|
|
22
11
|
pi: 0,
|
|
@@ -44,7 +33,6 @@ export function scanAllAgentSkills(opts) {
|
|
|
44
33
|
if (s.scope)
|
|
45
34
|
byScope[s.scope] = (byScope[s.scope] || 0) + 1;
|
|
46
35
|
}
|
|
47
|
-
// 识别冲突覆盖
|
|
48
36
|
const mapAll = new Map();
|
|
49
37
|
for (const s of allSkills) {
|
|
50
38
|
const key = s.name.toLowerCase();
|
|
@@ -77,7 +65,6 @@ export function scanAllAgentSkills(opts) {
|
|
|
77
65
|
scannedDirs: existingDirs,
|
|
78
66
|
};
|
|
79
67
|
}
|
|
80
|
-
/** 生成格式化的人类与智能体可读维护报告 */
|
|
81
68
|
export function generateSkillsReport(result, lang = "zh") {
|
|
82
69
|
const isZh = lang === "zh";
|
|
83
70
|
const lines = [];
|
|
@@ -86,7 +73,6 @@ export function generateSkillsReport(result, lang = "zh") {
|
|
|
86
73
|
? `整合唯一技能数: ${result.totalUnique} 个 (全源物理发现: ${result.totalDiscovered} 个, 扫描目录: ${result.scannedDirs.length} 处)`
|
|
87
74
|
: `Total Unique Skills: ${result.totalUnique} (Discovered: ${result.totalDiscovered}, Scanned Dirs: ${result.scannedDirs.length})`);
|
|
88
75
|
lines.push("");
|
|
89
|
-
// 来源分布
|
|
90
76
|
lines.push(isZh ? "【各智能体生态分布】:" : "[Agent Distribution]:");
|
|
91
77
|
for (const [source, count] of Object.entries(result.bySource)) {
|
|
92
78
|
if (count > 0) {
|
|
@@ -94,7 +80,6 @@ export function generateSkillsReport(result, lang = "zh") {
|
|
|
94
80
|
}
|
|
95
81
|
}
|
|
96
82
|
lines.push("");
|
|
97
|
-
// 作用域分布
|
|
98
83
|
lines.push(isZh ? "【作用域层级分布】:" : "[Scope Distribution]:");
|
|
99
84
|
for (const [scope, count] of Object.entries(result.byScope)) {
|
|
100
85
|
if (count > 0) {
|
|
@@ -102,7 +87,6 @@ export function generateSkillsReport(result, lang = "zh") {
|
|
|
102
87
|
}
|
|
103
88
|
}
|
|
104
89
|
lines.push("");
|
|
105
|
-
// 冲突与覆盖信息
|
|
106
90
|
if (result.conflicts.length > 0) {
|
|
107
91
|
lines.push(isZh
|
|
108
92
|
? `【同名技能优先级决议 (${result.conflicts.length} 处)】:`
|
|
@@ -116,7 +100,6 @@ export function generateSkillsReport(result, lang = "zh") {
|
|
|
116
100
|
}
|
|
117
101
|
lines.push("");
|
|
118
102
|
}
|
|
119
|
-
// 技能简表
|
|
120
103
|
lines.push(isZh ? "【整合生效技能清单】:" : "[Effective Skills Catalog]:");
|
|
121
104
|
for (const s of result.skills) {
|
|
122
105
|
const tag = `[${(s.source || "custom").toUpperCase()}|${s.scope || "global"}]`;
|
|
@@ -124,7 +107,6 @@ export function generateSkillsReport(result, lang = "zh") {
|
|
|
124
107
|
}
|
|
125
108
|
return lines.join("\n");
|
|
126
109
|
}
|
|
127
|
-
/** 校验技能文件健康状态与规格预算 */
|
|
128
110
|
export function verifySkillFile(filePath) {
|
|
129
111
|
const issues = [];
|
|
130
112
|
if (!existsSync(filePath)) {
|
|
@@ -178,12 +160,10 @@ export function verifySkillFile(filePath) {
|
|
|
178
160
|
issues,
|
|
179
161
|
};
|
|
180
162
|
}
|
|
181
|
-
/** Path-segment comparison also handles sibling prefixes and Windows drive boundaries. */
|
|
182
163
|
function isWithin(root, path) {
|
|
183
164
|
const rel = relative(root, path);
|
|
184
165
|
return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
|
|
185
166
|
}
|
|
186
|
-
/** Resolve existing ancestors too, so a missing target below a junction cannot hide recursion. */
|
|
187
167
|
function physicalPath(path) {
|
|
188
168
|
try {
|
|
189
169
|
return realpathSync(path);
|
|
@@ -199,7 +179,7 @@ function physicalPath(path) {
|
|
|
199
179
|
}
|
|
200
180
|
function destinationExists(path) {
|
|
201
181
|
try {
|
|
202
|
-
lstatSync(path);
|
|
182
|
+
lstatSync(path);
|
|
203
183
|
return true;
|
|
204
184
|
}
|
|
205
185
|
catch (err) {
|
|
@@ -208,7 +188,6 @@ function destinationExists(path) {
|
|
|
208
188
|
return false;
|
|
209
189
|
}
|
|
210
190
|
}
|
|
211
|
-
/** Copy internal links as resources; reject escapes and cycles before following them. */
|
|
212
191
|
function copySkillDirectory(source, destination, root, ancestors = new Set()) {
|
|
213
192
|
const physical = realpathSync(source);
|
|
214
193
|
if (!isWithin(root, physical))
|
|
@@ -234,10 +213,6 @@ function copySkillDirectory(source, destination, root, ancestors = new Set()) {
|
|
|
234
213
|
}
|
|
235
214
|
}
|
|
236
215
|
}
|
|
237
|
-
/**
|
|
238
|
-
* 跨 Agent 技能物理同步/软链维护:
|
|
239
|
-
* 将外部 Agent(如 Claude Code 或通用 Agents)的技能同步或软链至工作区或指定目录中。
|
|
240
|
-
*/
|
|
241
216
|
export function syncAgentSkills(opts) {
|
|
242
217
|
const targetDir = resolve(opts.targetDir || join(opts.cwd, ".pi", "skills"));
|
|
243
218
|
const mode = opts.mode || "copy";
|
|
@@ -250,7 +225,6 @@ export function syncAgentSkills(opts) {
|
|
|
250
225
|
if (targetSources && skill.source && !targetSources.has(skill.source)) {
|
|
251
226
|
continue;
|
|
252
227
|
}
|
|
253
|
-
// Names come from untrusted frontmatter, not necessarily from a directory name.
|
|
254
228
|
if (!skill.name ||
|
|
255
229
|
skill.name === "." ||
|
|
256
230
|
skill.name === ".." ||
|
|
@@ -288,7 +262,6 @@ export function syncAgentSkills(opts) {
|
|
|
288
262
|
symlinkSync(source, destination, isDirSkill ? (process.platform === "win32" ? "junction" : "dir") : "file");
|
|
289
263
|
}
|
|
290
264
|
else {
|
|
291
|
-
// Exclusively claim the destination; cleanup must never remove a conflicting entry.
|
|
292
265
|
if (isDirSkill) {
|
|
293
266
|
mkdirSync(destination);
|
|
294
267
|
ownedDestination = true;
|
|
@@ -1,52 +1,28 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// skill-tool.ts — 让 AI 按名取技能全文(名录 + skill 工具)
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// 背景:{{skills}} 默认只渲染名录(name/description/location),引导语原来让
|
|
5
|
-
// 模型“用 read 工具加载技能文件”——模型要自己拼 location 路径调 read,权限大
|
|
6
|
-
// 且容易猜错路径。本工具提供专用通道:skill({name}) 精确命中,读文件包成与
|
|
7
|
-
// SDK 一致的 `<skill name location>` 块(前端 parseSkillBlock 直接认,渲染折叠
|
|
8
|
-
// 卡片);不给 name 则返回名录 + 用法,找错名则给纠错列表。
|
|
9
|
-
//
|
|
10
|
-
// 约束(第 1 条定稿,不破坏现有体系):
|
|
11
|
-
// - 名录渲染不动;skillsFullText 名单注入不动;/skill:name 手势不动;
|
|
12
|
-
// - 正文每次重读(不缓存),单文件 8KB 封顶(与 fillSkillContents 同口径);
|
|
13
|
-
// - 禁用集由 host 在调用时过滤(与 skillsOverride 主会话语义一致),工具侧
|
|
14
|
-
// 查不到被禁用的技能;
|
|
15
|
-
// - 与 SDK 同名工具撞名时 customTools 按 name 覆盖(bash 本体是先例)。
|
|
16
|
-
//
|
|
17
|
-
// 文案约定:工具 definition(description/promptSnippet/promptGuidelines)为纯英文;per-call
|
|
18
|
-
// 返回文本按 lang 取 pick(lang, zh, en, key),缺表回落英文内联。
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
1
|
import { statSync, readFileSync } from "node:fs";
|
|
21
2
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
22
3
|
import { Type } from "typebox";
|
|
23
4
|
import { pick } from "./i18n.js";
|
|
24
5
|
import { SKILL_TOOL_NAME } from "./tool-manager.js";
|
|
25
6
|
import { decodeText } from "./text-sniff.js";
|
|
26
|
-
/** 单文件正文上限的出厂默认(= 设置项 skillsMaxFileBytes 的默认值,8KB)。 */
|
|
27
7
|
export const SKILL_TOOL_FILE_CAP = 8192;
|
|
28
|
-
/** 实际生效的单文件上限:非负整数,非法/未设置回退出厂默认。0 = 不设单文件上限。 */
|
|
29
8
|
function effectiveFileCap(host) {
|
|
30
9
|
const raw = host.maxFileBytes?.();
|
|
31
10
|
if (typeof raw === "number" && Number.isFinite(raw) && raw >= 0)
|
|
32
11
|
return Math.floor(raw);
|
|
33
12
|
return SKILL_TOOL_FILE_CAP;
|
|
34
13
|
}
|
|
35
|
-
/** 精确名匹配(大小写敏感,与 skillsFullText 名单语义一致)。 */
|
|
36
14
|
export function findSkill(skills, name) {
|
|
37
15
|
const n = name.trim();
|
|
38
16
|
if (!n)
|
|
39
17
|
return undefined;
|
|
40
18
|
return skills.find((s) => s.name === n);
|
|
41
19
|
}
|
|
42
|
-
/** 大小写不敏感子串纠错(空 query 全匹配,调用方截行数)。 */
|
|
43
20
|
export function suggestSkills(skills, name) {
|
|
44
21
|
const q = name.trim().toLowerCase();
|
|
45
22
|
if (!q)
|
|
46
23
|
return skills;
|
|
47
24
|
return skills.filter((s) => s.name.toLowerCase().includes(q) || s.description.toLowerCase().includes(q));
|
|
48
25
|
}
|
|
49
|
-
/** 名录文本(一行一名 + 一句话描述,无技能时给空目录句)。 */
|
|
50
26
|
export function formatSkillCatalog(skills, lang) {
|
|
51
27
|
if (skills.length === 0) {
|
|
52
28
|
return pick(lang, "当前没有可用技能。", "No skills are currently available.", "skill.catalog.empty");
|
|
@@ -58,7 +34,6 @@ export function formatSkillCatalog(skills, lang) {
|
|
|
58
34
|
});
|
|
59
35
|
return `${head}\n${lines.join("\n")}`;
|
|
60
36
|
}
|
|
61
|
-
/** 生成多智能体技能整合分布统计报告文本 */
|
|
62
37
|
export function formatSkillSourcesReport(skills, lang) {
|
|
63
38
|
const counts = {};
|
|
64
39
|
for (const s of skills) {
|
|
@@ -77,7 +52,6 @@ export function formatSkillSourcesReport(skills, lang) {
|
|
|
77
52
|
lines.push(formatSkillCatalog(skills, lang));
|
|
78
53
|
return lines.join("\n");
|
|
79
54
|
}
|
|
80
|
-
/** 技能全文块(与 SDK 的 /skill:name 展开格式一致,前端按 skill 卡片渲染)。 */
|
|
81
55
|
export function renderSkillContent(name, location, body) {
|
|
82
56
|
return `<skill name="${name}" location="${location}">\n${body.trim()}\n</skill>`;
|
|
83
57
|
}
|
|
@@ -115,27 +89,23 @@ export function makeSkillTool(host, lang) {
|
|
|
115
89
|
if (action === "report") {
|
|
116
90
|
return text(formatSkillSourcesReport(skills, L), { count: skills.length });
|
|
117
91
|
}
|
|
118
|
-
// 无名或请求列表 → 名录 + 用法。
|
|
119
92
|
if (!name || action === "list") {
|
|
120
93
|
const hint = pick(L, "用 skill({name}) 按名取全文。", "Use skill({name}) to load the full text by name.", "skill.catalog.hint");
|
|
121
94
|
return text(`${formatSkillCatalog(skills, L)}\n${hint}`, { count: skills.length });
|
|
122
95
|
}
|
|
123
96
|
const found = findSkill(skills, name);
|
|
124
|
-
// 找错名 → 纠错列表(不抛错,报名录)。
|
|
125
97
|
if (!found) {
|
|
126
98
|
const sug = suggestSkills(skills, name).slice(0, 10);
|
|
127
99
|
const head = pick(L, `没有名为 ${name} 的技能。`, `No skill named ${name}.`, "skill.not.found", { name });
|
|
128
100
|
const sugText = sug.length > 0 ? `\n${formatSkillCatalog(sug, L)}` : `\n${formatSkillCatalog(skills, L)}`;
|
|
129
101
|
return text(`${head}${sugText}`, { name, count: skills.length });
|
|
130
102
|
}
|
|
131
|
-
// 命中 → 最好努力读正文(每次重读,不缓存;失败/超限给可读错)。
|
|
132
103
|
if (!found.filePath) {
|
|
133
104
|
return text(pick(L, `技能 ${name} 没有关联文件路径,取不到全文。`, `Skill ${name} has no file path; full text unavailable.`, "skill.no.filepath", { name }));
|
|
134
105
|
}
|
|
135
106
|
try {
|
|
136
107
|
const st = statSync(found.filePath);
|
|
137
108
|
const cap = effectiveFileCap(host);
|
|
138
|
-
// 0 = 不设单文件上限(设置项显式打开);否则超限回落可读错误,不截断正文。
|
|
139
109
|
const kb = Math.max(1, Math.round(cap / 1024));
|
|
140
110
|
if (!st.isFile() || st.size <= 0 || (cap > 0 && st.size > cap)) {
|
|
141
111
|
return text(pick(L, `技能 ${name} 的文件不可读(不存在/超 ${kb}KB 上限)。`, `Skill ${name} file unreadable (missing or over the ${kb}KB cap).`, "skill.file.unreadable", { name, kb }));
|