@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,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-compat 插件:dsh(DeepSeek Harness)外部插件的兼容层,官方可开关、默认关。
|
|
3
|
+
*
|
|
4
|
+
* dsh 的外部插件与本仓库同为 cordis 模块插件(命名导出 inject/apply),cordis 版本
|
|
5
|
+
* 也一致;差异只在三处,这个插件补齐两处,第三处在 loader:
|
|
6
|
+
*
|
|
7
|
+
* 1. **logger 服务**:dsh 插件习惯 `inject: ['logger']`。npm 发布的 cordis 把内置
|
|
8
|
+
* logger 做成原型属性而不是可注入服务(dsh 的 vendor 版本是服务),插件一声明
|
|
9
|
+
* inject 就永远等不到、apply 不执行。这里 provide 一个委托到内置 logger 管道的
|
|
10
|
+
* 门面:可调用(named logger)、四种级别都在,warn/error 同时镜像进 transcript,
|
|
11
|
+
* 用户在对话流里看得见。
|
|
12
|
+
* 2. **模块解析钩子**:插件目录里的 dsh 插件 import `@deepseek-ai/*`(defineTool、
|
|
13
|
+
* schemastery 的 z、cordis 本体)时,重定向到 dsc 自带的 node_modules 与 dsh-tools
|
|
14
|
+
* 的传递依赖,cordis 保证单实例。钩子只对插件目录里的导入方生效。
|
|
15
|
+
* 3. **工具形状适配**:ctx.tools 的兼容面在 core/dsh-compat/tools-facade——loader 在
|
|
16
|
+
* 本插件开着时给外部插件的 ctx 换上它,dsh 的 ToolDefinition 与 dsc 的 ToolEntry
|
|
17
|
+
* 都能注册;risk 映射(dsh 没有这个概念)按插件条目配置,缺省每次调用都过审批卡。
|
|
18
|
+
*
|
|
19
|
+
* 兼容边界(明确不支持,挂载时响亮报错):inject 里出现 `sessionProjections`、`agents`、
|
|
20
|
+
* `goals`、`systemPrompt` 等 dsh 服务名的插件——那要整个 dsh 会话语义,个人版不背。
|
|
21
|
+
*
|
|
22
|
+
* @module dsc/plugins/dsh-compat
|
|
23
|
+
*/
|
|
24
|
+
import type { Plugin } from '@deepseek-ai/cordis';
|
|
25
|
+
export declare const dshCompatPlugin: Plugin.Object;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Logger, defaultFormatters } from '@deepseek-ai/cordis';
|
|
2
|
+
import { ensureResolveHook } from '../core/dsh-compat/resolve-hook.js';
|
|
3
|
+
import { DSC_PLUGINS_DIR } from '../core/plugin-loader.js';
|
|
4
|
+
export const dshCompatPlugin = {
|
|
5
|
+
name: 'dsh-compat',
|
|
6
|
+
inject: ['transcript'],
|
|
7
|
+
provide: 'logger',
|
|
8
|
+
apply(ctx) {
|
|
9
|
+
// 钩子注册同步生效;loader 在挂载外部插件前还会调一次(幂等),这里兜底
|
|
10
|
+
void ensureResolveHook([DSC_PLUGINS_DIR]);
|
|
11
|
+
// 内置 logger 管道上的桥:warn/error 镜像进 transcript(info/debug 不转,防刷屏)。
|
|
12
|
+
// levels 显式放到 debug(3):exporter 缺省阈值是 info(1),warn/error 会被默认滤掉。
|
|
13
|
+
// 文案经 Logger.format 还原 printf 占位符(dsh 插件习惯 warn('failed: %s', err))。
|
|
14
|
+
const offExporter = ctx.logger.exporter({
|
|
15
|
+
levels: { default: 3 },
|
|
16
|
+
export: (message) => {
|
|
17
|
+
if (message.type !== 'warn' && message.type !== 'error')
|
|
18
|
+
return;
|
|
19
|
+
const text = Logger.format({ formatters: defaultFormatters, export() { } }, message);
|
|
20
|
+
ctx.transcript.system(`[dsh 插件${message.name === '' ? '' : `·${message.name}`}] ${text}`);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
// 可注入的 logger 门面:可调用(ctx.logger('名字'))、四种级别都委托内置管道,
|
|
24
|
+
// 于是 named logger 的 warn/error 同样被上面的桥镜像进 transcript。
|
|
25
|
+
const builtin = ctx.logger;
|
|
26
|
+
const service = Object.assign((name) => builtin(name), {
|
|
27
|
+
debug: (format, ...rest) => builtin.debug(format, ...rest),
|
|
28
|
+
info: (format, ...rest) => builtin.info(format, ...rest),
|
|
29
|
+
warn: (format, ...rest) => builtin.warn(format, ...rest),
|
|
30
|
+
error: (format, ...rest) => builtin.error(format, ...rest),
|
|
31
|
+
});
|
|
32
|
+
ctx.provide('logger', service);
|
|
33
|
+
return () => {
|
|
34
|
+
void offExporter();
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Plugin } from '@deepseek-ai/cordis';
|
|
2
|
+
import { type DiffResult } from '../core/diff-text.js';
|
|
3
|
+
import type { ToolGuardInput } from '../core/tool-guards.js';
|
|
4
|
+
/** 插件在条目树(`~/.dsc/plugins.json`)里的键;同时是设置分区 id。 */
|
|
5
|
+
export declare const FILE_REVIEW_CONFIG_KEY = "file-review";
|
|
6
|
+
/** 可调值的区间:设置页的 min/max 与这里的夹取共用一份,免得两处对不上。 */
|
|
7
|
+
export declare const FILE_REVIEW_RANGES: {
|
|
8
|
+
/** diff 最多显示几行(含 hunk 头)。 */
|
|
9
|
+
readonly maxLines: {
|
|
10
|
+
readonly min: 5;
|
|
11
|
+
readonly max: 2000;
|
|
12
|
+
};
|
|
13
|
+
/** 每个 hunk 前后各留几行上下文。 */
|
|
14
|
+
readonly contextLines: {
|
|
15
|
+
readonly min: 0;
|
|
16
|
+
readonly max: 20;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 缺省值。取 120 行:一次正常的定点编辑通常几十行就够,
|
|
21
|
+
* 120 行既能把「改了哪些地方」说全,又不会让一条预览挤掉半屏对话。
|
|
22
|
+
*/
|
|
23
|
+
export declare const FILE_REVIEW_DEFAULTS: {
|
|
24
|
+
readonly enabled: true;
|
|
25
|
+
readonly maxLines: 120;
|
|
26
|
+
readonly contextLines: 3;
|
|
27
|
+
};
|
|
28
|
+
/** 这个插件的可调值。 */
|
|
29
|
+
export interface FileReviewConfig {
|
|
30
|
+
/** 关掉之后一次预览都不发(审批照常问,只是不会再先贴 diff)。 */
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
/** 一条预览最多显示几行 diff(含 hunk 头);超出的在末尾写明还剩多少行。 */
|
|
33
|
+
maxLines: number;
|
|
34
|
+
/** 每个 hunk 前后各留几行上下文。 */
|
|
35
|
+
contextLines: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 逐项夹到 {@link FILE_REVIEW_RANGES} 的范围里,写错类型就用缺省值。
|
|
39
|
+
* 单个值越界不该让整条工具链停下,所以这里不抛错;真有问题在设置页上看得见。
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseFileReviewConfig(raw: Record<string, unknown>): FileReviewConfig;
|
|
42
|
+
/**
|
|
43
|
+
* 取这个插件此刻该用的配置:装配时传进来的那份作底,磁盘上那份覆盖它。
|
|
44
|
+
* 每次判定现读(不是挂载时读一次),所以设置里改完立刻生效。
|
|
45
|
+
*/
|
|
46
|
+
export declare function readFileReviewConfig(passed?: unknown): FileReviewConfig;
|
|
47
|
+
/** 一次预览的全部素材(纯数据,渲染与自检脚本都从这里出发)。 */
|
|
48
|
+
export interface FileReviewPreview {
|
|
49
|
+
/** 工具名(write / edit)。 */
|
|
50
|
+
toolName: string;
|
|
51
|
+
/** 目标文件的绝对路径。 */
|
|
52
|
+
path: string;
|
|
53
|
+
/** 换算成相对工作目录的写法(拿不到相对路径时就是绝对路径)。 */
|
|
54
|
+
displayPath: string;
|
|
55
|
+
/** 'create' = 文件原先不存在,整篇都是新增;'update' = 定点改动。 */
|
|
56
|
+
action: 'create' | 'update';
|
|
57
|
+
/** 改动前的行数。 */
|
|
58
|
+
beforeLines: number;
|
|
59
|
+
/** 改动后的行数。 */
|
|
60
|
+
afterLines: number;
|
|
61
|
+
added: number;
|
|
62
|
+
removed: number;
|
|
63
|
+
diff: DiffResult;
|
|
64
|
+
/**
|
|
65
|
+
* 改动前后的全文。
|
|
66
|
+
* 为什么要留着:hunk 是**按当前上下文行数**切出来的(`renderReview` 拿到的是当下这份配置),
|
|
67
|
+
* 而 `buildPreview` 生成时用的上下文只是那一刻的配置——用户改完设置项,
|
|
68
|
+
* 已经算好的那份 hunk 切法就过期了。留一份原文,渲染时按当时的配置重切一次,
|
|
69
|
+
* 设置改完立刻生效,不必等下一次工具调用。
|
|
70
|
+
*/
|
|
71
|
+
before: string;
|
|
72
|
+
after: string;
|
|
73
|
+
/** 单行摘要(`/review` 的最近几次预览用它)。 */
|
|
74
|
+
summary: string;
|
|
75
|
+
}
|
|
76
|
+
/** 一次预览的渲染产物:摆给用户的文本 + 截断信息。 */
|
|
77
|
+
export interface RenderedReview {
|
|
78
|
+
text: string;
|
|
79
|
+
/** 因为超过显示上限被省略的 diff 行数(0 = 全显示了)。 */
|
|
80
|
+
omitted: number;
|
|
81
|
+
/** 实际显示了多少行 diff(含 hunk 头)。 */
|
|
82
|
+
shown: number;
|
|
83
|
+
}
|
|
84
|
+
/** 把绝对路径写成相对工作目录的样子;Windows 上统一成 `/`,跟 diff 头与编辑器一致。 */
|
|
85
|
+
export declare function displayPathOf(cwd: string, path: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* 算一份预览。
|
|
88
|
+
*
|
|
89
|
+
* `edit` 的替换规则跟 `core/tools/fs-tools.ts:113-115` 保持一致:old 必须唯一命中;
|
|
90
|
+
* 不唯一或找不到就说清「预览算不出来、工具执行时才会报错」,而不是给一份假的 diff。
|
|
91
|
+
*
|
|
92
|
+
* @param input - 守卫链递进来的那次调用(只读它的 toolName / args / cwd / target)。
|
|
93
|
+
* @param config - 当前配置(决定上下文行数)。
|
|
94
|
+
* @returns 预览素材;这次调用不该预览时返回 null。
|
|
95
|
+
*/
|
|
96
|
+
export declare function buildPreview(input: ToolGuardInput, config: FileReviewConfig): FileReviewPreview | null;
|
|
97
|
+
/**
|
|
98
|
+
* 渲染成摆给用户看的那段文本。
|
|
99
|
+
*
|
|
100
|
+
* 截断照仓库惯例来(`core/spill.ts:268`):超出上限时留明确标记,写清「只显示了多少行、还有多少行」,
|
|
101
|
+
* 绝不让读者以为看到的是全部。截断按整行切,绝不腰斩一个 hunk 头。
|
|
102
|
+
*
|
|
103
|
+
* @param preview - {@link buildPreview} 的产物。
|
|
104
|
+
* @param config - 当前配置(决定显示上限)。
|
|
105
|
+
* @param note - 额外要说明的一句话(例如审批策略是「仅查看」,这次根本不会落盘)。
|
|
106
|
+
*/
|
|
107
|
+
export declare function renderReview(preview: FileReviewPreview, config: FileReviewConfig, note?: string): RenderedReview;
|
|
108
|
+
export declare const fileReviewPlugin: Plugin.Object;
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* file-review 插件:edit / write 动手之前,把「改了哪几行」算成 unified diff 摆给用户看。
|
|
3
|
+
*
|
|
4
|
+
* **挂在哪一环**:守卫链 order 25——真实刻度是灾难地板 5、模式闸门 10、安全钩子 20、
|
|
5
|
+
* **文件预览 25**、审批 30(`core/tool-guards.ts:43` 写着内置刻度)。摆这个位置的理由:
|
|
6
|
+
* 1. 它必须早于审批卡(30),用户点「允许」之前就已经看见要改什么;
|
|
7
|
+
* 2. 它必须晚于模式闸门与安全钩子,这一位只听「参数里写了什么」,不需要跟它们抢裁决权;
|
|
8
|
+
* 3. 它永远 defer,从不 deny、从不 pass——一条纯观察的守卫返回 pass 会把后面的审批卡
|
|
9
|
+
* 一起跳掉(`plugins/approval-floor.ts:19` 记着这个坑),所以这里只表态「我没意见」。
|
|
10
|
+
* 这跟 Codex 的做法同构:Codex 在执行前算出 unified diff,把它挂在审批请求
|
|
11
|
+
* (`ApplyPatchApprovalRequestEvent.changes`,`protocol/src/approvals.rs:471-487`)与会话流
|
|
12
|
+
* (`PatchHistoryCell`,`tui/src/history_cell/patches.rs:44-50`)上。
|
|
13
|
+
*
|
|
14
|
+
* **怎么送到用户眼前**:走 `ctx.emit('dsc/notice', …)` → transcript 折成一条 system 条目
|
|
15
|
+
* (`plugins/transcript.ts:35-38`)。这是仓库里现成的「把一句话摆进对话流」通道,
|
|
16
|
+
* 而且恢复历史会话时 transcript 会整个清空重放(`plugins/transcript.ts:43-48`),
|
|
17
|
+
* 所以这些预览不会攒成僵尸条目。
|
|
18
|
+
*
|
|
19
|
+
* **为什么是只读的**:这一位不读文件以外的任何东西、不落盘、不改参数、不拦任何调用(恒 defer),
|
|
20
|
+
* 最坏情况就是多出一段没被采纳的预览文字。算不动(超大改动区间)时退回摘要,而不是抛错——
|
|
21
|
+
* 守卫链上抛错按拒处理(`core/tool-guards.ts:104-109`),预览这种锦上添花的东西没有资格拦下写操作。
|
|
22
|
+
*
|
|
23
|
+
* @module dsc/plugins/file-review
|
|
24
|
+
*/
|
|
25
|
+
import { readFileSync } from 'node:fs';
|
|
26
|
+
import { relative } from 'node:path';
|
|
27
|
+
import { diffLines, renderHunk, } from '../core/diff-text.js';
|
|
28
|
+
import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
|
|
29
|
+
import { callFacts } from '../core/tools.js';
|
|
30
|
+
/** 插件在条目树(`~/.dsc/plugins.json`)里的键;同时是设置分区 id。 */
|
|
31
|
+
export const FILE_REVIEW_CONFIG_KEY = 'file-review';
|
|
32
|
+
/** 走这套预览的工具:只认会落盘的那两个(bash 里的写没法在动手前知道结果,不在这一位管)。 */
|
|
33
|
+
const REVIEWED_TOOLS = new Set(['write', 'edit']);
|
|
34
|
+
/** 可调值的区间:设置页的 min/max 与这里的夹取共用一份,免得两处对不上。 */
|
|
35
|
+
export const FILE_REVIEW_RANGES = {
|
|
36
|
+
/** diff 最多显示几行(含 hunk 头)。 */
|
|
37
|
+
maxLines: { min: 5, max: 2000 },
|
|
38
|
+
/** 每个 hunk 前后各留几行上下文。 */
|
|
39
|
+
contextLines: { min: 0, max: 20 },
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 缺省值。取 120 行:一次正常的定点编辑通常几十行就够,
|
|
43
|
+
* 120 行既能把「改了哪些地方」说全,又不会让一条预览挤掉半屏对话。
|
|
44
|
+
*/
|
|
45
|
+
export const FILE_REVIEW_DEFAULTS = {
|
|
46
|
+
enabled: true,
|
|
47
|
+
maxLines: 120,
|
|
48
|
+
contextLines: 3,
|
|
49
|
+
};
|
|
50
|
+
/** 夹到区间内的整数;认不出的值退回缺省。 */
|
|
51
|
+
function clampInt(value, range, fallback) {
|
|
52
|
+
const num = Number(value);
|
|
53
|
+
return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), range.min), range.max) : fallback;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 逐项夹到 {@link FILE_REVIEW_RANGES} 的范围里,写错类型就用缺省值。
|
|
57
|
+
* 单个值越界不该让整条工具链停下,所以这里不抛错;真有问题在设置页上看得见。
|
|
58
|
+
*/
|
|
59
|
+
export function parseFileReviewConfig(raw) {
|
|
60
|
+
return {
|
|
61
|
+
// 只有显式写了 false 才算关:没配过(缺键)时保持默认开着
|
|
62
|
+
enabled: raw.enabled !== false,
|
|
63
|
+
maxLines: clampInt(raw.maxLines, FILE_REVIEW_RANGES.maxLines, FILE_REVIEW_DEFAULTS.maxLines),
|
|
64
|
+
contextLines: clampInt(raw.contextLines, FILE_REVIEW_RANGES.contextLines, FILE_REVIEW_DEFAULTS.contextLines),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 取这个插件此刻该用的配置:装配时传进来的那份作底,磁盘上那份覆盖它。
|
|
69
|
+
* 每次判定现读(不是挂载时读一次),所以设置里改完立刻生效。
|
|
70
|
+
*/
|
|
71
|
+
export function readFileReviewConfig(passed) {
|
|
72
|
+
return parseFileReviewConfig(resolvePluginConfig(FILE_REVIEW_CONFIG_KEY, passed));
|
|
73
|
+
}
|
|
74
|
+
/** 把绝对路径写成相对工作目录的样子;Windows 上统一成 `/`,跟 diff 头与编辑器一致。 */
|
|
75
|
+
export function displayPathOf(cwd, path) {
|
|
76
|
+
const rel = relative(cwd, path);
|
|
77
|
+
const use = rel === '' || rel.startsWith('..') ? path : rel;
|
|
78
|
+
return use.replace(/\\/g, '/');
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 认这次调用要动哪个文件。
|
|
82
|
+
*
|
|
83
|
+
* 路径的绝对化复用 `core/tools.ts:42` 的 `callFacts`(跟循环递进守卫链的是同一份认法,
|
|
84
|
+
* 参数名 file_path / path / target / file 都认),自己再写一份迟早会跟它走岔。
|
|
85
|
+
* 返回值 null = 这次调用没指名要动哪个文件,那就不预览。
|
|
86
|
+
*/
|
|
87
|
+
function targetPathOf(input) {
|
|
88
|
+
// 先确认参数里确实写了 path:工具靠它定位,没写就没什么可预览的
|
|
89
|
+
const raw = input.args.path;
|
|
90
|
+
if (typeof raw !== 'string' || raw.trim() === '')
|
|
91
|
+
return null;
|
|
92
|
+
return callFacts(input.args, input.cwd).target ?? input.target ?? null;
|
|
93
|
+
}
|
|
94
|
+
/** 读旧内容。文件不存在 = 新建(读失败与不存在要分开,读失败得说一句)。 */
|
|
95
|
+
function readBefore(path) {
|
|
96
|
+
try {
|
|
97
|
+
return { text: readFileSync(path, 'utf8'), missing: false, problem: null };
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const code = error.code;
|
|
101
|
+
if (code === 'ENOENT' || code === 'ENOTDIR')
|
|
102
|
+
return { text: '', missing: true, problem: null };
|
|
103
|
+
return { text: '', missing: false, problem: error instanceof Error ? error.message : String(error) };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 算一份预览。
|
|
108
|
+
*
|
|
109
|
+
* `edit` 的替换规则跟 `core/tools/fs-tools.ts:113-115` 保持一致:old 必须唯一命中;
|
|
110
|
+
* 不唯一或找不到就说清「预览算不出来、工具执行时才会报错」,而不是给一份假的 diff。
|
|
111
|
+
*
|
|
112
|
+
* @param input - 守卫链递进来的那次调用(只读它的 toolName / args / cwd / target)。
|
|
113
|
+
* @param config - 当前配置(决定上下文行数)。
|
|
114
|
+
* @returns 预览素材;这次调用不该预览时返回 null。
|
|
115
|
+
*/
|
|
116
|
+
export function buildPreview(input, config) {
|
|
117
|
+
if (!REVIEWED_TOOLS.has(input.toolName.toLowerCase()))
|
|
118
|
+
return null;
|
|
119
|
+
const path = targetPathOf(input);
|
|
120
|
+
if (path === null)
|
|
121
|
+
return null;
|
|
122
|
+
const before = readBefore(path);
|
|
123
|
+
let after = '';
|
|
124
|
+
let action = before.missing ? 'create' : 'update';
|
|
125
|
+
if (input.toolName.toLowerCase() === 'edit') {
|
|
126
|
+
const oldText = typeof input.args.old === 'string' ? input.args.old : null;
|
|
127
|
+
const newText = typeof input.args.new === 'string' ? input.args.new : null;
|
|
128
|
+
if (oldText === null || newText === null)
|
|
129
|
+
return null;
|
|
130
|
+
if (before.missing) {
|
|
131
|
+
// edit 对不存在的文件必然失败,预览没有意义(工具自己会回一句 old 不存在)
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const at = before.text.indexOf(oldText);
|
|
135
|
+
if (at < 0) {
|
|
136
|
+
return noteOnly(input.toolName, input.cwd, path, 'old 内容在文件里找不到,这次 edit 会失败;这里不是即将发生的改动');
|
|
137
|
+
}
|
|
138
|
+
if (before.text.indexOf(oldText, at + 1) >= 0) {
|
|
139
|
+
return noteOnly(input.toolName, input.cwd, path, 'old 内容匹配多处,这次 edit 会失败;这里不是即将发生的改动');
|
|
140
|
+
}
|
|
141
|
+
after = before.text.slice(0, at) + newText + before.text.slice(at + oldText.length);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
if (typeof input.args.content !== 'string')
|
|
145
|
+
return null;
|
|
146
|
+
after = input.args.content;
|
|
147
|
+
action = before.missing ? 'create' : 'update';
|
|
148
|
+
}
|
|
149
|
+
const diff = diffLines(before.text, after, config.contextLines);
|
|
150
|
+
const draft = {
|
|
151
|
+
toolName: input.toolName.toLowerCase(),
|
|
152
|
+
path,
|
|
153
|
+
displayPath: displayPathOf(input.cwd, path),
|
|
154
|
+
action,
|
|
155
|
+
beforeLines: countLines(before.text),
|
|
156
|
+
afterLines: countLines(after),
|
|
157
|
+
added: diff.added,
|
|
158
|
+
removed: diff.removed,
|
|
159
|
+
diff,
|
|
160
|
+
before: before.text,
|
|
161
|
+
after,
|
|
162
|
+
};
|
|
163
|
+
return { ...draft, summary: summarize(draft, before.problem) };
|
|
164
|
+
}
|
|
165
|
+
/** 「算不出 diff」时的那种预览:没有 hunk,只有一句说明(正文不贴,免得看着像改动)。 */
|
|
166
|
+
function noteOnly(toolName, cwd, path, note) {
|
|
167
|
+
const empty = { ok: false, hunks: [], added: 0, removed: 0, note, identical: false, oversize: false };
|
|
168
|
+
const draft = {
|
|
169
|
+
toolName: toolName.toLowerCase(),
|
|
170
|
+
path,
|
|
171
|
+
displayPath: displayPathOf(cwd, path),
|
|
172
|
+
action: 'update',
|
|
173
|
+
beforeLines: 0,
|
|
174
|
+
afterLines: 0,
|
|
175
|
+
added: 0,
|
|
176
|
+
removed: 0,
|
|
177
|
+
diff: empty,
|
|
178
|
+
before: '',
|
|
179
|
+
after: '',
|
|
180
|
+
};
|
|
181
|
+
return { ...draft, summary: `${draft.displayPath}|预览算不出:${note}` };
|
|
182
|
+
}
|
|
183
|
+
/** 行数(空文本算 0 行,与 diffLines 的切法保持一致)。 */
|
|
184
|
+
function countLines(text) {
|
|
185
|
+
if (text === '')
|
|
186
|
+
return 0;
|
|
187
|
+
const body = text.endsWith('\n') ? text.slice(0, -1) : text;
|
|
188
|
+
return body === '' ? 0 : body.split('\n').length;
|
|
189
|
+
}
|
|
190
|
+
/** 单行摘要(带读文件失败之类的意外时一并说清)。 */
|
|
191
|
+
function summarize(preview, problem) {
|
|
192
|
+
const verb = preview.action === 'create' ? '新建' : '修改';
|
|
193
|
+
const counts = preview.diff.ok ? `+${String(preview.added)} -${String(preview.removed)}` : '只给摘要';
|
|
194
|
+
const trouble = problem === null ? '' : `(没能读到原文件:${problem})`;
|
|
195
|
+
return `${verb} ${preview.displayPath}|${counts}${trouble}`;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 渲染成摆给用户看的那段文本。
|
|
199
|
+
*
|
|
200
|
+
* 截断照仓库惯例来(`core/spill.ts:268`):超出上限时留明确标记,写清「只显示了多少行、还有多少行」,
|
|
201
|
+
* 绝不让读者以为看到的是全部。截断按整行切,绝不腰斩一个 hunk 头。
|
|
202
|
+
*
|
|
203
|
+
* @param preview - {@link buildPreview} 的产物。
|
|
204
|
+
* @param config - 当前配置(决定显示上限)。
|
|
205
|
+
* @param note - 额外要说明的一句话(例如审批策略是「仅查看」,这次根本不会落盘)。
|
|
206
|
+
*/
|
|
207
|
+
export function renderReview(preview, config, note) {
|
|
208
|
+
const verb = preview.action === 'create' ? '新建' : '修改';
|
|
209
|
+
// 按当下这份配置重切一次 hunk:用户在设置页改了上下文行数,也不该等下一次工具调用才生效
|
|
210
|
+
const diff = preview.diff.ok ? diffLines(preview.before, preview.after, config.contextLines) : preview.diff;
|
|
211
|
+
const counts = diff.ok
|
|
212
|
+
? `+${String(diff.added)} 行 / -${String(diff.removed)} 行`
|
|
213
|
+
: '逐行 diff 未给出';
|
|
214
|
+
const head = [`【文件更改预览·尚未落盘】${verb} ${preview.displayPath}(${counts})`];
|
|
215
|
+
const body = [];
|
|
216
|
+
if (diff.identical) {
|
|
217
|
+
body.push('(内容与磁盘上现在这份完全一样,这次写入不会改动任何一行)');
|
|
218
|
+
}
|
|
219
|
+
else if (!diff.ok) {
|
|
220
|
+
body.push(`(${diff.note ?? '算不出逐行差异'})`);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
for (const hunk of diff.hunks)
|
|
224
|
+
body.push(...renderHunk(hunk));
|
|
225
|
+
if (config.contextLines === 0)
|
|
226
|
+
body.push('(上下文行数设为 0,只列改动本身)');
|
|
227
|
+
}
|
|
228
|
+
const shown = Math.min(body.length, config.maxLines);
|
|
229
|
+
const omitted = body.length - shown;
|
|
230
|
+
const tail = [];
|
|
231
|
+
if (omitted > 0)
|
|
232
|
+
tail.push(`…(这份预览只显示前 ${String(shown)} 行,还有 ${String(omitted)} 行未显示;把设置里「一条预览最多显示几行」调大可以看全)`);
|
|
233
|
+
if (diff.note !== undefined && diff.ok)
|
|
234
|
+
tail.push(`(${diff.note})`);
|
|
235
|
+
if (note !== undefined && note !== '')
|
|
236
|
+
tail.push(note);
|
|
237
|
+
return { text: [...head, ...body.slice(0, shown), ...tail].join('\n'), omitted, shown };
|
|
238
|
+
}
|
|
239
|
+
export const fileReviewPlugin = {
|
|
240
|
+
name: 'file-review',
|
|
241
|
+
inject: ['guards', 'settings', 'commands'],
|
|
242
|
+
apply(ctx, passed) {
|
|
243
|
+
/** 每次都现读:设置里改完立刻生效,不必重启宿主。 */
|
|
244
|
+
const config = () => readFileReviewConfig(passed);
|
|
245
|
+
/** 最近几次预览的摘要(`/review` 命令用;只留摘要不留正文,免得白占内存)。 */
|
|
246
|
+
const recent = [];
|
|
247
|
+
/** 本会话发过多少条预览、其中多少条被截断(`/review` 一眼看出它有没有在工作)。 */
|
|
248
|
+
let emitted = 0;
|
|
249
|
+
let truncated = 0;
|
|
250
|
+
const remember = (line) => {
|
|
251
|
+
recent.unshift(line);
|
|
252
|
+
if (recent.length > 8)
|
|
253
|
+
recent.length = 8;
|
|
254
|
+
};
|
|
255
|
+
const guard = {
|
|
256
|
+
id: 'file-review',
|
|
257
|
+
// 真实刻度:地板 5、模式 10、安全钩子 20、本插件 25、审批 30(core/tool-guards.ts:43)
|
|
258
|
+
order: 25,
|
|
259
|
+
decide(input) {
|
|
260
|
+
const cfg = config();
|
|
261
|
+
if (!cfg.enabled)
|
|
262
|
+
return { action: 'defer' };
|
|
263
|
+
// 只读工具不预览;bash 之类的执行类工具没法在动手前知道它写了什么,也不预览
|
|
264
|
+
if (input.risk === 'read')
|
|
265
|
+
return { action: 'defer' };
|
|
266
|
+
let preview;
|
|
267
|
+
try {
|
|
268
|
+
preview = buildPreview(input, cfg);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
// 守卫链上抛错按拒处理(core/tool-guards.ts:104-109)。预览是锦上添花的东西,
|
|
272
|
+
// 没有资格因为自己算不动就把一次写操作拦下来,所以这里自己吞掉,只留一句提示。
|
|
273
|
+
ctx.emit('dsc/notice', `文件更改预览算不出来(不影响这次调用):${error instanceof Error ? error.message : String(error)}`);
|
|
274
|
+
return { action: 'defer' };
|
|
275
|
+
}
|
|
276
|
+
if (preview === null)
|
|
277
|
+
return { action: 'defer' };
|
|
278
|
+
const rendered = renderReview(preview, cfg);
|
|
279
|
+
emitted += 1;
|
|
280
|
+
if (rendered.omitted > 0)
|
|
281
|
+
truncated += 1;
|
|
282
|
+
remember(preview.summary);
|
|
283
|
+
// 先落进对话流:审批卡(order 30)随即会弹在它下面,用户是先看见改动、再决定放不放行
|
|
284
|
+
ctx.emit('dsc/notice', rendered.text);
|
|
285
|
+
return { action: 'defer' };
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
const offGuard = ctx.guards.register(guard);
|
|
289
|
+
// ── /review 命令:不经模型就能确认这一位在不在链上、配置是什么 ────────────────
|
|
290
|
+
const describe = () => {
|
|
291
|
+
const cfg = config();
|
|
292
|
+
const lines = [];
|
|
293
|
+
lines.push(`文件更改预览:${cfg.enabled ? '开着' : '关着'}|守卫链 order 25(模式 10、安全钩子 20、本插件 25、审批 30)`);
|
|
294
|
+
lines.push(`一条预览最多显示 ${String(cfg.maxLines)} 行|每个 hunk 前后留 ${String(cfg.contextLines)} 行上下文`);
|
|
295
|
+
lines.push(`这次挂载以来发过 ${String(emitted)} 条预览(其中 ${String(truncated)} 条被截断)`);
|
|
296
|
+
lines.push('配置文件:~/.dsc/plugins.json 的 file-review 条目(设置页也能改)');
|
|
297
|
+
lines.push(recent.length === 0 ? '最近还没有预览过。' : `最近预览:\n${recent.map((line) => ` ${line}`).join('\n')}`);
|
|
298
|
+
return lines.join('\n');
|
|
299
|
+
};
|
|
300
|
+
const offCommand = ctx.commands.register(
|
|
301
|
+
// 不叫 /review:那是内置的「审查工作区未提交改动」命令,同名注册会把它顶掉
|
|
302
|
+
// (registry 是 Map.set 覆盖语义,file-review 默认启用,曾把 /review 劫走)。
|
|
303
|
+
{ name: 'file-review', args: '', description: '看文件更改预览的状态与最近几次预览' }, ({ ui }) => ui.notice(describe()));
|
|
304
|
+
// ── 设置分区 ──────────────────────────────────────────────────────────────
|
|
305
|
+
const section = {
|
|
306
|
+
id: FILE_REVIEW_CONFIG_KEY,
|
|
307
|
+
title: '文件更改预览',
|
|
308
|
+
subtitle: 'edit / write 落盘前先把 unified diff 摆进对话流,改哪几行看得见',
|
|
309
|
+
// 排在大输出溢出(37)前面:这一档管的是「改之前看见」,比事后截断更靠前
|
|
310
|
+
order: 36,
|
|
311
|
+
fields() {
|
|
312
|
+
const cfg = config();
|
|
313
|
+
return [
|
|
314
|
+
{
|
|
315
|
+
type: 'switch',
|
|
316
|
+
key: 'enabled',
|
|
317
|
+
label: '启用文件更改预览',
|
|
318
|
+
help: '关掉之后不再往对话流贴 diff,工具照常执行、审批照常问。',
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
type: 'number',
|
|
322
|
+
key: 'maxLines',
|
|
323
|
+
label: '一条预览最多显示几行',
|
|
324
|
+
min: FILE_REVIEW_RANGES.maxLines.min,
|
|
325
|
+
max: FILE_REVIEW_RANGES.maxLines.max,
|
|
326
|
+
step: 10,
|
|
327
|
+
help: `超过这个行数的部分不显示,末尾写明还剩多少行(默认 ${String(FILE_REVIEW_DEFAULTS.maxLines)})。`,
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
type: 'number',
|
|
331
|
+
key: 'contextLines',
|
|
332
|
+
label: '改动前后各留几行上下文',
|
|
333
|
+
min: FILE_REVIEW_RANGES.contextLines.min,
|
|
334
|
+
max: FILE_REVIEW_RANGES.contextLines.max,
|
|
335
|
+
step: 1,
|
|
336
|
+
help: '跟 `diff -u` 的 -U 一个意思:0 = 只看改动本身,3 = 默认。留几行上下文才看得出改在哪个函数里。',
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: 'info',
|
|
340
|
+
label: '它在链上的位置',
|
|
341
|
+
text: 'order 25:比审批卡(30)早,所以点「允许」之前就已经看见要改什么;它自己永远不拦、不替别的守卫放行(一律 defer)。',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
type: 'info',
|
|
345
|
+
label: '这次挂载的统计',
|
|
346
|
+
text: `发过 ${String(emitted)} 条预览,其中 ${String(truncated)} 条因为超过行数上限被截断。`,
|
|
347
|
+
},
|
|
348
|
+
];
|
|
349
|
+
},
|
|
350
|
+
values() {
|
|
351
|
+
const cfg = config();
|
|
352
|
+
return { enabled: cfg.enabled, maxLines: cfg.maxLines, contextLines: cfg.contextLines };
|
|
353
|
+
},
|
|
354
|
+
save(key, value) {
|
|
355
|
+
switch (key) {
|
|
356
|
+
case 'enabled':
|
|
357
|
+
writePluginConfig(FILE_REVIEW_CONFIG_KEY, { enabled: value === true });
|
|
358
|
+
break;
|
|
359
|
+
case 'maxLines': {
|
|
360
|
+
const num = Number(value);
|
|
361
|
+
if (!Number.isFinite(num))
|
|
362
|
+
return '这里要填一个数字(行)';
|
|
363
|
+
// 越界的值写进去也没关系:用的时候会被夹回区间(parseFileReviewConfig)
|
|
364
|
+
writePluginConfig(FILE_REVIEW_CONFIG_KEY, { maxLines: Math.round(num) });
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
case 'contextLines': {
|
|
368
|
+
const num = Number(value);
|
|
369
|
+
if (!Number.isFinite(num))
|
|
370
|
+
return '这里要填一个数字(行)';
|
|
371
|
+
writePluginConfig(FILE_REVIEW_CONFIG_KEY, { contextLines: Math.round(num) });
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
default:
|
|
375
|
+
return `这个分区没有这项:${key}`;
|
|
376
|
+
}
|
|
377
|
+
ctx.emit('dsc/changed');
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
const offSection = ctx.settings.registerSection(section);
|
|
381
|
+
ctx.on('dsc/session-open', () => {
|
|
382
|
+
// 换会话清一次统计:上一个会话的预览数跟新会话没关系
|
|
383
|
+
recent.length = 0;
|
|
384
|
+
emitted = 0;
|
|
385
|
+
truncated = 0;
|
|
386
|
+
});
|
|
387
|
+
return () => {
|
|
388
|
+
offSection();
|
|
389
|
+
offCommand();
|
|
390
|
+
offGuard();
|
|
391
|
+
};
|
|
392
|
+
},
|
|
393
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git 插件:把「当前工作区的分支 + 改动计数」登记成快照面(`surfaces.git`),并提供
|
|
3
|
+
* `git` 服务(写类 op 落盘后催拍一拍,见 `desktop-dock` 的接线)。
|
|
4
|
+
*
|
|
5
|
+
* ## 为什么这片读数住在宿主
|
|
6
|
+
*
|
|
7
|
+
* 输入框上那颗分支钮(壳 `plugins/composer`)要**一直**显示当前分支,状态面板的
|
|
8
|
+
* 「Git 工具」区也有同一行分支与改动数。界面自己各拉一次 `dock git-status` 的话,同一份
|
|
9
|
+
* 读数就是每个组件一拍;宿主的快照面是「谁要谁来读」的那一处(与 goal / todos / plan
|
|
10
|
+
* 这些面同一套)。
|
|
11
|
+
*
|
|
12
|
+
* 这一片是**轻读**:一条分支名 + 一条 `git status --porcelain -z`(只数条数)。状态面板
|
|
13
|
+
* 那条重读(`stats: true`:还要每文件增删行数、未跟踪文件按内容数行)留在壳里按它自己
|
|
14
|
+
* 更松的节奏走——两处要的东西本来就不同(这里要的是「哪个分支、脏不脏」)。
|
|
15
|
+
*
|
|
16
|
+
* ## 节奏与「没人看就不拍」
|
|
17
|
+
*
|
|
18
|
+
* 拍一拍按三档走(有改动 12s / 干净 30s / 不是仓库 60s),另有事件催拍:回合收工、换会话、
|
|
19
|
+
* 写类 git op 落盘。但**只有界面真的连着时才拍**——快照的 `read()` 只在有人连着界面时发生
|
|
20
|
+
* (`core/ui-events.ts`:没有连接就不造帧),所以「这一片最近被读过」就是「界面活着」的
|
|
21
|
+
* 代理。CLI / TUI 会话里没人看这颗钮,每 12 秒跑一次 `git status` 是纯浪费 CPU。
|
|
22
|
+
*
|
|
23
|
+
* @module dsc/plugins/git
|
|
24
|
+
*/
|
|
25
|
+
import type { Plugin } from '@deepseek-ai/cordis';
|
|
26
|
+
export declare const gitPlugin: Plugin.Object;
|