@waq666/pneuma 0.0.0-stage → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +206 -3
- 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 +15 -0
- package/lib/app/App.js +1650 -0
- package/lib/app/App.js.nv-backup +1650 -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 +63 -0
- package/lib/app/ChatView.js +310 -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 +201 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/TimelineRail.d.ts +22 -0
- package/lib/app/TimelineRail.js +160 -0
- package/lib/app/TimelineRail.js.negbak +98 -0
- package/lib/app/TimelineRail.js.nv-backup +160 -0
- package/lib/app/ToolCard.d.ts +11 -0
- package/lib/app/ToolCard.js +64 -0
- package/lib/app/ToolCard.js.nv-backup +64 -0
- package/lib/app/TranscriptOverlay.d.ts +27 -0
- package/lib/app/TranscriptOverlay.js +36 -0
- package/lib/app/TranscriptViewport.d.ts +78 -0
- package/lib/app/TranscriptViewport.js +218 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +71 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +40 -0
- package/lib/app/click.js +103 -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/keymap.d.ts +56 -0
- package/lib/app/keymap.js +56 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/mouse.d.ts +33 -0
- package/lib/app/mouse.js +35 -0
- package/lib/app/pointer.d.ts +16 -0
- package/lib/app/pointer.js +60 -0
- package/lib/app/scroll-model.d.ts +240 -0
- package/lib/app/scroll-model.js +347 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/snapshot-subscribe.d.ts +34 -0
- package/lib/app/snapshot-subscribe.js +110 -0
- package/lib/app/theme.d.ts +194 -0
- package/lib/app/theme.js +186 -0
- package/lib/app/ticker.d.ts +7 -0
- package/lib/app/ticker.js +53 -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 +283 -0
- package/lib/core/llm.js +565 -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 +896 -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 +434 -0
- package/lib/plugins/tool-search.js.nv-backup +434 -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,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模式(预设):一个模式就是 `~/.dsc/presets/<名字>.md` 一个文件。
|
|
3
|
+
* frontmatter 说清这个模式的工牌(工具白名单、要去掉的骨架段),正文就是这个模式
|
|
4
|
+
* 追加给模型的提示词——形状和 `~/.dsc/agents/<名字>.md` 一样,会写角色就会写模式。
|
|
5
|
+
*
|
|
6
|
+
* 与协作模式(`core/modes.ts`)的分工是两根独立旋钮(dsh 的 preset 与 plan-mode 也分开):
|
|
7
|
+
* 协作模式 管「这一轮允许模型把手伸多远」——工具闸门,判法是代码;
|
|
8
|
+
* 模式 管「模型是谁、手上有什么、被叮嘱了什么」——提示词 + 工具目录 + 骨架取舍。
|
|
9
|
+
*
|
|
10
|
+
* 三条硬约束(改这个文件时别破):
|
|
11
|
+
* 1. **模式只做减法**。工具白名单只能是全量的子集,`drop` 只能在下面那张名单里去掉
|
|
12
|
+
* 骨架段。任何模式都放宽不了安全:审批灾难地板与守卫链不看模式,看的是命令行与权限模式。
|
|
13
|
+
* 2. **默认档必须等价于「没有模式这个概念」**。标准模式的工具投影是恒等映射、提示段是
|
|
14
|
+
* 空串(空段会被 composePrompt 滤掉),所以系统提示词逐字节不变——服务端提示缓存
|
|
15
|
+
* 只认前缀,默认档一变就等于全失效。
|
|
16
|
+
* 3. **坏文件不许把启动拦下来**。解析不出来就带 problem 列出来,模型仍按标准档跑。
|
|
17
|
+
*
|
|
18
|
+
* frontmatter 认这些键(都可选,缺省值见括号):
|
|
19
|
+
*
|
|
20
|
+
* ```markdown
|
|
21
|
+
* ---
|
|
22
|
+
* name: review # 模式标识,小写字母数字连字符(缺省取文件名)
|
|
23
|
+
* label: 代码审查模式 # 界面上的显示名(缺省取 name)
|
|
24
|
+
* description: 只读地找漏洞与测试缺口,指出文件与行号
|
|
25
|
+
* tools: read, glob, grep, bash # 工具白名单(不写 = 全量;写 none = 一个工具都不给)
|
|
26
|
+
* drop: behavior, tool-rules # 要去掉的骨架提示段(名单见 DROPPABLE_SECTIONS)
|
|
27
|
+
* ---
|
|
28
|
+
* 这一段是模式的提示词,追加进系统提示。
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @module dsc/core/presets
|
|
32
|
+
*/
|
|
33
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
34
|
+
import { basename, join } from 'node:path';
|
|
35
|
+
import YAML from 'yaml';
|
|
36
|
+
import { splitFrontmatter } from './skills.js';
|
|
37
|
+
import { dscPath } from './path-policy.js';
|
|
38
|
+
/** 模式文件目录。 */
|
|
39
|
+
export const DSC_PRESETS_DIR = dscPath('presets');
|
|
40
|
+
/** 四个出厂模式的标识(标准档是永久的回落目标,任何读不出来的情况都回落到它)。 */
|
|
41
|
+
export const STANDARD_PRESET = 'standard';
|
|
42
|
+
export const MINIMAL_PRESET = 'minimal';
|
|
43
|
+
export const MAKER_PRESET = 'maker';
|
|
44
|
+
export const PTC_PRESET = 'ptc';
|
|
45
|
+
/** 允许被模式去掉的骨架提示段。
|
|
46
|
+
*
|
|
47
|
+
* 只放「做法层面的叮嘱」:去掉它们只影响模型的自觉程度,
|
|
48
|
+
* 代码里的守卫(审批硬地板、命令策略、路径策略)一条都不会因此松开。
|
|
49
|
+
* `identity`(中文与称呼约定)与 `environment`(环境事实)不在名单里:前者是产品约定,
|
|
50
|
+
* 后者是事实——两者都不该被一个模式抹掉。 */
|
|
51
|
+
export const DROPPABLE_SECTIONS = ['behavior', 'tool-rules', 'instructions', 'skills'];
|
|
52
|
+
/** 骨架段的中文名(设置面板上让人勾的名单)。 */
|
|
53
|
+
export const DROPPABLE_LABELS = {
|
|
54
|
+
behavior: '做事方式(先看代码再动手、破坏性操作先警告…)',
|
|
55
|
+
'tool-rules': '工具使用规范(哪个工具干什么、别拿 shell 当万能)',
|
|
56
|
+
instructions: '项目说明书(AGENTS.md / CLAUDE.md)',
|
|
57
|
+
skills: '技能目录(<available_skills>)',
|
|
58
|
+
};
|
|
59
|
+
/** 模式名形状:小写字母数字加连字符,最长 32,够界面一排显示。 */
|
|
60
|
+
const PRESET_NAME = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
61
|
+
/** 出厂模式:名字 → 文件内容。第一次用到时写出去,之后用户随便改(不覆盖)。 */
|
|
62
|
+
const BUILTIN_FILES = {
|
|
63
|
+
[STANDARD_PRESET]: `---
|
|
64
|
+
name: ${STANDARD_PRESET}
|
|
65
|
+
label: 标准模式
|
|
66
|
+
description: 处理代码、文件和资料,适合大多数任务;工具按需使用,提示词与出厂完全一致
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
`,
|
|
70
|
+
[MINIMAL_PRESET]: `---
|
|
71
|
+
name: ${MINIMAL_PRESET}
|
|
72
|
+
label: 极简模式
|
|
73
|
+
description: 只给一条 shell(PowerShell)与固定提示词,用来对照模型的基础表现
|
|
74
|
+
tools: bash
|
|
75
|
+
drop: behavior, tool-rules, instructions, skills
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
你手上只有一条 shell 工具(bash),在这台机器上它跑的是 PowerShell,工作目录就是当前项目。
|
|
79
|
+
别的工具一个都没有:读文件、找文件、改文件、跑测试,全部用 shell 命令完成。
|
|
80
|
+
|
|
81
|
+
怎么干:
|
|
82
|
+
- 看文件用 Get-Content(要行号自己数);找内容用 Select-String;找文件用 Get-ChildItem -Recurse。
|
|
83
|
+
- 改文件没有定点替换工具:先整篇读出来,再整篇写回去(Set-Content),改一处也一样。
|
|
84
|
+
- 跑测试、构建、git 都用 shell。
|
|
85
|
+
- 一条命令只做一件事;输出会被原样收进上下文,所以用 Select-Object -First 之类的办法先收窄,
|
|
86
|
+
别把几万行拉进来。
|
|
87
|
+
- 每条命令都要过审批。危险动作(递归删除、强推、重置)先停下来说清,不要硬试。
|
|
88
|
+
- 最后用一小段话交回:做了什么、结果是什么、哪里还没查清。
|
|
89
|
+
`,
|
|
90
|
+
[MAKER_PRESET]: `---
|
|
91
|
+
name: ${MAKER_PRESET}
|
|
92
|
+
label: 创造模式
|
|
93
|
+
description: 在标准能力之上加运行时只读查询:给自己加模式、给 dsc 写插件
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
你可以给自己加模式,也可以写插件。两件事都有现成的落点:
|
|
97
|
+
|
|
98
|
+
加一个模式:在 ~/.dsc/presets/ 下新建 <名字>.md(小写字母数字连字符)。frontmatter 认
|
|
99
|
+
name / label / description / tools / drop 五个键,正文就是追加进系统提示的那段话;
|
|
100
|
+
tools 是工具白名单(不写 = 全量),drop 只能去掉行为规范那几段(完整名单见 docs/presets.md)。
|
|
101
|
+
写完让用户切过去试:/preset <名字>,或者在设置 → 模式里点一下。
|
|
102
|
+
|
|
103
|
+
写一个插件:先读 docs/dsh-plugin-porting.md 与 examples/plugins/ 里的例子,再用
|
|
104
|
+
plugin_manager 装进 ~/.dsc/plugins/。插件能拿到哪些服务、扩展点长什么样,用 runtime_api
|
|
105
|
+
工具查——它读的是运行期的真状态,不是文档里的旧说法。
|
|
106
|
+
|
|
107
|
+
做事方式:
|
|
108
|
+
- 动别人的文件之前先说清要改什么、为什么;改完立刻验证(切过去问一轮,或跑相关自检脚本)。
|
|
109
|
+
- 别猜 API:查不到就说查不到,不要凭印象编一个方法名或字段名出来。
|
|
110
|
+
`,
|
|
111
|
+
[PTC_PRESET]: `---
|
|
112
|
+
name: ${PTC_PRESET}
|
|
113
|
+
label: PTC 模式
|
|
114
|
+
description: 模型用代码组织工具调用:一次写一段脚本批量调工具,在代码里筛选汇总再把结论交回来
|
|
115
|
+
tools: run_code
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
这一轮你用代码组织工具调用:手上只有 run_code 一个工具,别的工具都在它的 SDK 里。
|
|
119
|
+
|
|
120
|
+
怎么写:run_code 的 code 参数是一段 JavaScript(顶层可以直接 await),
|
|
121
|
+
里面用 sdk 调工具——每个工具是一个函数,参数就是它原来的参数,返回它原来的输出文本:
|
|
122
|
+
|
|
123
|
+
const found = await sdk.grep({ pattern: 'TODO', path: 'src' })
|
|
124
|
+
const hits = found.split('\\n').filter((line) => line.includes('core'))
|
|
125
|
+
return hits.slice(0, 20).join('\\n')
|
|
126
|
+
|
|
127
|
+
为什么这么做:工具的原始输出先进你的程序,你在程序里筛选、去重、统计、汇总,
|
|
128
|
+
只把结论交回上下文;批量任务因此不会被几十条工具输出撑爆。
|
|
129
|
+
|
|
130
|
+
每次 sdk.xxx 调用都照旧过审批与安全钩子,也照旧记进会话记录里。
|
|
131
|
+
直接 return 的就是要交回的内容——太长会被截断,自己先压到一两百行以内。
|
|
132
|
+
`,
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* 把还不存在的出厂模式写进模式目录。
|
|
136
|
+
* @returns 实际新写出的模式名(已存在的一律不覆盖,用户改过的永远留着)。
|
|
137
|
+
*/
|
|
138
|
+
export function ensureBuiltinPresets() {
|
|
139
|
+
const created = [];
|
|
140
|
+
for (const [name, text] of Object.entries(BUILTIN_FILES)) {
|
|
141
|
+
const file = join(DSC_PRESETS_DIR, `${name}.md`);
|
|
142
|
+
if (existsSync(file))
|
|
143
|
+
continue;
|
|
144
|
+
try {
|
|
145
|
+
mkdirSync(DSC_PRESETS_DIR, { recursive: true });
|
|
146
|
+
writeFileSync(file, text, 'utf8');
|
|
147
|
+
created.push(name);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// 目录建不出来(只读盘、权限):不报错,让用户自己建文件。
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return created;
|
|
154
|
+
}
|
|
155
|
+
/** 把 frontmatter 里的列表字段读成字符串数组:逗号或空隔分隔,也认 YAML 数组。 */
|
|
156
|
+
function readList(raw) {
|
|
157
|
+
if (raw === undefined || raw === null)
|
|
158
|
+
return [];
|
|
159
|
+
const items = Array.isArray(raw) ? raw.map((item) => String(item)) : String(raw).split(/[,,\s]+/);
|
|
160
|
+
return items.map((item) => item.trim()).filter((item) => item !== '');
|
|
161
|
+
}
|
|
162
|
+
/** 读一个模式文件;返回 null = 文件名不合法或读不起来。 */
|
|
163
|
+
export function readPreset(file) {
|
|
164
|
+
let text;
|
|
165
|
+
try {
|
|
166
|
+
text = readFileSync(file, 'utf8');
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
const base = basename(file, '.md');
|
|
172
|
+
return parsePreset(text, base, file, base in BUILTIN_FILES);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 标准档规格:文件在就用文件,文件被删了/写坏了就用出厂那份(内存里现解析)。
|
|
176
|
+
* 这个函数**绝不返回 null**——它是整套模式系统的回落点,任何读不出来的情况
|
|
177
|
+
* (文件没了、frontmatter 坏了、偏好里写了不存在的名字)最后都落到它身上。
|
|
178
|
+
*/
|
|
179
|
+
export function standardPreset() {
|
|
180
|
+
const fromDisk = findPreset(STANDARD_PRESET);
|
|
181
|
+
if (fromDisk !== null)
|
|
182
|
+
return fromDisk;
|
|
183
|
+
const parsed = parsePreset(BUILTIN_FILES[STANDARD_PRESET] ?? '', STANDARD_PRESET, join(DSC_PRESETS_DIR, `${STANDARD_PRESET}.md`), true);
|
|
184
|
+
return parsed ?? FALLBACK_PRESET;
|
|
185
|
+
}
|
|
186
|
+
/** 连出厂文本都解析不出来时的兜底对象(理论上到不了这里,留一个绝不为 null 的底)。 */
|
|
187
|
+
const FALLBACK_PRESET = {
|
|
188
|
+
name: STANDARD_PRESET,
|
|
189
|
+
label: '标准模式',
|
|
190
|
+
description: '',
|
|
191
|
+
tools: null,
|
|
192
|
+
drop: [],
|
|
193
|
+
prompt: '',
|
|
194
|
+
builtin: true,
|
|
195
|
+
file: join(DSC_PRESETS_DIR, `${STANDARD_PRESET}.md`),
|
|
196
|
+
};
|
|
197
|
+
/** 解析一份模式文件正文(磁盘上的文件与出厂文本走同一条路,判法只有一处)。 */
|
|
198
|
+
function parsePreset(text, base, file, builtin) {
|
|
199
|
+
const { front, body } = splitFrontmatter(text);
|
|
200
|
+
let doc = {};
|
|
201
|
+
let problem;
|
|
202
|
+
if (front.trim() !== '') {
|
|
203
|
+
try {
|
|
204
|
+
doc = YAML.parse(front) ?? {};
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
problem = `frontmatter 不是合法 YAML:${error instanceof Error ? error.message : String(error)}`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const declared = typeof doc.name === 'string' ? doc.name.trim() : '';
|
|
211
|
+
const name = declared !== '' ? declared : base;
|
|
212
|
+
if (!PRESET_NAME.test(name)) {
|
|
213
|
+
return {
|
|
214
|
+
name: base,
|
|
215
|
+
label: base,
|
|
216
|
+
description: '',
|
|
217
|
+
tools: null,
|
|
218
|
+
drop: [],
|
|
219
|
+
prompt: '',
|
|
220
|
+
builtin,
|
|
221
|
+
file,
|
|
222
|
+
problem: `模式名「${name}」不合法:只能用小写字母、数字、连字符,且不能以连字符开头`,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const rawTools = doc.tools;
|
|
226
|
+
let tools = null;
|
|
227
|
+
if (rawTools !== undefined) {
|
|
228
|
+
const list = readList(rawTools);
|
|
229
|
+
tools = list.length === 0 || list.every((item) => item === 'none') ? [] : list;
|
|
230
|
+
}
|
|
231
|
+
// drop 只认名单里的段:写错的当场说清,别让用户对着「提示词没变」猜半天
|
|
232
|
+
const rawDrop = readList(doc.drop);
|
|
233
|
+
const unknownDrop = rawDrop.filter((id) => !DROPPABLE_SECTIONS.includes(id));
|
|
234
|
+
if (unknownDrop.length > 0) {
|
|
235
|
+
problem =
|
|
236
|
+
problem ?? `drop 里的 ${unknownDrop.join('、')} 不是可去掉的段(可选:${DROPPABLE_SECTIONS.join('、')})`;
|
|
237
|
+
}
|
|
238
|
+
const drop = rawDrop.filter((id) => DROPPABLE_SECTIONS.includes(id));
|
|
239
|
+
const label = typeof doc.label === 'string' && doc.label.trim() !== '' ? doc.label.trim() : name;
|
|
240
|
+
return {
|
|
241
|
+
name,
|
|
242
|
+
label,
|
|
243
|
+
description: typeof doc.description === 'string' ? doc.description.trim() : '',
|
|
244
|
+
tools,
|
|
245
|
+
drop,
|
|
246
|
+
prompt: body.trim(),
|
|
247
|
+
builtin,
|
|
248
|
+
file,
|
|
249
|
+
...(problem !== undefined ? { problem } : {}),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/** 列出全部模式,按名字排序;坏文件也列出来(带 problem),免得用户以为文件没生效。 */
|
|
253
|
+
export function listPresets() {
|
|
254
|
+
if (!existsSync(DSC_PRESETS_DIR))
|
|
255
|
+
return [];
|
|
256
|
+
const out = [];
|
|
257
|
+
const seen = new Set();
|
|
258
|
+
// 文件名先排序:两个文件声明了同一个 name 时,谁生效是确定的(字典序在前的那个)
|
|
259
|
+
for (const entry of readdirSync(DSC_PRESETS_DIR).sort()) {
|
|
260
|
+
if (!entry.endsWith('.md'))
|
|
261
|
+
continue;
|
|
262
|
+
const preset = readPreset(join(DSC_PRESETS_DIR, entry));
|
|
263
|
+
if (preset === null)
|
|
264
|
+
continue;
|
|
265
|
+
if (seen.has(preset.name)) {
|
|
266
|
+
// 不静默丢弃:这一份按文件名挂在清单里,带一句话说明它为什么没生效
|
|
267
|
+
out.push({
|
|
268
|
+
...preset,
|
|
269
|
+
name: basename(entry, '.md'),
|
|
270
|
+
label: `${preset.label}(未生效)`,
|
|
271
|
+
tools: [],
|
|
272
|
+
drop: [],
|
|
273
|
+
prompt: '',
|
|
274
|
+
problem: `这个文件声明的 name 是「${preset.name}」,已经有一个同名模式生效了,所以这一份不生效`,
|
|
275
|
+
});
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
seen.add(preset.name);
|
|
279
|
+
out.push(preset);
|
|
280
|
+
}
|
|
281
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
282
|
+
}
|
|
283
|
+
/** 按名字取模式;不存在返回 null(调用方决定是报错还是回落到标准档)。 */
|
|
284
|
+
export function findPreset(name) {
|
|
285
|
+
if (!PRESET_NAME.test(name))
|
|
286
|
+
return null;
|
|
287
|
+
const preset = readPreset(join(DSC_PRESETS_DIR, `${name}.md`));
|
|
288
|
+
return preset !== null && preset.name === name ? preset : null;
|
|
289
|
+
}
|
|
290
|
+
/** 写一个模式文件的正文(新建与编辑共用)。 */
|
|
291
|
+
function presetFileText(draft) {
|
|
292
|
+
const front = { name: draft.name, label: draft.label, description: draft.description };
|
|
293
|
+
if (draft.tools !== null)
|
|
294
|
+
front.tools = draft.tools.length === 0 ? 'none' : draft.tools.join(', ');
|
|
295
|
+
if (draft.drop.length > 0)
|
|
296
|
+
front.drop = draft.drop.join(', ');
|
|
297
|
+
return `---\n${YAML.stringify(front).trimEnd()}\n---\n\n${draft.prompt.trim()}\n`;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* 写一个模式文件(设置面板「保存」用)。
|
|
301
|
+
*
|
|
302
|
+
* 覆盖写:手写在 frontmatter 里的额外键不会保留(写的永远是上面那五个键),
|
|
303
|
+
* 想留着自己的键就直接编辑文件。名字非法或改名为已存在的模式时抛错。
|
|
304
|
+
*/
|
|
305
|
+
export function writePreset(draft) {
|
|
306
|
+
const name = draft.name.trim();
|
|
307
|
+
if (!PRESET_NAME.test(name)) {
|
|
308
|
+
throw new Error(`模式名「${name}」不合法:只能用小写字母、数字、连字符,且不能以连字符开头`);
|
|
309
|
+
}
|
|
310
|
+
const drop = draft.drop.filter((id) => DROPPABLE_SECTIONS.includes(id));
|
|
311
|
+
const label = draft.label.trim() === '' ? name : draft.label.trim();
|
|
312
|
+
mkdirSync(DSC_PRESETS_DIR, { recursive: true });
|
|
313
|
+
const file = join(DSC_PRESETS_DIR, `${name}.md`);
|
|
314
|
+
if (draft.oldName !== null && draft.oldName !== name) {
|
|
315
|
+
const oldFile = join(DSC_PRESETS_DIR, `${draft.oldName}.md`);
|
|
316
|
+
if (existsSync(oldFile) && !existsSync(file))
|
|
317
|
+
rmSync(oldFile, { force: true });
|
|
318
|
+
}
|
|
319
|
+
writeFileSync(file, presetFileText({ ...draft, name, label, drop }), 'utf8');
|
|
320
|
+
const written = readPreset(file);
|
|
321
|
+
if (written === null)
|
|
322
|
+
throw new Error(`模式 ${name} 写下去了却读不回来,检查一下 ${file}`);
|
|
323
|
+
return written;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* 删掉一个自定义模式。
|
|
327
|
+
*
|
|
328
|
+
* 内置四个不给删:删了下次启动 ensureBuiltinPresets 又会长回来,只会让人以为没删掉;
|
|
329
|
+
* 想改内置的就直接编辑它。
|
|
330
|
+
*/
|
|
331
|
+
export function removePreset(name) {
|
|
332
|
+
if (name in BUILTIN_FILES) {
|
|
333
|
+
throw new Error(`「${name}」是出厂内置模式,删不掉(删了下次启动又会长回来);想改就直接编辑它`);
|
|
334
|
+
}
|
|
335
|
+
if (!PRESET_NAME.test(name))
|
|
336
|
+
throw new Error(`模式名「${name}」不合法`);
|
|
337
|
+
const file = join(DSC_PRESETS_DIR, `${name}.md`);
|
|
338
|
+
if (!existsSync(file))
|
|
339
|
+
throw new Error(`没有名为「${name}」的模式`);
|
|
340
|
+
rmSync(file, { force: true });
|
|
341
|
+
}
|
|
342
|
+
/** 用户输入里的模式别名(`/preset 极简` 这类也能翻)。 */
|
|
343
|
+
const PRESET_ALIASES = {
|
|
344
|
+
standard: STANDARD_PRESET,
|
|
345
|
+
标准: STANDARD_PRESET,
|
|
346
|
+
默认: STANDARD_PRESET,
|
|
347
|
+
minimal: MINIMAL_PRESET,
|
|
348
|
+
极简: MINIMAL_PRESET,
|
|
349
|
+
精简: MINIMAL_PRESET,
|
|
350
|
+
maker: MAKER_PRESET,
|
|
351
|
+
创造: MAKER_PRESET,
|
|
352
|
+
cordis: MAKER_PRESET,
|
|
353
|
+
ptc: PTC_PRESET,
|
|
354
|
+
代码: PTC_PRESET,
|
|
355
|
+
批量: PTC_PRESET,
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* 把用户写的模式词翻成模式名:先按别名表,再按显示名(label)精确匹配。
|
|
359
|
+
* 认不出来返回 null(让调用方报可用清单)。
|
|
360
|
+
*/
|
|
361
|
+
export function parsePresetToken(token, presets = listPresets()) {
|
|
362
|
+
const raw = token.trim();
|
|
363
|
+
if (raw === '')
|
|
364
|
+
return null;
|
|
365
|
+
const alias = PRESET_ALIASES[raw.toLowerCase()];
|
|
366
|
+
if (alias !== undefined)
|
|
367
|
+
return alias;
|
|
368
|
+
const byLabel = presets.find((preset) => preset.label === raw);
|
|
369
|
+
if (byLabel !== undefined)
|
|
370
|
+
return byLabel.name;
|
|
371
|
+
const lower = raw.toLowerCase();
|
|
372
|
+
return presets.some((preset) => preset.name === lower) ? lower : null;
|
|
373
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSeek 官方定价与「本会话花费」估算(人民币口径)。
|
|
3
|
+
*
|
|
4
|
+
* 数据来源:DeepSeek 官方文档「模型 & 价格」页(2026-09 快照,与 dsh 的
|
|
5
|
+
* deepseekPricing.ts 同源),单位为人民币/百万 tokens。DeepSeek 官方 API 只返回
|
|
6
|
+
* token 用量、不返回金额,本模块按官方公开单价把会话累计 token 换算成金额——
|
|
7
|
+
* 这是**估算**,不是账单:定价可能变动,余额扣费发生在 DeepSeek 侧(以平台账单为准)。
|
|
8
|
+
*
|
|
9
|
+
* 计价规则(来自官方页面):
|
|
10
|
+
* - 扣减费用 = token 消耗量 × 模型单价;
|
|
11
|
+
* - 缓存命中的输入按命中价计费,其余输入(含写入缓存)按未命中价计费;
|
|
12
|
+
* - 高峰时段为北京时间周一至周五 9:00-12:00、14:00-18:00,其余为空闲时段
|
|
13
|
+
* (空闲价为高峰价的一半)。
|
|
14
|
+
*
|
|
15
|
+
* 只对 DeepSeek 官方端点生效:Pneuma 的 provider 名是用户在 config.yaml 里自己起的,
|
|
16
|
+
* 这里用「名字含 deepseek」判定(官方 API 的唯一事实来源就是它的域名单词)。
|
|
17
|
+
* 其它 provider / 价目表外的模型一律返回 undefined,界面不显示金额——宁可不显示,
|
|
18
|
+
* 也不给错误数字。
|
|
19
|
+
*
|
|
20
|
+
* @module dsc/core/pricing
|
|
21
|
+
*/
|
|
22
|
+
/** 单价对:`[空闲价, 高峰价]`,单位 元/百万 tokens。 */
|
|
23
|
+
export type CnyPerMillion = readonly [number, number];
|
|
24
|
+
/** 一个官方模型的完整价目(人民币/百万 tokens)。 */
|
|
25
|
+
export interface DeepseekModelPrice {
|
|
26
|
+
/** 输入(缓存未命中)单价;缓存写入量按此价另计。 */
|
|
27
|
+
inputMiss: CnyPerMillion;
|
|
28
|
+
/** 输入(缓存命中)单价。 */
|
|
29
|
+
inputHit: CnyPerMillion;
|
|
30
|
+
/** 输出。 */
|
|
31
|
+
output: CnyPerMillion;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 在售模型价目表,按 API model id 前缀匹配(最长前缀优先)。
|
|
35
|
+
* 新模型上线而本表未收录时,估算返回 undefined,界面不显示金额(只显示
|
|
36
|
+
* token 用量),不会给出错误数字。
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEEPSEEK_MODEL_PRICES: Readonly<Record<string, DeepseekModelPrice>>;
|
|
39
|
+
/** 是否 DeepSeek 官方 provider(定价只适用官方计费口径)。 */
|
|
40
|
+
export declare function isDeepseekProvider(provider: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 是否处于高峰计费时段:北京时间周一至周五 9:00-12:00、14:00-18:00。
|
|
43
|
+
* 北京时间为 UTC+8 固定偏移(无夏令时),用 UTC 时刻加偏移换算。
|
|
44
|
+
*/
|
|
45
|
+
export declare function isPeakHour(date?: Date): boolean;
|
|
46
|
+
/** 按前缀匹配模型价目,最长前缀优先;未收录返回 undefined。 */
|
|
47
|
+
export declare function priceForModel(model: string): DeepseekModelPrice | undefined;
|
|
48
|
+
/** 一个峰/谷桶的 token 分项(与 usage 事件的字段对齐)。 */
|
|
49
|
+
export interface CostBucket {
|
|
50
|
+
/** 缓存命中输入(按命中价计)。 */
|
|
51
|
+
hit: number;
|
|
52
|
+
/** 其余输入(按未命中价计)。 */
|
|
53
|
+
miss: number;
|
|
54
|
+
/** 输出。 */
|
|
55
|
+
output: number;
|
|
56
|
+
}
|
|
57
|
+
/** 按计价时段分桶的会话 token:每笔用量按其发生时刻落入峰或谷。 */
|
|
58
|
+
export interface CostBuckets {
|
|
59
|
+
peak: CostBucket;
|
|
60
|
+
idle: CostBucket;
|
|
61
|
+
}
|
|
62
|
+
/** 空的峰谷分桶(新会话累计起点)。 */
|
|
63
|
+
export declare function emptyCostBuckets(): CostBuckets;
|
|
64
|
+
/**
|
|
65
|
+
* 把一笔用量按发生时刻累加进分桶(不取整不设防,负数调用方自己不传)。
|
|
66
|
+
* Pneuma 的用量口径:`inputTokens` 是 prompt_tokens 总量(缓存命中**包含在内**),
|
|
67
|
+
* 与 dsh 的「互斥分项」不同——所以这里先拆命中/未命中,端点没报明细时全部输入
|
|
68
|
+
* 按未命中价计(保守上限,估算只会偏高不会漏)。
|
|
69
|
+
*/
|
|
70
|
+
export declare function addUsageToBuckets(buckets: CostBuckets, usage: {
|
|
71
|
+
inputTokens: number;
|
|
72
|
+
outputTokens: number;
|
|
73
|
+
cacheHitTokens?: number;
|
|
74
|
+
cacheMissTokens?: number;
|
|
75
|
+
}, peak: boolean): void;
|
|
76
|
+
/** 待计价的一份累计:哪个模型、峰谷各多少 token。 */
|
|
77
|
+
export interface PricedEntry {
|
|
78
|
+
model: string;
|
|
79
|
+
buckets: CostBuckets;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 会话费用估算(人民币,元):逐模型查价求和,峰桶按高峰价、谷桶按空闲价。
|
|
83
|
+
* 没有任何一笔可计价 token(provider 不对口 / 模型未收录 / 一次用量都没有)时
|
|
84
|
+
* 返回 undefined,调用方不显示金额。
|
|
85
|
+
*/
|
|
86
|
+
export declare function estimateSessionCostCny(entries: readonly PricedEntry[]): {
|
|
87
|
+
total: number;
|
|
88
|
+
peak: number;
|
|
89
|
+
idle: number;
|
|
90
|
+
} | undefined;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSeek 官方定价与「本会话花费」估算(人民币口径)。
|
|
3
|
+
*
|
|
4
|
+
* 数据来源:DeepSeek 官方文档「模型 & 价格」页(2026-09 快照,与 dsh 的
|
|
5
|
+
* deepseekPricing.ts 同源),单位为人民币/百万 tokens。DeepSeek 官方 API 只返回
|
|
6
|
+
* token 用量、不返回金额,本模块按官方公开单价把会话累计 token 换算成金额——
|
|
7
|
+
* 这是**估算**,不是账单:定价可能变动,余额扣费发生在 DeepSeek 侧(以平台账单为准)。
|
|
8
|
+
*
|
|
9
|
+
* 计价规则(来自官方页面):
|
|
10
|
+
* - 扣减费用 = token 消耗量 × 模型单价;
|
|
11
|
+
* - 缓存命中的输入按命中价计费,其余输入(含写入缓存)按未命中价计费;
|
|
12
|
+
* - 高峰时段为北京时间周一至周五 9:00-12:00、14:00-18:00,其余为空闲时段
|
|
13
|
+
* (空闲价为高峰价的一半)。
|
|
14
|
+
*
|
|
15
|
+
* 只对 DeepSeek 官方端点生效:Pneuma 的 provider 名是用户在 config.yaml 里自己起的,
|
|
16
|
+
* 这里用「名字含 deepseek」判定(官方 API 的唯一事实来源就是它的域名单词)。
|
|
17
|
+
* 其它 provider / 价目表外的模型一律返回 undefined,界面不显示金额——宁可不显示,
|
|
18
|
+
* 也不给错误数字。
|
|
19
|
+
*
|
|
20
|
+
* @module dsc/core/pricing
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* 在售模型价目表,按 API model id 前缀匹配(最长前缀优先)。
|
|
24
|
+
* 新模型上线而本表未收录时,估算返回 undefined,界面不显示金额(只显示
|
|
25
|
+
* token 用量),不会给出错误数字。
|
|
26
|
+
*/
|
|
27
|
+
export const DEEPSEEK_MODEL_PRICES = {
|
|
28
|
+
'deepseek-flash': {
|
|
29
|
+
inputMiss: [1.0, 2.0],
|
|
30
|
+
inputHit: [0.02, 0.04],
|
|
31
|
+
output: [4.0, 8.0],
|
|
32
|
+
},
|
|
33
|
+
'deepseek-v4-flash': {
|
|
34
|
+
inputMiss: [1.0, 2.0],
|
|
35
|
+
inputHit: [0.02, 0.04],
|
|
36
|
+
output: [4.0, 8.0],
|
|
37
|
+
},
|
|
38
|
+
'deepseek-v4-flash-vision-exp': {
|
|
39
|
+
inputMiss: [1.0, 2.0],
|
|
40
|
+
inputHit: [0.02, 0.04],
|
|
41
|
+
output: [4.0, 8.0],
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
/** 是否 DeepSeek 官方 provider(定价只适用官方计费口径)。 */
|
|
45
|
+
export function isDeepseekProvider(provider) {
|
|
46
|
+
return /deepseek/i.test(provider);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 是否处于高峰计费时段:北京时间周一至周五 9:00-12:00、14:00-18:00。
|
|
50
|
+
* 北京时间为 UTC+8 固定偏移(无夏令时),用 UTC 时刻加偏移换算。
|
|
51
|
+
*/
|
|
52
|
+
export function isPeakHour(date = new Date()) {
|
|
53
|
+
const shifted = new Date(date.getTime() + 8 * 3_600_000);
|
|
54
|
+
const weekday = shifted.getUTCDay(); // 0 = Sunday
|
|
55
|
+
const hour = shifted.getUTCHours();
|
|
56
|
+
if (weekday === 0 || weekday === 6)
|
|
57
|
+
return false;
|
|
58
|
+
return (hour >= 9 && hour < 12) || (hour >= 14 && hour < 18);
|
|
59
|
+
}
|
|
60
|
+
/** 按前缀匹配模型价目,最长前缀优先;未收录返回 undefined。 */
|
|
61
|
+
export function priceForModel(model) {
|
|
62
|
+
let best;
|
|
63
|
+
let bestLength = 0;
|
|
64
|
+
for (const [prefix, price] of Object.entries(DEEPSEEK_MODEL_PRICES)) {
|
|
65
|
+
if (model.startsWith(prefix) && prefix.length > bestLength) {
|
|
66
|
+
best = price;
|
|
67
|
+
bestLength = prefix.length;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return best;
|
|
71
|
+
}
|
|
72
|
+
/** 空的峰谷分桶(新会话累计起点)。 */
|
|
73
|
+
export function emptyCostBuckets() {
|
|
74
|
+
return {
|
|
75
|
+
peak: { hit: 0, miss: 0, output: 0 },
|
|
76
|
+
idle: { hit: 0, miss: 0, output: 0 },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 把一笔用量按发生时刻累加进分桶(不取整不设防,负数调用方自己不传)。
|
|
81
|
+
* Pneuma 的用量口径:`inputTokens` 是 prompt_tokens 总量(缓存命中**包含在内**),
|
|
82
|
+
* 与 dsh 的「互斥分项」不同——所以这里先拆命中/未命中,端点没报明细时全部输入
|
|
83
|
+
* 按未命中价计(保守上限,估算只会偏高不会漏)。
|
|
84
|
+
*/
|
|
85
|
+
export function addUsageToBuckets(buckets, usage, peak) {
|
|
86
|
+
const bucket = peak ? buckets.peak : buckets.idle;
|
|
87
|
+
const hit = usage.cacheHitTokens ?? 0;
|
|
88
|
+
const miss = usage.cacheMissTokens ??
|
|
89
|
+
(usage.cacheHitTokens === undefined ? usage.inputTokens : Math.max(usage.inputTokens - hit, 0));
|
|
90
|
+
bucket.hit += hit;
|
|
91
|
+
bucket.miss += miss;
|
|
92
|
+
bucket.output += usage.outputTokens;
|
|
93
|
+
}
|
|
94
|
+
/** 按峰/谷单价计一桶的钱(元,未除 1e6)。 */
|
|
95
|
+
function bucketCost(bucket, price, rateIndex) {
|
|
96
|
+
return (bucket.miss * price.inputMiss[rateIndex]
|
|
97
|
+
+ bucket.hit * price.inputHit[rateIndex]
|
|
98
|
+
+ bucket.output * price.output[rateIndex]);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 会话费用估算(人民币,元):逐模型查价求和,峰桶按高峰价、谷桶按空闲价。
|
|
102
|
+
* 没有任何一笔可计价 token(provider 不对口 / 模型未收录 / 一次用量都没有)时
|
|
103
|
+
* 返回 undefined,调用方不显示金额。
|
|
104
|
+
*/
|
|
105
|
+
export function estimateSessionCostCny(entries) {
|
|
106
|
+
let total = 0;
|
|
107
|
+
let peak = 0;
|
|
108
|
+
let idle = 0;
|
|
109
|
+
let tokens = 0;
|
|
110
|
+
for (const entry of entries) {
|
|
111
|
+
const price = priceForModel(entry.model);
|
|
112
|
+
if (price === undefined)
|
|
113
|
+
continue;
|
|
114
|
+
const bucketTokens = entry.buckets.peak.hit + entry.buckets.peak.miss + entry.buckets.peak.output
|
|
115
|
+
+ entry.buckets.idle.hit + entry.buckets.idle.miss + entry.buckets.idle.output;
|
|
116
|
+
if (bucketTokens <= 0)
|
|
117
|
+
continue;
|
|
118
|
+
tokens += bucketTokens;
|
|
119
|
+
peak += bucketCost(entry.buckets.peak, price, 1) / 1_000_000;
|
|
120
|
+
idle += bucketCost(entry.buckets.idle, price, 0) / 1_000_000;
|
|
121
|
+
}
|
|
122
|
+
if (tokens <= 0)
|
|
123
|
+
return undefined;
|
|
124
|
+
total = peak + idle;
|
|
125
|
+
return { total, peak, idle };
|
|
126
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/** 一段可装配的提示词贡献(插件与内核共用同一套顺序刻度)。 */
|
|
2
|
+
export interface PromptContribution {
|
|
3
|
+
/** 段 id(同名后注册者顶掉先注册的)。 */
|
|
4
|
+
id: string;
|
|
5
|
+
/** 顺序:小的排在前面。同值按 id 字典序。 */
|
|
6
|
+
order: number;
|
|
7
|
+
/** 段文本(空串等于不出现)。 */
|
|
8
|
+
text: string;
|
|
9
|
+
/**
|
|
10
|
+
* 归并目标。`agents-md` = 这一段不单独成段,而是并进 `# agentsMd` 块
|
|
11
|
+
* (与 AGENTS.md 同一块,见 {@link renderAgentsMd});长期记忆索引走这条路。
|
|
12
|
+
* 缺省 = 按 order 单独成段。
|
|
13
|
+
*/
|
|
14
|
+
block?: 'agents-md';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 指令文件总预算的缺省值——单位是**字符**(UTF-16 code unit,即 `String.length`),
|
|
18
|
+
* 不是字节。整条链(本常量、`instructionBudget` 参数、`prompt.instructionBudget`
|
|
19
|
+
* 插件配置)都按这个口径算,截断判据见 {@link instructionChunks} 里的 `body.length > room`。
|
|
20
|
+
*
|
|
21
|
+
* 为什么保留字符口径而不是改成字节:口径本身不省 token,改口径要同步重算缺省值,
|
|
22
|
+
* 否则中文项目会被悄悄砍半。三家参考实现的预算都是**字节**口径,换算关系如下
|
|
23
|
+
* (`1 字符 = 1 字节` 只在纯 ASCII 下成立;UTF-8 下中文一字 3 字节、emoji 一字 4 字节):
|
|
24
|
+
* - codex:AGENTS.md diff 投影约 32 KiB → 32768 字节;纯 ASCII 下 ≈ 32768 字符,
|
|
25
|
+
* 纯中文下 ≈ 10922 字符(dsc 的 20000 字符在纯中文下 ≈ 60000 字节,比它宽);
|
|
26
|
+
* - dsh:`maxBytes` 默认 65536 字节(`packages/bundle/base/cordis.patch.yml`);
|
|
27
|
+
* 纯 ASCII ≈ 65536 字符、纯中文 ≈ 21845 字符——dsc 的 20000 字符在纯中文下
|
|
28
|
+
* 与它相当(≈60000 字节),纯 ASCII 下比它窄;
|
|
29
|
+
* - ZCode:`# agentsMd` 块预算 100 KB → 约 102400 字节;纯 ASCII ≈ 102400 字符,
|
|
30
|
+
* 纯中文 ≈ 34133 字符——dsc 的 20000 字符是三家最保守的。
|
|
31
|
+
* 一句话:dsc 的这个数是「字符」,与三家的字节数不能直接比大小;要换算按内容语言
|
|
32
|
+
* 乘 1(ASCII)到 3(中文)倍。用户想对齐某一家,把自己那份 AGENTS.md 按上面的
|
|
33
|
+
* 字节数 / 语言系数折算成字符填 `prompt.instructionBudget` 就行。
|
|
34
|
+
*
|
|
35
|
+
* 这个常量只是没配时的缺省;实际用的是 {@link buildSystemPrompt} 的 `instructionBudget`
|
|
36
|
+
* 参数,由 prompt 插件从自己的插件配置里取(见 plugins/prompt.ts)。
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_INSTRUCTION_BUDGET = 20000;
|
|
39
|
+
/** 顺序拼接:先按 order,再按 id。 */
|
|
40
|
+
export declare function composePrompt(sections: readonly PromptContribution[]): string;
|
|
41
|
+
/**
|
|
42
|
+
* 拼 `# agentsMd` 块:AGENTS.md(用户级 + 工作区级)与长期记忆索引**同一个块**。
|
|
43
|
+
*
|
|
44
|
+
* 为什么合在一起(照 ZCode 的 `# agentsMd` 块):两者都是「模型开工前该读的既有约定」,
|
|
45
|
+
* 分两段会让模型把它们当成两套东西;合成一块只留一个标题,读起来是一件事。
|
|
46
|
+
* 标题**不绑定 AGENTS.md**:只有记忆、没有 AGENTS.md 时标题仍在(否则模型拿到的
|
|
47
|
+
* 就是一段没有出处的记忆,不知道该怎么用)。两边都空 = 空串(这一块不出现)。
|
|
48
|
+
*
|
|
49
|
+
* @param instructions - 指令文件正文(已带围栏;没有就传空串)。
|
|
50
|
+
* @param memoryParts - 要并进这一块的记忆段(每段已经是完整文本)。
|
|
51
|
+
*/
|
|
52
|
+
export declare function renderAgentsMd(instructions: string, memoryParts: readonly string[]): string;
|
|
53
|
+
export declare function environmentText(cwd: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* 子代理自己的环境/模型事实(对照 {@link environmentText},但按子代理的 cwd 与工牌模型算)。
|
|
56
|
+
*
|
|
57
|
+
* 为什么要单独一份:子代理的 MiniAgent deps 里没有 `rewrite`,主会话那条 env-facts 投影
|
|
58
|
+
* 对它不生效;而它又不该拿主会话的环境快照——子代理有自己的会话目录与冻结的模型,把主会话
|
|
59
|
+
* 的 cwd/模型塞给它正好是「瞎猜路径」的根因。这段文本直接进它自己的系统提示词(子代理没有
|
|
60
|
+
* 尾部快照那条路)。
|
|
61
|
+
*
|
|
62
|
+
* 刻意不查 git 分支:子代理每轮都要现算这段文本,跑同步 git 子进程不值当;它瞎猜路径的
|
|
63
|
+
* 痛点在 cwd 与平台,不在分支。所以这个函数是纯的(除当天的日期),便于探针直读。
|
|
64
|
+
*/
|
|
65
|
+
export declare function subagentEnvironmentText(cwd: string, model: string): string;
|
|
66
|
+
/** buildSystemPrompt 的可选输入。 */
|
|
67
|
+
export interface SystemPromptOptions {
|
|
68
|
+
/** 技能服务的 `<available_skills>` 文本(空串 = 没有可用技能)。 */
|
|
69
|
+
skills?: string;
|
|
70
|
+
/**
|
|
71
|
+
* 指令文件总预算,**以字符计**(UTF-16 code unit,不是字节;换算见
|
|
72
|
+
* {@link DEFAULT_INSTRUCTION_BUDGET} 的注释);缺省 {@link DEFAULT_INSTRUCTION_BUDGET}。
|
|
73
|
+
*/
|
|
74
|
+
instructionBudget?: number;
|
|
75
|
+
/** 插件贡献段(模式条款、模型信息等);顺序由各段自己声明。 */
|
|
76
|
+
contributions?: readonly PromptContribution[];
|
|
77
|
+
/**
|
|
78
|
+
* 骨架取舍:拿到全部候选段的 id(内置段 + 贡献段),返回要留下的那些。
|
|
79
|
+
* 模式(`core/presets.ts`)就是靠它去掉「做事方式」「工具规范」这类叮嘱段,
|
|
80
|
+
* 让极简档只剩一段固定提示词。缺省 = 一段不去(输出与没有这个参数时逐字节一致)。
|
|
81
|
+
*
|
|
82
|
+
* 注意它只管**提示词文本**:审批硬地板、命令策略、路径策略都在代码里,
|
|
83
|
+
* 去掉多少段提示词都不会让它们松一格。
|
|
84
|
+
*/
|
|
85
|
+
keep?: (ids: readonly string[]) => readonly string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 拼系统提示词。
|
|
89
|
+
* @param cwd - 当前会话工作目录。
|
|
90
|
+
* @param options - 见 {@link SystemPromptOptions}。
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildSystemPrompt(cwd: string, options?: SystemPromptOptions): string;
|