@waq666/pneuma 0.0.0-stage → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +144 -2
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +13 -0
- package/lib/app/App.js +1498 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +32 -0
- package/lib/app/ChatView.js +198 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +272 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/ToolCard.d.ts +5 -0
- package/lib/app/ToolCard.js +40 -0
- package/lib/app/TranscriptOverlay.d.ts +12 -0
- package/lib/app/TranscriptOverlay.js +17 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +66 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +27 -0
- package/lib/app/click.js +89 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/theme.d.ts +166 -0
- package/lib/app/theme.js +141 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +272 -0
- package/lib/core/llm.js +548 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +862 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +425 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Plugin } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { DscRuntime, UsageStatsView } from '../contract.js';
|
|
3
|
+
export declare const commandsPlugin: Plugin.Object;
|
|
4
|
+
/** 兼容导出:v2 的 runCommand(App.tsx 零逻辑改动,仅 import 路径变化)。 */
|
|
5
|
+
export declare function runCommand(input: string, runtime: DscRuntime, ui: import('../services/types.js').CommandContext): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* /usage 的文本组装(独立成函数便于脱离命令体系直测)。
|
|
8
|
+
* 缓存命中率只统计端点上报过明细的请求(usage-log 的口径),没上报的不掺进来。
|
|
9
|
+
*/
|
|
10
|
+
export declare function usageReport(stats: UsageStatsView): string;
|
|
11
|
+
/**
|
|
12
|
+
* /status 的文本组装(独立成函数便于脱离命令体系直测)。
|
|
13
|
+
* tokens 由调用方用 core/compact 的 estimateTokens 算——数字与自动压缩触发判定同源。
|
|
14
|
+
*/
|
|
15
|
+
export declare function statusReport(input: {
|
|
16
|
+
provider: string;
|
|
17
|
+
model: string;
|
|
18
|
+
window: number;
|
|
19
|
+
tokens: number;
|
|
20
|
+
messageCount: number;
|
|
21
|
+
toolCount: number;
|
|
22
|
+
autoCompactPercent: number;
|
|
23
|
+
}): string;
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* commands 插件:provide `commands` 服务(斜杠命令注册表 + 派发)。
|
|
3
|
+
* 内置命令改为注册表条目,外部插件经 ctx.commands.register 注入新命令后
|
|
4
|
+
* 自动进入 /help、补全与派发。
|
|
5
|
+
*
|
|
6
|
+
* spec 表与补全函数都在 core/commands-completion.ts(渲染层直接 import 那份;
|
|
7
|
+
* 本模块顶层的 node 内置模块会把渲染进程炸成白屏——取数走 core/git-info)。
|
|
8
|
+
*
|
|
9
|
+
* @module dsc/plugins/commands
|
|
10
|
+
*/
|
|
11
|
+
import { mkdirSync, writeFileSync, readFileSync } from 'node:fs';
|
|
12
|
+
import { spawn } from 'node:child_process';
|
|
13
|
+
import { dirname, join } from 'node:path';
|
|
14
|
+
import { collectWorkingTree, reviewMessage } from '../core/git-info.js';
|
|
15
|
+
import { estimateTokens } from '../core/compact.js';
|
|
16
|
+
import { exportSessionMarkdown } from '../core/session-export.js';
|
|
17
|
+
import { checkForUpdate } from '../core/update-check.js';
|
|
18
|
+
import { errText } from '../core/err-text.js';
|
|
19
|
+
import { discoverThirdPartyUiArtifacts, readUiPluginManifestReport } from '../core/ui-bundles.js';
|
|
20
|
+
import { dscPath } from '../core/path-policy.js';
|
|
21
|
+
import { trustUiPlugin } from '../core/plugin-registry.js';
|
|
22
|
+
import { DSC_VERSION } from '../core/version.js';
|
|
23
|
+
import { addExtraSpec, allSpecs, BUILT_IN_COMMANDS, expandCommand, helpText, removeExtraSpec, } from '../core/commands-completion.js';
|
|
24
|
+
/** 当前壳的 `@dsc/ui` 契约版本(内置清单顶层那个);读不到就不设门(发现层会给出问题清单)。 */
|
|
25
|
+
function shellApiVersionForTrust() {
|
|
26
|
+
return readUiPluginManifestReport().apiVersion;
|
|
27
|
+
}
|
|
28
|
+
export const commandsPlugin = {
|
|
29
|
+
name: 'commands',
|
|
30
|
+
// /status 要问 llm 服务的窗口大小与当前端点名
|
|
31
|
+
inject: ['session', 'llm'],
|
|
32
|
+
provide: 'commands',
|
|
33
|
+
apply(ctx) {
|
|
34
|
+
const registry = new Map();
|
|
35
|
+
const service = {
|
|
36
|
+
register(spec, handler) {
|
|
37
|
+
// duringTask 以 BUILT_IN 表为准(spec 单一真源):内置名注册时把声明合并进来,
|
|
38
|
+
// 否则派发闸读到的注册 spec 缺 duringTask,回合中的 deny 全部落空。
|
|
39
|
+
const builtin = BUILT_IN_COMMANDS.find((entry) => entry.name === spec.name);
|
|
40
|
+
registry.set(spec.name, { spec: builtin ?? spec, handler });
|
|
41
|
+
if (!BUILT_IN_COMMANDS.some((entry) => entry.name === spec.name))
|
|
42
|
+
addExtraSpec(spec);
|
|
43
|
+
return () => {
|
|
44
|
+
if (registry.get(spec.name)?.handler === handler) {
|
|
45
|
+
registry.delete(spec.name);
|
|
46
|
+
removeExtraSpec(spec);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
specs() {
|
|
51
|
+
return allSpecs();
|
|
52
|
+
},
|
|
53
|
+
run(input, runtime, ui) {
|
|
54
|
+
if (!input.startsWith('/'))
|
|
55
|
+
return false;
|
|
56
|
+
const expanded = expandCommand(input);
|
|
57
|
+
const parts = expanded.slice(1).trim().split(/\s+/);
|
|
58
|
+
const command = parts[0] ?? '';
|
|
59
|
+
const args = parts.slice(1);
|
|
60
|
+
if (command === '') {
|
|
61
|
+
ui.notice(helpText(service.specs()));
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
const entry = registry.get(command);
|
|
65
|
+
if (entry === undefined) {
|
|
66
|
+
ui.notice(`未知命令:/${command}(/help 查看全部)`);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
// T44:可用性矩阵统一在派发这一闸——回合跑着的时候 deny 的命令挡下,
|
|
70
|
+
// 桌面 / TUI / 远端三端行为一致(以前只有桌面输入框自己禁了字)。
|
|
71
|
+
if (entry.spec.duringTask === 'deny' &&
|
|
72
|
+
runtime.getSnapshot().status.turnState !== 'idle') {
|
|
73
|
+
ui.notice(`/${command} 要等当前回合结束(或先打断)再用`);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
entry.handler({ args, runtime, ui });
|
|
77
|
+
return true;
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
// ---- 内置命令注册 ----
|
|
81
|
+
service.register({ name: 'help', args: '', description: '查看帮助' }, ({ ui }) => ui.notice(helpText(service.specs())));
|
|
82
|
+
service.register({ name: 'new', args: '', description: '新建会话' }, ({ runtime }) => void runtime.openSession(undefined));
|
|
83
|
+
service.register({ name: 'resume', args: '', description: '恢复历史会话' }, ({ ui }) => ui.openPicker());
|
|
84
|
+
service.register({ name: 'agents', args: '', description: '查看子代理与后台会话(转录只读)' }, ({ ui }) => ui.openAgents?.());
|
|
85
|
+
service.register({ name: 'settings', args: '', description: '打开设置页' }, ({ ui }) => ui.openSettings?.());
|
|
86
|
+
service.register({
|
|
87
|
+
name: 'model',
|
|
88
|
+
args: '<[端点/]模型名>',
|
|
89
|
+
description: '切换模型,下一次请求生效(无参数打开选择器)',
|
|
90
|
+
}, ({ args, runtime, ui }) => {
|
|
91
|
+
const model = args[0];
|
|
92
|
+
if (model === undefined || model === '') {
|
|
93
|
+
// 裸 /model 直接开选择器;用法提示只活在补全面板里(打 / 就能看到),
|
|
94
|
+
// 这里再发一条就变成常驻盒(0.6.66 用户反馈)。
|
|
95
|
+
ui.openModels();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
void runtime.setModel(model);
|
|
99
|
+
});
|
|
100
|
+
service.register({ name: 'status', args: '', description: '查看上下文占用与压缩余量' }, ({ ui }) => {
|
|
101
|
+
const session = ctx.session.current();
|
|
102
|
+
const messages = session.messages;
|
|
103
|
+
const compact = ctx.get('compact');
|
|
104
|
+
ui.notice(statusReport({
|
|
105
|
+
provider: ctx.llm.provider,
|
|
106
|
+
model: ctx.llm.model,
|
|
107
|
+
window: ctx.llm.contextWindow,
|
|
108
|
+
tokens: estimateTokens(messages),
|
|
109
|
+
messageCount: messages.length,
|
|
110
|
+
toolCount: messages.filter((message) => message.role === 'tool').length,
|
|
111
|
+
autoCompactPercent: compact !== undefined ? compact.describe().autoCompactPercent : 80,
|
|
112
|
+
}));
|
|
113
|
+
});
|
|
114
|
+
service.register({ name: 'usage', args: '', description: '查看累计用量统计(含缓存命中率)' }, ({ runtime, ui }) => {
|
|
115
|
+
void runtime
|
|
116
|
+
.usageStats()
|
|
117
|
+
.then((stats) => ui.notice(usageReport(stats)))
|
|
118
|
+
.catch((cause) => ui.notice(`/usage 失败:${cause instanceof Error ? cause.message : String(cause)}`));
|
|
119
|
+
});
|
|
120
|
+
service.register({ name: 'export', args: '[文件路径]', description: '导出当前会话为 markdown' }, ({ args, ui }) => {
|
|
121
|
+
const session = ctx.session.current();
|
|
122
|
+
if (session.messages.length === 0) {
|
|
123
|
+
ui.notice('这个会话还没有消息,没东西可导出。');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const stamp = new Date();
|
|
127
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
128
|
+
const target = args[0] ?? join(session.meta.cwd || process.cwd(), `pneuma-export-${session.meta.id.slice(0, 8)}-${stamp.getFullYear()}${pad(stamp.getMonth() + 1)}${pad(stamp.getDate())}-${pad(stamp.getHours())}${pad(stamp.getMinutes())}.md`);
|
|
129
|
+
const markdown = exportSessionMarkdown({
|
|
130
|
+
id: session.meta.id,
|
|
131
|
+
cwd: session.meta.cwd,
|
|
132
|
+
createdAt: session.meta.createdAt,
|
|
133
|
+
messages: session.messages,
|
|
134
|
+
});
|
|
135
|
+
try {
|
|
136
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
137
|
+
writeFileSync(target, markdown, 'utf8');
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
ui.notice(`导出失败:${errText(error)}`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
ui.notice(`已导出 ${session.messages.length} 条消息 → ${target}`);
|
|
144
|
+
});
|
|
145
|
+
service.register({ name: 'review', args: '[关注点]', description: '审查工作区未提交改动' }, ({ args, runtime, ui }) => {
|
|
146
|
+
const cwd = ctx.session.current().meta.cwd;
|
|
147
|
+
const focus = args.join(' ').trim();
|
|
148
|
+
void collectWorkingTree(cwd)
|
|
149
|
+
.then((collected) => {
|
|
150
|
+
if (collected === null) {
|
|
151
|
+
ui.notice('这里不是 git 仓库,/review 没有可审查的改动。');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (collected.diff === '' && collected.untracked.length === 0) {
|
|
155
|
+
ui.notice('工作区没有未提交的改动。');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// T18:subagent 插件开着就走只读审查队友——后台审,findings 直接出卡片,
|
|
159
|
+
// 不占用当前会话的模型轮;插件没开(或额度满)回落 v1 的主会话审查轮。
|
|
160
|
+
const review = ctx.get('review');
|
|
161
|
+
if (review !== undefined) {
|
|
162
|
+
const spawned = review.spawn({ ...collected, focus });
|
|
163
|
+
if (spawned.ok) {
|
|
164
|
+
ui.notice(`已派出只读审查队友 ${spawned.name},结论出来后直接出现在会话里`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
ui.notice(`/review 没派出审查队友(${spawned.reason}),改在本会话里审`);
|
|
168
|
+
}
|
|
169
|
+
// 组装一条审查请求走正常对话轮(runtime.submit → agent.followup):
|
|
170
|
+
// 回复就是审查意见,与用户自己贴着 diff 问「帮我看看」同一条链路。
|
|
171
|
+
runtime.submit(reviewMessage(collected, focus));
|
|
172
|
+
})
|
|
173
|
+
.catch((cause) => {
|
|
174
|
+
ui.notice(`/review 失败:${cause instanceof Error ? cause.message : String(cause)}`);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
service.register({ name: 'diff', args: '[文件]', description: '查看工作区未提交改动的 diff' }, ({ args, runtime, ui }) => {
|
|
178
|
+
const file = args[0];
|
|
179
|
+
void runtime
|
|
180
|
+
.dock('git-diff', file === undefined ? {} : { file })
|
|
181
|
+
.then((result) => {
|
|
182
|
+
const diff = result.diff ?? '';
|
|
183
|
+
ui.notice(diff === '' ? '工作区没有未提交的改动(或这里不是 git 仓库)。' : diff);
|
|
184
|
+
})
|
|
185
|
+
.catch((cause) => ui.notice(`/diff 失败:${cause instanceof Error ? cause.message : String(cause)}`));
|
|
186
|
+
});
|
|
187
|
+
service.register({ name: 'copy', args: '', description: '复制上一条回复到剪贴板' }, ({ runtime, ui }) => {
|
|
188
|
+
const entries = runtime.getSnapshot().entries;
|
|
189
|
+
let text = null;
|
|
190
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
191
|
+
const entry = entries[index];
|
|
192
|
+
if (entry !== undefined && entry.kind === 'text' && entry.text.trim() !== '') {
|
|
193
|
+
text = entry.text;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (text === null) {
|
|
198
|
+
ui.notice('还没有可复制的回复。');
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const command = process.platform === 'darwin' ? 'pbcopy' : process.platform === 'win32' ? 'clip' : 'wl-copy';
|
|
202
|
+
try {
|
|
203
|
+
const child = spawn(command, [], { stdio: ['pipe', 'ignore', 'ignore'] });
|
|
204
|
+
child.on('error', () => ui.notice(`复制失败:找不到 ${command} 命令`));
|
|
205
|
+
child.stdin?.end(text);
|
|
206
|
+
ui.notice(`已复制上一条回复(${text.length} 字符)到剪贴板`);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
ui.notice(`复制失败:${errText(error)}`);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
// 权限那三根旋钮各有一个入口,分工照着参考实现来:
|
|
213
|
+
// /permission —— 打包预设(沙箱 + 权限模式 + 审阅者三合一的快捷档,dsh 同名命令的口径);
|
|
214
|
+
// /policy —— 权限模式单档(细调;拼出非预设组合时预设读作「自定义」);
|
|
215
|
+
// /reviewer —— 审阅者单轴(谁来裁要问的事)。
|
|
216
|
+
// 三根都写 system 条目告知模型与用户,都记审计(在各自的服务里)。
|
|
217
|
+
const switchPolicy = ({ args, runtime, ui }) => {
|
|
218
|
+
const surface = runtime.getSnapshot().surfaces.policy;
|
|
219
|
+
const query = args[0]?.toLowerCase() ?? '';
|
|
220
|
+
if (query === '') {
|
|
221
|
+
ui.notice([
|
|
222
|
+
`当前权限模式:${surface.current}`,
|
|
223
|
+
...surface.options.map((option) => `· ${option.id} — ${option.label}:${option.hint}`),
|
|
224
|
+
'用法:/policy <档位>(支持前缀匹配,如 /policy full)',
|
|
225
|
+
].join('\n'));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const matches = surface.options.filter((option) => option.id.startsWith(query));
|
|
229
|
+
if (matches.length !== 1) {
|
|
230
|
+
ui.notice(matches.length === 0
|
|
231
|
+
? `未知权限档位:${args[0]}(可选:${surface.options.map((option) => option.id).join(' / ')})`
|
|
232
|
+
: `「${args[0]}」匹配到 ${matches.length} 个档位,请写全`);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
runtime.setPolicy(matches[0].id);
|
|
236
|
+
};
|
|
237
|
+
service.register({
|
|
238
|
+
name: 'policy',
|
|
239
|
+
args: '[readonly|auto-edit|full-access]',
|
|
240
|
+
description: '查看或切换权限模式(自动放行集那一轴)',
|
|
241
|
+
}, switchPolicy);
|
|
242
|
+
service.register({
|
|
243
|
+
name: 'reviewer',
|
|
244
|
+
args: '[user|auto-review]',
|
|
245
|
+
description: '查看或切换审批审阅者(要问的事先给谁看)',
|
|
246
|
+
}, ({ args, runtime, ui }) => {
|
|
247
|
+
const surface = runtime.getSnapshot().surfaces.policy;
|
|
248
|
+
const query = args[0]?.toLowerCase() ?? '';
|
|
249
|
+
if (query === '') {
|
|
250
|
+
ui.notice([
|
|
251
|
+
`当前审阅者:${surface.reviewer}`,
|
|
252
|
+
...surface.reviewerOptions.map((option) => `· ${option.id} — ${option.label}:${option.hint}`),
|
|
253
|
+
'用法:/reviewer <user|auto-review>',
|
|
254
|
+
].join('\n'));
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const matches = surface.reviewerOptions.filter((option) => option.id.startsWith(query));
|
|
258
|
+
if (matches.length !== 1) {
|
|
259
|
+
ui.notice(matches.length === 0
|
|
260
|
+
? `未知审阅者:${args[0]}(可选:${surface.reviewerOptions.map((option) => option.id).join(' / ')})`
|
|
261
|
+
: `「${args[0]}」匹配到 ${matches.length} 个审阅者,请写全`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
runtime.setReviewer(matches[0].id);
|
|
265
|
+
});
|
|
266
|
+
service.register({
|
|
267
|
+
name: 'permission',
|
|
268
|
+
args: '[预设名]',
|
|
269
|
+
description: '查看或切换打包权限预设(沙箱 + 权限模式 + 审阅者三合一)',
|
|
270
|
+
}, ({ args, runtime, ui }) => {
|
|
271
|
+
const presets = runtime.getSnapshot().surfaces.permissionPresets;
|
|
272
|
+
const query = args[0] ?? '';
|
|
273
|
+
if (query === '') {
|
|
274
|
+
ui.notice([
|
|
275
|
+
`当前权限预设:${presets.current}${presets.current === 'custom' ? '(三根旋钮的组合不匹配任何预设)' : ''}`,
|
|
276
|
+
...presets.options.map((option) => `· ${option.name} — ${option.label}:${option.description}`),
|
|
277
|
+
'用法:/permission <预设名>(如 /permission full-access);细调单档用 /policy、/reviewer',
|
|
278
|
+
].join('\n'));
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
// 档位名被误当预设名时给一句能照着走的提示,别只说「认不出」
|
|
282
|
+
if (runtime.getSnapshot().surfaces.policy.options.some((option) => option.id === query.toLowerCase())) {
|
|
283
|
+
ui.notice(`「${query}」是权限档位不是预设:切档位用 /policy ${query},切预设的名字见 /permission(不带参数)`);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const matches = presets.options.filter((option) => option.name.startsWith(query.toLowerCase()));
|
|
287
|
+
if (matches.length !== 1) {
|
|
288
|
+
ui.notice(matches.length === 0
|
|
289
|
+
? `未知权限预设:${query}(可选:${presets.options.map((option) => option.name).join(' / ')})`
|
|
290
|
+
: `「${query}」匹配到 ${matches.length} 个预设,请写全`);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const result = runtime.usePermissionPreset(matches[0].name);
|
|
294
|
+
if (!result.ok)
|
|
295
|
+
ui.notice(result.error);
|
|
296
|
+
});
|
|
297
|
+
service.register({ name: 'effort', args: '[default|off|low|high|max]', description: '查看或切换思考强度' }, ({ args, runtime, ui }) => {
|
|
298
|
+
const levels = [
|
|
299
|
+
{ id: 'default', label: '默认(不声明思考字段,跟随端点)' },
|
|
300
|
+
{ id: 'off', label: '关闭思考' },
|
|
301
|
+
{ id: 'low', label: '低' },
|
|
302
|
+
{ id: 'high', label: '高' },
|
|
303
|
+
{ id: 'max', label: '最大' },
|
|
304
|
+
];
|
|
305
|
+
const query = args[0]?.toLowerCase() ?? '';
|
|
306
|
+
if (query === '') {
|
|
307
|
+
ui.notice([
|
|
308
|
+
`当前思考强度:${runtime.getSnapshot().status.effort}`,
|
|
309
|
+
...levels.map((level) => `· ${level.id} — ${level.label}`),
|
|
310
|
+
'用法:/effort <档位>(当前模型不支持的档位会报错)',
|
|
311
|
+
].join('\n'));
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const matches = levels.filter((level) => level.id.startsWith(query));
|
|
315
|
+
if (matches.length !== 1) {
|
|
316
|
+
ui.notice(matches.length === 0
|
|
317
|
+
? `未知思考档位:${args[0]}(可选:${levels.map((level) => level.id).join(' / ')})`
|
|
318
|
+
: `「${args[0]}」匹配到 ${matches.length} 个档位,请写全`);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
void runtime.setEffort(matches[0].id);
|
|
322
|
+
});
|
|
323
|
+
service.register(
|
|
324
|
+
// dsh 语义:整本分叉成「可恢复的副本」,现场会话与跑动回合不动(kimi-code
|
|
325
|
+
// 的 fork)。按分叉点选副本走 /resume 里的 Ctrl+F,这里只做整本。
|
|
326
|
+
{ name: 'fork', args: '', description: '分叉当前会话为可恢复的副本(当前会话不变)' }, ({ runtime, ui }) => {
|
|
327
|
+
// sessionId 是 uuid,当文件用会按进程 cwd 解析出 ENOENT(0.6.66 实锤:
|
|
328
|
+
// C:\Windows\System32\<uuid>);落盘一律走 sessionPath。
|
|
329
|
+
const path = runtime.getSnapshot().status.sessionPath;
|
|
330
|
+
if (path === undefined || path === '') {
|
|
331
|
+
ui.notice('当前还没有可分叉的会话(先聊一句再分叉)。');
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
void runtime
|
|
335
|
+
.listUserMessages(path)
|
|
336
|
+
.then((messages) => runtime.forkSession(path, messages.length))
|
|
337
|
+
.then((result) => {
|
|
338
|
+
if (!result.ok) {
|
|
339
|
+
ui.notice(`/fork 失败:${result.error}`);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const shortId = (result.path.split(/[\\/]/).pop() ?? result.path)
|
|
343
|
+
.replace(/\.jsonl$/, '')
|
|
344
|
+
.slice(0, 8);
|
|
345
|
+
ui.notice(`已分叉出副本 ${shortId},当前会话不变;/resume 里可以打开它`);
|
|
346
|
+
})
|
|
347
|
+
.catch((cause) => ui.notice(`/fork 失败:${errText(cause)}`));
|
|
348
|
+
});
|
|
349
|
+
service.register(
|
|
350
|
+
// 思考块显示切换:与 Ctrl+T 同一状态(会话内生效,不持久化——持久化的
|
|
351
|
+
// 默认值在设置「新会话的思考块默认摊开」)。没有思考块的端忽略回调。
|
|
352
|
+
{ name: 'thinking', args: '[on|off]', description: '切换思考块展开显示(无参数 = 翻转,会话内生效)' }, ({ args, ui }) => {
|
|
353
|
+
if (ui.toggleThinking === undefined) {
|
|
354
|
+
ui.notice('当前界面不支持会话内切换思考块(桌面端在设置里改「新会话的思考块默认摊开」)。');
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const query = args[0]?.toLowerCase() ?? '';
|
|
358
|
+
if (query === '') {
|
|
359
|
+
ui.toggleThinking();
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (query !== 'on' && query !== 'off') {
|
|
363
|
+
ui.notice('用法:/thinking [on|off](无参数 = 翻转当前显示)');
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
ui.toggleThinking(query === 'on');
|
|
367
|
+
});
|
|
368
|
+
service.register({ name: 'plugins', args: '', description: '查看已挂载插件清单(启停与详情在桌面端插件中心)' }, ({ runtime, ui }) => {
|
|
369
|
+
const plugins = runtime.listPlugins();
|
|
370
|
+
if (plugins.length === 0) {
|
|
371
|
+
ui.notice('没有已挂载的插件(内核自带服务不在此列)。');
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
const lines = plugins.map((plugin) => {
|
|
375
|
+
const flags = [plugin.source === 'builtin' ? '内核' : '外部', plugin.enabled ? undefined : '已停用']
|
|
376
|
+
.filter((flag) => flag !== undefined)
|
|
377
|
+
.join(' · ');
|
|
378
|
+
const problem = plugin.problem !== undefined ? `(注意:${plugin.problem})` : '';
|
|
379
|
+
return `· ${plugin.name}(${flags})— ${plugin.description}${problem}`;
|
|
380
|
+
});
|
|
381
|
+
ui.notice([
|
|
382
|
+
`已挂载插件(${plugins.length} 个)`,
|
|
383
|
+
...lines,
|
|
384
|
+
'启停与配置在桌面端「插件」页;外部插件放进 ~/.dsc/plugins 会自动加载。',
|
|
385
|
+
].join('\n'));
|
|
386
|
+
});
|
|
387
|
+
service.register(
|
|
388
|
+
// 只查不装(0.6.50 起的边界):结果与设置「关于」的检查按钮同一份回执口径,
|
|
389
|
+
// 终端打不开浏览器,新版时把发布页 URL 一并给出。
|
|
390
|
+
{ name: 'update', args: '', description: '检查有没有新版(只查不装)' }, ({ ui }) => {
|
|
391
|
+
void checkForUpdate()
|
|
392
|
+
.then((result) => {
|
|
393
|
+
if (!result.ok) {
|
|
394
|
+
ui.notice(result.error);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
ui.notice(result.data?.url !== undefined ? `${result.notice}\n发布页:${result.data.url}` : result.notice);
|
|
398
|
+
})
|
|
399
|
+
.catch((cause) => ui.notice(`/update 失败:${errText(cause)}`));
|
|
400
|
+
});
|
|
401
|
+
service.register({ name: 'ui-trust', args: '<插件目录名>', description: '信任一个第三方界面插件(首次安装的确认动作)' }, ({ args, ui }) => {
|
|
402
|
+
const name = args[0] ?? '';
|
|
403
|
+
if (name === '') {
|
|
404
|
+
// 列出当前等着被确认的(discover 的 problems 里就有它们的名字)。
|
|
405
|
+
const pending = discoverThirdPartyUiArtifacts(shellApiVersionForTrust(), new Set());
|
|
406
|
+
const waiting = pending.problems.filter((line) => line.includes('还没有信任记录'));
|
|
407
|
+
if (waiting.length === 0) {
|
|
408
|
+
ui.notice('没有等着确认的第三方界面插件。装法:把 <目录名>/{plugin.json, ui/client.js} 放进 ~/.dsc/plugins/。');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
ui.notice(['还没确认的第三方界面插件(能调宿主的界面方法与原生桥,确认前不装载):', ...waiting.map((line) => ` ${line}`), '确认:/ui-trust <插件目录名>'].join('\n'));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const fileKey = `${name}/ui/client.js`;
|
|
415
|
+
// 摊开能力面再落信任:它声明对着哪个契约版本、跑在哪种壳,以及两条通用能力。
|
|
416
|
+
const manifestPath = join(dscPath('plugins'), name, 'plugin.json');
|
|
417
|
+
let api = '(没写)';
|
|
418
|
+
let platforms = 'web';
|
|
419
|
+
try {
|
|
420
|
+
const doc = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
421
|
+
if (typeof doc.api === 'string')
|
|
422
|
+
api = doc.api;
|
|
423
|
+
if (Array.isArray(doc.platforms) && doc.platforms.length > 0)
|
|
424
|
+
platforms = doc.platforms.join('/');
|
|
425
|
+
}
|
|
426
|
+
catch {
|
|
427
|
+
ui.notice(`读不到 ${fileKey} 的 plugin.json——目录名对吗?(要的是 ~/.dsc/plugins/<目录名>)`);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
trustUiPlugin(fileKey);
|
|
431
|
+
ui.notice([
|
|
432
|
+
`已信任第三方界面插件「${name}」`,
|
|
433
|
+
` @dsc/ui 区间:${api}(当前壳 ${DSC_VERSION},不满足会被门禁拦下并说明)`,
|
|
434
|
+
` 载体:${platforms}`,
|
|
435
|
+
' 能力:调用宿主界面通道的白名单方法;桌面窗口里可用原生桥(打开目录、终端等 14 个操作)',
|
|
436
|
+
' 生效:重启宿主(或刷新浏览器页面)后装载;停用走 plugins.json 的启停或插件中心',
|
|
437
|
+
].join('\n'));
|
|
438
|
+
});
|
|
439
|
+
service.register({ name: 'exit', args: '', description: '退出' }, ({ runtime }) => runtime.exit());
|
|
440
|
+
serviceRef = service;
|
|
441
|
+
ctx.provide('commands', service);
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
/** 注册表单例引用(App.tsx 的 runCommand 走它,外部命令一并派发)。 */
|
|
445
|
+
let serviceRef = null;
|
|
446
|
+
/** 兼容导出:v2 的 runCommand(App.tsx 零逻辑改动,仅 import 路径变化)。 */
|
|
447
|
+
export function runCommand(input, runtime, ui) {
|
|
448
|
+
return serviceRef !== null ? serviceRef.run(input, runtime, ui) : false;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* /usage 的文本组装(独立成函数便于脱离命令体系直测)。
|
|
452
|
+
* 缓存命中率只统计端点上报过明细的请求(usage-log 的口径),没上报的不掺进来。
|
|
453
|
+
*/
|
|
454
|
+
export function usageReport(stats) {
|
|
455
|
+
if (stats.totalTurns === 0)
|
|
456
|
+
return '还没有用量记录(~/.dsc/usage/usage.jsonl 里一条都没有)。';
|
|
457
|
+
const fmtTokens = (value) => value >= 1_000_000
|
|
458
|
+
? `${(value / 1_000_000).toFixed(1)}M`
|
|
459
|
+
: value >= 1000
|
|
460
|
+
? `${(value / 1000).toFixed(1)}k`
|
|
461
|
+
: String(value);
|
|
462
|
+
const lines = [
|
|
463
|
+
`用量统计(自 ${new Date(stats.sinceTs ?? Date.now()).toISOString().slice(0, 10)},${stats.activeDays} 天有活动)`,
|
|
464
|
+
`· 累计:输入 ${fmtTokens(stats.totalInputTokens)} / 输出 ${fmtTokens(stats.totalOutputTokens)} tokens,共 ${stats.totalTurns} 轮请求`,
|
|
465
|
+
];
|
|
466
|
+
const cacheTotal = stats.totalCacheHitTokens + stats.totalCacheMissTokens;
|
|
467
|
+
if (cacheTotal > 0) {
|
|
468
|
+
lines.push(`· 前缀缓存命中:${Math.round((stats.totalCacheHitTokens / cacheTotal) * 100)}%(命中 ${fmtTokens(stats.totalCacheHitTokens)} / 未命中 ${fmtTokens(stats.totalCacheMissTokens)},只统计上报过明细的请求)`);
|
|
469
|
+
}
|
|
470
|
+
if (stats.peakDay !== null) {
|
|
471
|
+
lines.push(`· 单日峰值:${stats.peakDay.date}(${fmtTokens(stats.peakDay.inputTokens + stats.peakDay.outputTokens)} tokens)`);
|
|
472
|
+
}
|
|
473
|
+
lines.push(`· 连续活跃 ${stats.currentStreakDays} 天(最长 ${stats.longestStreakDays} 天)`);
|
|
474
|
+
const top = stats.models.slice(0, 5);
|
|
475
|
+
if (top.length > 0) {
|
|
476
|
+
lines.push('按模型(Top 5):');
|
|
477
|
+
for (const model of top) {
|
|
478
|
+
lines.push(`· ${model.key}:${fmtTokens(model.inputTokens + model.outputTokens)} tokens(${model.turns} 轮)`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return lines.join('\n');
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* /status 的文本组装(独立成函数便于脱离命令体系直测)。
|
|
485
|
+
* tokens 由调用方用 core/compact 的 estimateTokens 算——数字与自动压缩触发判定同源。
|
|
486
|
+
*/
|
|
487
|
+
export function statusReport(input) {
|
|
488
|
+
const threshold = Math.round(input.window * (input.autoCompactPercent / 100));
|
|
489
|
+
const share = input.window > 0 ? Math.round((input.tokens / input.window) * 100) : 0;
|
|
490
|
+
return [
|
|
491
|
+
'上下文占用',
|
|
492
|
+
`· 模型:${input.provider}/${input.model}(窗口 ${input.window.toLocaleString('zh-CN')} tokens)`,
|
|
493
|
+
`· 消息:${input.messageCount} 条(其中工具结果 ${input.toolCount} 条)`,
|
|
494
|
+
`· 估算用量:${input.tokens.toLocaleString('zh-CN')} tokens,约占窗口 ${share}%`,
|
|
495
|
+
`· 自动压缩触发线:${input.autoCompactPercent}%(≈${threshold.toLocaleString('zh-CN')} tokens,还差 ${Math.max(0, threshold - input.tokens).toLocaleString('zh-CN')})`,
|
|
496
|
+
'· 估算口径与自动压缩同源(中文 0.65、其余 0.33 tokens/字符)',
|
|
497
|
+
].join('\n');
|
|
498
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compact 插件:provide `compact` 服务(自动压缩检查 + /compact 手动压缩 + 原样带过去的文本登记)。
|
|
3
|
+
* 逻辑迁自 v2 adapter/core-runtime 的 autoCompact 段与 /compact 命令分支;
|
|
4
|
+
* 结果提示统一经 dsc/notice 事件,注册 /compact 命令进 commands 注册表。
|
|
5
|
+
* 真正压出结果的那条提示带 `'compaction'` 类别:transcript 据此给条目打压缩标记,
|
|
6
|
+
* 轨迹页才能把「压缩历史」画成独立区段;失败与「无需压缩」的提示不带这个类别。
|
|
7
|
+
*
|
|
8
|
+
* 「哪些内容不许被摘要模型改写」由功能点自己登记(`registerCarry`):任务清单与会话目标
|
|
9
|
+
* 各登记一段文本,这个插件因此不认识任何具体功能。
|
|
10
|
+
*
|
|
11
|
+
* 摘要调用复用主对话前缀(2026-10-03):系统提示词取自 prompt 服务、工具目录取自 tools 服务,
|
|
12
|
+
* 摘要请求因此是上一次真实请求的前缀扩展,命中服务端 KV 缓存(见 core/compact.ts 的 context 参数)。
|
|
13
|
+
*
|
|
14
|
+
* 六个可调值(保留条数、自动压缩触发线、锚点索引字符预算、用户原话字符预算、
|
|
15
|
+
* read-state 文件数、read-state 字符预算)读自己的插件配置,
|
|
16
|
+
* 并以设置分区的面目交给界面;保存后本插件立刻重读,下一次压缩就用新值。
|
|
17
|
+
*
|
|
18
|
+
* @module dsc/plugins/compact
|
|
19
|
+
*/
|
|
20
|
+
import type { Plugin } from '@deepseek-ai/cordis';
|
|
21
|
+
export declare const compactPlugin: Plugin.Object;
|