@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,102 @@
|
|
|
1
|
+
/** 一条候选是从哪条闭环来的。 */
|
|
2
|
+
export type LearningKind = 'correction' | 'failure' | 'note' | 'skill-draft';
|
|
3
|
+
/** 候选的生命周期:只有用户显式 promote / drop 才会离开 candidate。 */
|
|
4
|
+
export type LearningState = 'candidate' | 'promoted' | 'dropped';
|
|
5
|
+
/** 候选清单里的一行(与插件文档里定的形状逐字段一致)。 */
|
|
6
|
+
export interface LearningCandidate {
|
|
7
|
+
id: string;
|
|
8
|
+
ts: number;
|
|
9
|
+
kind: LearningKind;
|
|
10
|
+
/** 正文。`skill-draft` 这一种放的是技能草稿的 JSON 一行。 */
|
|
11
|
+
text: string;
|
|
12
|
+
/** 这条候选来自哪一轮(会话 id 前 8 位 + 第几条用户消息)。 */
|
|
13
|
+
turnRef: string;
|
|
14
|
+
/** 同一句话被重复捕获几次(去重时累加,说明这个纠正反复出现)。 */
|
|
15
|
+
hits: number;
|
|
16
|
+
state: LearningState;
|
|
17
|
+
}
|
|
18
|
+
/** 保留策略(设置分区里可调)。 */
|
|
19
|
+
export interface LearningStoreOptions {
|
|
20
|
+
/** 保留天数:超过就裁掉。 */
|
|
21
|
+
retentionDays: number;
|
|
22
|
+
/** 条数上限:超了先裁最老的。 */
|
|
23
|
+
maxEntries: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_STORE_OPTIONS: LearningStoreOptions;
|
|
26
|
+
/** 会话状态里 `learnings` 那一格的形状。 */
|
|
27
|
+
export interface LearningsState {
|
|
28
|
+
/** 已经复盘过的用户轮次序号(0 起算),重启后读回来,同一轮不重复复盘。 */
|
|
29
|
+
lastReviewedTurn: number;
|
|
30
|
+
/** 本轮是由插件自己发起的(L2 复盘轮、定时任务投递):这种轮次里的写入一律拒。 */
|
|
31
|
+
pluginInitiated: boolean;
|
|
32
|
+
/** 本会话用 `skill` 工具读过的技能名(read-before-write 的记账)。 */
|
|
33
|
+
readSkills: string[];
|
|
34
|
+
/** 本会话由本插件刚创建出来的技能名(刚建的算已读)。 */
|
|
35
|
+
createdSkills: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare const EMPTY_LEARNINGS_STATE: LearningsState;
|
|
38
|
+
/** 从会话记录里读回来的负载可能是手改过的或老版本写的,这里挑出认识的字段。 */
|
|
39
|
+
export declare function normalizeLearningsState(raw: unknown): LearningsState;
|
|
40
|
+
/** 候选目录根(`~/.dsc/learnings`)。 */
|
|
41
|
+
export declare function learningsRoot(): string;
|
|
42
|
+
/**
|
|
43
|
+
* 把工作目录折成一个安全的目录名:可读前缀 + 规范化路径的短哈希。
|
|
44
|
+
*
|
|
45
|
+
* 为什么要哈希:路径里的中文、冒号、空格在 Windows 上都能当目录名,但换到别的机器或
|
|
46
|
+
* 备份工具上就会出乱子;同一目录不同写法(`D:\a\b` 与 `D:/a/b/`)还必须折成同一个键,
|
|
47
|
+
* 所以先 `resolve` 再小写,最后拿哈希兜住「两个不同路径压出同一个前缀」这种撞车。
|
|
48
|
+
*/
|
|
49
|
+
export declare function workspaceKeyOf(cwd: string): string;
|
|
50
|
+
/** 某个工作目录的候选目录。 */
|
|
51
|
+
export declare function workspaceDir(cwd: string): string;
|
|
52
|
+
/** 某个工作目录的候选清单文件。 */
|
|
53
|
+
export declare function candidatesFile(cwd: string): string;
|
|
54
|
+
/** 读候选清单:坏行跳过,同一个 id 以最后一行生效(状态迁移就是靠追加实现的)。 */
|
|
55
|
+
export declare function readCandidates(cwd: string): LearningCandidate[];
|
|
56
|
+
/** 裁剪结果(`removed` 是裁掉的条数)。 */
|
|
57
|
+
export interface PruneResult {
|
|
58
|
+
removed: number;
|
|
59
|
+
kept: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 一次裁剪:先按保留天数裁过期的,再按条数上限裁最老的。
|
|
63
|
+
*
|
|
64
|
+
* 命令与自检都要一个「裁剪后清单」的返回值,所以这里顺带把结果读回来,省一次读盘。
|
|
65
|
+
*/
|
|
66
|
+
export declare function pruneCandidates(cwd: string, options?: Partial<LearningStoreOptions>, now?: number): {
|
|
67
|
+
result: PruneResult;
|
|
68
|
+
candidates: LearningCandidate[];
|
|
69
|
+
};
|
|
70
|
+
/** 新候选的入参。 */
|
|
71
|
+
export interface CandidateInput {
|
|
72
|
+
kind: LearningKind;
|
|
73
|
+
text: string;
|
|
74
|
+
turnRef: string;
|
|
75
|
+
}
|
|
76
|
+
/** 记一条候选的结果。 */
|
|
77
|
+
export interface RecordResult {
|
|
78
|
+
/** 记下来的那条(命中去重时是 hits+1 之后的状态)。 */
|
|
79
|
+
candidate: LearningCandidate | null;
|
|
80
|
+
/** true = 同样内容已经在了,只把 hits 加了一。 */
|
|
81
|
+
deduped: boolean;
|
|
82
|
+
/** 空内容这类不入账的情况,这里说明原因。 */
|
|
83
|
+
error: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 记一条候选。
|
|
87
|
+
*
|
|
88
|
+
* 去重按「同 kind + 同正文」算:用户连着两轮说同一句「不对,用 pnpm 不是 npm」,
|
|
89
|
+
* 该看到的是 hits 从 1 变 2(说明这条纠正戳得深),而不是两条一模一样的候选。
|
|
90
|
+
* 命中去重时只把 hits 加一,不重排时间戳,免得一条老候选因为复现就永远不过期。
|
|
91
|
+
*/
|
|
92
|
+
export declare function recordCandidate(cwd: string, input: CandidateInput, options?: Partial<LearningStoreOptions>, now?: number): RecordResult;
|
|
93
|
+
/** 状态迁移的结果。 */
|
|
94
|
+
export interface StateResult {
|
|
95
|
+
ok: boolean;
|
|
96
|
+
error: string;
|
|
97
|
+
candidate: LearningCandidate | null;
|
|
98
|
+
}
|
|
99
|
+
/** 改一条候选的状态(promote / drop 都走这里,写的是追加一行)。 */
|
|
100
|
+
export declare function setCandidateState(cwd: string, id: string, state: LearningState): StateResult;
|
|
101
|
+
/** 候选清单在会话里的显示文案(命令与工具共用,两处不会写岔)。 */
|
|
102
|
+
export declare function formatCandidate(candidate: LearningCandidate, index?: number): string;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 学习候选清单存储:`~/.dsc/learnings/<workspaceKey>/candidates.jsonl`。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独放一层:L1 的「纠正捕获」是零模型调用的动作,它记下来的东西**绝不进系统提示**
|
|
5
|
+
* ——这是关键安全属性,被纠正的内容里可能夹着用户贴进来的外部文本,直接注入等于给外部
|
|
6
|
+
* 文本开了一条进提示词的路。所以候选清单只是一份带状态的台账,
|
|
7
|
+
* 只有用户显式 `/learnings promote <id>` 才可能变成记忆条目或技能草稿。
|
|
8
|
+
*
|
|
9
|
+
* 为什么用 jsonl 而不是一份整 JSON:状态迁移(candidate → promoted / dropped)写成追加一行,
|
|
10
|
+
* 读取时按 id「最后一条生效」。整份仍然一律 tmp + rename 落盘,所以崩在中间不会留半行;
|
|
11
|
+
* 坏行在读取时跳过,不因为一行坏了就把整份清单读废(用户的台账比行格式的洁癖重要)。
|
|
12
|
+
*
|
|
13
|
+
* 会话记录里那一格自己的状态(`learnings`:已复盘的轮次、本会话读过/建过的技能、「本轮由插件
|
|
14
|
+
* 自己发起」的标记)由 `core/session.ts` 的 {@link SessionStateMap} 声明成 `unknown`——
|
|
15
|
+
* core 层不该认识插件层的类型,依赖方向反过来就成环。所以这里**不做声明合并**:
|
|
16
|
+
* 写回去的是 {@link LearningsState},读回来一律过 {@link normalizeLearningsState} 收口,
|
|
17
|
+
* 两边在类型上各自独立,改这一格不必动内核。
|
|
18
|
+
*
|
|
19
|
+
* @module dsc/core/learnings/store
|
|
20
|
+
*/
|
|
21
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
22
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import { join, resolve } from 'node:path';
|
|
24
|
+
import { dscPath } from '../path-policy.js';
|
|
25
|
+
export const DEFAULT_STORE_OPTIONS = { retentionDays: 30, maxEntries: 200 };
|
|
26
|
+
export const EMPTY_LEARNINGS_STATE = {
|
|
27
|
+
lastReviewedTurn: -1,
|
|
28
|
+
pluginInitiated: false,
|
|
29
|
+
readSkills: [],
|
|
30
|
+
createdSkills: [],
|
|
31
|
+
};
|
|
32
|
+
/** 从会话记录里读回来的负载可能是手改过的或老版本写的,这里挑出认识的字段。 */
|
|
33
|
+
export function normalizeLearningsState(raw) {
|
|
34
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
|
|
35
|
+
return { ...EMPTY_LEARNINGS_STATE };
|
|
36
|
+
const doc = raw;
|
|
37
|
+
const turn = Number(doc.lastReviewedTurn);
|
|
38
|
+
const names = (value) => Array.isArray(value) ? value.filter((item) => typeof item === 'string' && item !== '') : [];
|
|
39
|
+
return {
|
|
40
|
+
lastReviewedTurn: Number.isFinite(turn) ? Math.trunc(turn) : -1,
|
|
41
|
+
pluginInitiated: doc.pluginInitiated === true,
|
|
42
|
+
readSkills: names(doc.readSkills),
|
|
43
|
+
createdSkills: names(doc.createdSkills),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** 候选目录根(`~/.dsc/learnings`)。 */
|
|
47
|
+
export function learningsRoot() {
|
|
48
|
+
return dscPath('learnings');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 把工作目录折成一个安全的目录名:可读前缀 + 规范化路径的短哈希。
|
|
52
|
+
*
|
|
53
|
+
* 为什么要哈希:路径里的中文、冒号、空格在 Windows 上都能当目录名,但换到别的机器或
|
|
54
|
+
* 备份工具上就会出乱子;同一目录不同写法(`D:\a\b` 与 `D:/a/b/`)还必须折成同一个键,
|
|
55
|
+
* 所以先 `resolve` 再小写,最后拿哈希兜住「两个不同路径压出同一个前缀」这种撞车。
|
|
56
|
+
*/
|
|
57
|
+
export function workspaceKeyOf(cwd) {
|
|
58
|
+
const full = resolve(cwd);
|
|
59
|
+
const slug = full
|
|
60
|
+
.replace(/[:\\/_\s]+/g, '-')
|
|
61
|
+
.replace(/^-+|-+$/g, '')
|
|
62
|
+
.toLowerCase()
|
|
63
|
+
.slice(0, 24);
|
|
64
|
+
const stamp = createHash('sha1').update(full.toLowerCase()).digest('hex').slice(0, 8);
|
|
65
|
+
return `${slug === '' ? 'root' : slug}-${stamp}`;
|
|
66
|
+
}
|
|
67
|
+
/** 某个工作目录的候选目录。 */
|
|
68
|
+
export function workspaceDir(cwd) {
|
|
69
|
+
return join(learningsRoot(), workspaceKeyOf(cwd));
|
|
70
|
+
}
|
|
71
|
+
/** 某个工作目录的候选清单文件。 */
|
|
72
|
+
export function candidatesFile(cwd) {
|
|
73
|
+
return join(workspaceDir(cwd), 'candidates.jsonl');
|
|
74
|
+
}
|
|
75
|
+
/** 一行是不是一条合法候选(坏行、手改坏的都在这拦掉)。 */
|
|
76
|
+
function parseCandidate(line) {
|
|
77
|
+
let doc;
|
|
78
|
+
try {
|
|
79
|
+
doc = JSON.parse(line);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (doc === null || typeof doc !== 'object' || Array.isArray(doc))
|
|
85
|
+
return null;
|
|
86
|
+
const raw = doc;
|
|
87
|
+
const id = typeof raw.id === 'string' ? raw.id : '';
|
|
88
|
+
const text = typeof raw.text === 'string' ? raw.text : '';
|
|
89
|
+
const kind = raw.kind;
|
|
90
|
+
const state = raw.state;
|
|
91
|
+
if (id === '' || text === '')
|
|
92
|
+
return null;
|
|
93
|
+
if (kind !== 'correction' && kind !== 'failure' && kind !== 'note' && kind !== 'skill-draft')
|
|
94
|
+
return null;
|
|
95
|
+
if (state !== 'candidate' && state !== 'promoted' && state !== 'dropped')
|
|
96
|
+
return null;
|
|
97
|
+
const ts = Number(raw.ts);
|
|
98
|
+
const hits = Number(raw.hits);
|
|
99
|
+
return {
|
|
100
|
+
id,
|
|
101
|
+
ts: Number.isFinite(ts) ? Math.trunc(ts) : 0,
|
|
102
|
+
kind,
|
|
103
|
+
text,
|
|
104
|
+
turnRef: typeof raw.turnRef === 'string' ? raw.turnRef : '',
|
|
105
|
+
hits: Number.isFinite(hits) && hits >= 0 ? Math.trunc(hits) : 0,
|
|
106
|
+
state,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** 读候选清单:坏行跳过,同一个 id 以最后一行生效(状态迁移就是靠追加实现的)。 */
|
|
110
|
+
export function readCandidates(cwd) {
|
|
111
|
+
const file = candidatesFile(cwd);
|
|
112
|
+
if (!existsSync(file))
|
|
113
|
+
return [];
|
|
114
|
+
let text = '';
|
|
115
|
+
try {
|
|
116
|
+
text = readFileSync(file, 'utf8');
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const byId = new Map();
|
|
122
|
+
const order = [];
|
|
123
|
+
for (const line of text.split(/\r?\n/)) {
|
|
124
|
+
if (line.trim() === '')
|
|
125
|
+
continue;
|
|
126
|
+
const parsed = parseCandidate(line);
|
|
127
|
+
if (parsed === null)
|
|
128
|
+
continue;
|
|
129
|
+
if (!byId.has(parsed.id))
|
|
130
|
+
order.push(parsed.id);
|
|
131
|
+
byId.set(parsed.id, parsed);
|
|
132
|
+
}
|
|
133
|
+
return order.map((id) => byId.get(id)).filter((item) => item !== undefined);
|
|
134
|
+
}
|
|
135
|
+
/** 原子追加若干行:整份读出来 + 追加 + 写临时文件 + rename,不产生半行。 */
|
|
136
|
+
function appendLines(cwd, records) {
|
|
137
|
+
const dir = workspaceDir(cwd);
|
|
138
|
+
const file = candidatesFile(cwd);
|
|
139
|
+
mkdirSync(dir, { recursive: true });
|
|
140
|
+
const existing = existsSync(file) ? readFileSync(file, 'utf8') : '';
|
|
141
|
+
const head = existing === '' || existing.endsWith('\n') ? existing : `${existing}\n`;
|
|
142
|
+
const body = records.map((record) => `${JSON.stringify(record)}\n`).join('');
|
|
143
|
+
const tmp = `${file}.tmp`;
|
|
144
|
+
writeFileSync(tmp, head + body, 'utf8');
|
|
145
|
+
try {
|
|
146
|
+
renameSync(tmp, file);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
// rename 不成就把临时文件收拾掉,别在用户目录里留垃圾
|
|
150
|
+
try {
|
|
151
|
+
unlinkSync(tmp);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// 临时文件本来就没了:忽略
|
|
155
|
+
}
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function optionsOf(options) {
|
|
160
|
+
const days = Number(options?.retentionDays ?? DEFAULT_STORE_OPTIONS.retentionDays);
|
|
161
|
+
const max = Number(options?.maxEntries ?? DEFAULT_STORE_OPTIONS.maxEntries);
|
|
162
|
+
return {
|
|
163
|
+
// 0 天保留等于「记完就扔」,没有意义;上限至少留 1 条
|
|
164
|
+
retentionDays: Number.isFinite(days) ? Math.max(1, Math.trunc(days)) : DEFAULT_STORE_OPTIONS.retentionDays,
|
|
165
|
+
maxEntries: Number.isFinite(max) ? Math.max(1, Math.trunc(max)) : DEFAULT_STORE_OPTIONS.maxEntries,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 一次裁剪:先按保留天数裁过期的,再按条数上限裁最老的。
|
|
170
|
+
*
|
|
171
|
+
* 命令与自检都要一个「裁剪后清单」的返回值,所以这里顺带把结果读回来,省一次读盘。
|
|
172
|
+
*/
|
|
173
|
+
export function pruneCandidates(cwd, options, now = Date.now()) {
|
|
174
|
+
const opts = optionsOf(options);
|
|
175
|
+
const all = readCandidates(cwd);
|
|
176
|
+
const deadline = now - opts.retentionDays * 24 * 60 * 60 * 1000;
|
|
177
|
+
let kept = all.filter((item) => item.ts >= deadline);
|
|
178
|
+
if (kept.length > opts.maxEntries) {
|
|
179
|
+
// 新的在前;同一毫秒按 id 稳定排序,免得两次裁剪结果不一样
|
|
180
|
+
const sorted = [...kept].sort((a, b) => (b.ts === a.ts ? a.id.localeCompare(b.id) : b.ts - a.ts));
|
|
181
|
+
kept = sorted.slice(0, opts.maxEntries);
|
|
182
|
+
}
|
|
183
|
+
const removed = all.length - kept.length;
|
|
184
|
+
if (removed > 0)
|
|
185
|
+
writeAll(cwd, kept);
|
|
186
|
+
return { result: { removed, kept: kept.length }, candidates: kept };
|
|
187
|
+
}
|
|
188
|
+
/** 整份覆盖写(裁剪用):仍然 tmp + rename。 */
|
|
189
|
+
function writeAll(cwd, records) {
|
|
190
|
+
const file = candidatesFile(cwd);
|
|
191
|
+
mkdirSync(workspaceDir(cwd), { recursive: true });
|
|
192
|
+
const tmp = `${file}.tmp`;
|
|
193
|
+
writeFileSync(tmp, records.map((record) => `${JSON.stringify(record)}\n`).join(''), 'utf8');
|
|
194
|
+
try {
|
|
195
|
+
renameSync(tmp, file);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
try {
|
|
199
|
+
unlinkSync(tmp);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// 同上:临时文件已经不在了
|
|
203
|
+
}
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** 新的短 id:8 位十六进制,够 `/learnings promote <id>` 手打,也不至于跟已有的撞。 */
|
|
208
|
+
function newId(existing) {
|
|
209
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
210
|
+
const id = randomUUID().replace(/-/g, '').slice(0, 8);
|
|
211
|
+
if (!existing.has(id))
|
|
212
|
+
return id;
|
|
213
|
+
}
|
|
214
|
+
return randomUUID().replace(/-/g, '').slice(0, 12);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 记一条候选。
|
|
218
|
+
*
|
|
219
|
+
* 去重按「同 kind + 同正文」算:用户连着两轮说同一句「不对,用 pnpm 不是 npm」,
|
|
220
|
+
* 该看到的是 hits 从 1 变 2(说明这条纠正戳得深),而不是两条一模一样的候选。
|
|
221
|
+
* 命中去重时只把 hits 加一,不重排时间戳,免得一条老候选因为复现就永远不过期。
|
|
222
|
+
*/
|
|
223
|
+
export function recordCandidate(cwd, input, options, now = Date.now()) {
|
|
224
|
+
const text = input.text.replace(/\s+/g, ' ').trim();
|
|
225
|
+
if (text === '')
|
|
226
|
+
return { candidate: null, deduped: false, error: '候选正文是空的,没什么可记' };
|
|
227
|
+
const clipped = text.length > 2000 ? `${text.slice(0, 2000)}…` : text;
|
|
228
|
+
const candidates = readCandidates(cwd);
|
|
229
|
+
const existing = candidates.find((item) => item.kind === input.kind && item.text === clipped && item.state === 'candidate');
|
|
230
|
+
if (existing !== undefined) {
|
|
231
|
+
const bumped = { ...existing, hits: existing.hits + 1 };
|
|
232
|
+
appendLines(cwd, [bumped]);
|
|
233
|
+
return { candidate: bumped, deduped: true, error: '' };
|
|
234
|
+
}
|
|
235
|
+
const candidate = {
|
|
236
|
+
id: newId(new Set(candidates.map((item) => item.id))),
|
|
237
|
+
ts: now,
|
|
238
|
+
kind: input.kind,
|
|
239
|
+
text: clipped,
|
|
240
|
+
turnRef: input.turnRef,
|
|
241
|
+
hits: 0,
|
|
242
|
+
state: 'candidate',
|
|
243
|
+
};
|
|
244
|
+
appendLines(cwd, [candidate]);
|
|
245
|
+
pruneCandidates(cwd, options, now);
|
|
246
|
+
return { candidate, deduped: false, error: '' };
|
|
247
|
+
}
|
|
248
|
+
/** 改一条候选的状态(promote / drop 都走这里,写的是追加一行)。 */
|
|
249
|
+
export function setCandidateState(cwd, id, state) {
|
|
250
|
+
const candidates = readCandidates(cwd);
|
|
251
|
+
const found = candidates.find((item) => item.id === id);
|
|
252
|
+
if (found === undefined)
|
|
253
|
+
return { ok: false, error: `没有 id 为 ${id} 的候选(/learnings list 看清单)`, candidate: null };
|
|
254
|
+
if (found.state === state)
|
|
255
|
+
return { ok: true, error: '', candidate: found };
|
|
256
|
+
const next = { ...found, state };
|
|
257
|
+
appendLines(cwd, [next]);
|
|
258
|
+
return { ok: true, error: '', candidate: next };
|
|
259
|
+
}
|
|
260
|
+
/** 候选清单在会话里的显示文案(命令与工具共用,两处不会写岔)。 */
|
|
261
|
+
export function formatCandidate(candidate, index) {
|
|
262
|
+
const head = candidate.text.replace(/\s+/g, ' ').slice(0, 58);
|
|
263
|
+
const more = candidate.text.length > 58 ? '…' : '';
|
|
264
|
+
const serial = index === undefined ? '' : `#${String(index + 1).padStart(2, '0')} `;
|
|
265
|
+
return `${serial}[${candidate.id}] ${candidate.kind} · ${candidate.state} · 命中${String(candidate.hits)} · ${head}${more}`;
|
|
266
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { HookJudgement, HookRun } from './hooks.js';
|
|
2
|
+
/**
|
|
3
|
+
* codex 的十二个生命周期事件名,照抄 `codex/codex-rs/hooks/src/lib.rs:23-36`。
|
|
4
|
+
* 名字保持 codex 原样(大驼峰),用户手上的 hooks.json 不用改一个字。
|
|
5
|
+
*/
|
|
6
|
+
export declare const LIFECYCLE_EVENTS: readonly ["PreToolUse", "PermissionRequest", "PostToolUse", "PreCompact", "PostCompact", "SessionStart", "SessionEnd", "UserPromptSubmit", "SubagentStart", "SubagentStop", "Stop", "Interrupt"];
|
|
7
|
+
export type LifecycleEvent = (typeof LIFECYCLE_EVENTS)[number];
|
|
8
|
+
/** 接通档位:wired = 完整接通;partial = 接上了但做不到 codex 的全部能力;unwired = 没有扩展点,不执行。 */
|
|
9
|
+
export type LifecycleTier = 'wired' | 'partial' | 'unwired';
|
|
10
|
+
/** 一个事件的能力声明:接到哪、什么档、为什么。 */
|
|
11
|
+
export interface LifecycleCapability {
|
|
12
|
+
event: LifecycleEvent;
|
|
13
|
+
tier: LifecycleTier;
|
|
14
|
+
/** 用的内核扩展点;`unwired` 写「无」。 */
|
|
15
|
+
extension: string;
|
|
16
|
+
/** 接法或限度(`unwired` 就是不能接通的理由,会原样进 problems)。 */
|
|
17
|
+
note: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 能力清单(显式声明,别让用户猜哪些事件真的会跑)。
|
|
21
|
+
* 档位是按 dsc 现有扩展点核实过的,改扩展点就要连带改这张表。
|
|
22
|
+
*/
|
|
23
|
+
export declare const LIFECYCLE_CAPABILITIES: readonly LifecycleCapability[];
|
|
24
|
+
/**
|
|
25
|
+
* matcher 字段拿什么去比:只有这三个事件在 dsc 里有比对对象。
|
|
26
|
+
* 其余事件的 matcher 会被忽略(配了也会记一条 problems,不静默吞掉)。
|
|
27
|
+
*/
|
|
28
|
+
export declare const LIFECYCLE_MATCHER_EVENTS: readonly LifecycleEvent[];
|
|
29
|
+
/** 这个事件支持 matcher 比对(不支持时 matcher 字段被忽略)。 */
|
|
30
|
+
export declare function matcherSupported(event: LifecycleEvent): boolean;
|
|
31
|
+
/** 钩子条数上限、命令与 matcher 的字数上限。 */
|
|
32
|
+
export declare const LIFECYCLE_MAX_HOOKS = 50;
|
|
33
|
+
export declare const LIFECYCLE_COMMAND_MAX = 1000;
|
|
34
|
+
export declare const LIFECYCLE_MATCHER_MAX = 120;
|
|
35
|
+
/**
|
|
36
|
+
* 插件可调值。存 `~/.dsc/plugins.json` 的条目 config 里,设置分区保存后立刻生效,
|
|
37
|
+
* 因为每次用值都现调 {@link resolveLifecycleConfig}。
|
|
38
|
+
*/
|
|
39
|
+
export interface LifecycleHooksConfig {
|
|
40
|
+
/** 总开关:关掉之后一个钩子都不跑(配置留着,随时开回来)。 */
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
/** codex 风格钩子配置文件的绝对路径(`~` 开头会展开成用户目录)。 */
|
|
43
|
+
configPath: string;
|
|
44
|
+
/** 钩子自己没写超时时给多少毫秒。 */
|
|
45
|
+
timeoutMs: number;
|
|
46
|
+
/** 钩子没跑成(超时、命令起不来、输出看不懂、退出码非 0)时按拒处理;false 才转放行。 */
|
|
47
|
+
failClosed: boolean;
|
|
48
|
+
/** 命令白名单:逗号或空格分隔的入口(例如 `node, uv`);空串 = 不限制。 */
|
|
49
|
+
commandAllowlist: string;
|
|
50
|
+
}
|
|
51
|
+
/** 缺省值。放着让用户改,不是硬编码的裁决。 */
|
|
52
|
+
export declare const LIFECYCLE_DEFAULTS: LifecycleHooksConfig;
|
|
53
|
+
/**
|
|
54
|
+
* 取这个插件此刻该用的配置:装配时传进来的那份作底,`~/.dsc/plugins.json` 上那份覆盖它。
|
|
55
|
+
* 每次用值都现调,所以设置里改完不必重启宿主。
|
|
56
|
+
*
|
|
57
|
+
* @param passed - 插件 `apply(ctx, passed)` 的第二参数;不是对象就当没给。
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveLifecycleConfig(passed?: unknown): LifecycleHooksConfig;
|
|
60
|
+
/** 一条外部命令钩子。 */
|
|
61
|
+
export interface LifecycleHook {
|
|
62
|
+
id: string;
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
event: LifecycleEvent;
|
|
65
|
+
/** 工具名(PreToolUse / PostToolUse)或来源(SessionStart)的匹配式;`*` 或空 = 全中。 */
|
|
66
|
+
matcher: string;
|
|
67
|
+
/** 交给 shell 执行的命令原文。 */
|
|
68
|
+
command: string;
|
|
69
|
+
/** 这一条的超时(毫秒);0 = 用配置里的全局缺省。 */
|
|
70
|
+
timeoutMs: number;
|
|
71
|
+
/** 这一条没跑成时是否按拒处理;undefined = 跟配置里的全局开关走。 */
|
|
72
|
+
failClosed: boolean | undefined;
|
|
73
|
+
}
|
|
74
|
+
/** 读一份配置的结果:能跑的钩子 + 读的时候发现的毛病。 */
|
|
75
|
+
export interface LifecycleDoc {
|
|
76
|
+
hooks: LifecycleHook[];
|
|
77
|
+
problems: string[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 把磁盘上的内容按 codex 的形态读成钩子表。
|
|
81
|
+
*
|
|
82
|
+
* 认两种外形:`{ hooks: { PreToolUse: [...] } }`(codex 的包装形态)与直接的事件表
|
|
83
|
+
* `{ PreToolUse: [...] }`。每个事件下是一组 `{ matcher, hooks: [{ type, command, timeout }] }`;
|
|
84
|
+
* 只跑同步的 `command` 钩子,`type` 不是 command 或写了 `async: true` 的照样列进 problems
|
|
85
|
+
* 而不是悄悄丢掉。`timeout` 与 `timeoutSec` 都按**秒**读(codex 的约定),0 或没写 = 用全局缺省。
|
|
86
|
+
*
|
|
87
|
+
* @param configPath - 配置文件路径。
|
|
88
|
+
*/
|
|
89
|
+
export declare function readLifecycleDoc(configPath: string): LifecycleDoc;
|
|
90
|
+
/** 给人看的报告:能力清单 + 配置里的钩子 + 毛病。 */
|
|
91
|
+
export interface LifecycleReport {
|
|
92
|
+
capabilities: readonly LifecycleCapability[];
|
|
93
|
+
hooks: LifecycleHook[];
|
|
94
|
+
problems: string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 把配置、能力表与配置里的毛病拼成一份给人看的报告。
|
|
98
|
+
* `/lifecycle-hooks` 命令、设置分区与自检读的都是这一份,三处不会各说各话。
|
|
99
|
+
*
|
|
100
|
+
* @param configPath - 钩子配置文件路径。
|
|
101
|
+
*/
|
|
102
|
+
export declare function lifecycleReport(configPath: string): LifecycleReport;
|
|
103
|
+
/**
|
|
104
|
+
* 命令是否被白名单放行。
|
|
105
|
+
*
|
|
106
|
+
* 按**入口词**比:白名单里的 `node` 放行 `node guard.js --strict`,但不放行 `nodejs-evil`;
|
|
107
|
+
* 词与后面之间必须是空格、斜杠或行尾。白名单是空串时一律放行(不限制)。
|
|
108
|
+
*
|
|
109
|
+
* @param command - 钩子要跑的命令原文。
|
|
110
|
+
* @param allowlist - 逗号或空格分隔的入口清单。
|
|
111
|
+
*/
|
|
112
|
+
export declare function commandAllowed(command: string, allowlist: string): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* 递给钩子脚本 stdin 的载荷。
|
|
115
|
+
*
|
|
116
|
+
* 字段名照 codex:公共字段每条都有,其余按事件补。三条与 codex 的差别是知道的、写在这:
|
|
117
|
+
* 会话文件路径 dsc 的 `Session` 上取不到,`transcript_path` 恒为 `null`;
|
|
118
|
+
* dsc 没有回合计数器,所以不发 `turn_id`(钩子脚本读它是 undefined,不是 0 也不是空串);
|
|
119
|
+
* `stop_hook_active` 恒为 `false`(dsc 没有 codex 那个「这轮已经是钩子推起来的」标记)。
|
|
120
|
+
*/
|
|
121
|
+
export interface LifecyclePayload {
|
|
122
|
+
session_id: string;
|
|
123
|
+
transcript_path: null;
|
|
124
|
+
cwd: string;
|
|
125
|
+
hook_event_name: LifecycleEvent;
|
|
126
|
+
model: string;
|
|
127
|
+
permission_mode: string;
|
|
128
|
+
tool_name?: string;
|
|
129
|
+
tool_input?: Record<string, unknown>;
|
|
130
|
+
tool_response?: string;
|
|
131
|
+
prompt?: string;
|
|
132
|
+
source?: string;
|
|
133
|
+
reason?: string;
|
|
134
|
+
stop_hook_active?: boolean;
|
|
135
|
+
last_assistant_message?: string | null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 跑一条钩子命令。
|
|
139
|
+
*
|
|
140
|
+
* 命令交给 shell 执行(`cmd.exe /c` 或 `sh -c`),带参数、带管道都能照原样写。
|
|
141
|
+
* 子进程环境剥掉凭据(与 bash 工具同一套 `scrubChildEnv`),载荷从 stdin 进去、
|
|
142
|
+
* **不发结尾换行**(codex 就是这么发的,照着来才不至于让现成脚本按行读多读一条空行)。
|
|
143
|
+
* 到点没结束就 SIGKILL,Windows 上连整棵进程树一起点名杀,否则 `cmd.exe` 死了、
|
|
144
|
+
* 它启的脚本还占着管道,一个已经判死的钩子能再拖好几秒。
|
|
145
|
+
*
|
|
146
|
+
* 不抛错:脚本怎么坏都体现在返回值里,交给 {@link judgeLifecycleRun} 去定失败方向。
|
|
147
|
+
*
|
|
148
|
+
* @param command - 命令原文。
|
|
149
|
+
* @param timeoutMs - 这次给多少毫秒;会被夹进 `HOOK_TIMEOUT_MIN`~`HOOK_TIMEOUT_MAX`。
|
|
150
|
+
* @param payload - 递给 stdin 的载荷。
|
|
151
|
+
* @param cwd - 工作目录(会话目录,不是 dsc 自己的目录)。
|
|
152
|
+
* @param signal - 取消信号:用户打断或插件卸载时杀掉脚本。
|
|
153
|
+
*/
|
|
154
|
+
export declare function runLifecycleCommand(command: string, timeoutMs: number, payload: LifecyclePayload, cwd: string, signal: AbortSignal): Promise<HookRun>;
|
|
155
|
+
/** 这一条钩子的失败方向:自己写了就听自己的,没写跟全局开关走。 */
|
|
156
|
+
export declare function failClosedOf(hook: LifecycleHook, config: LifecycleHooksConfig): boolean;
|
|
157
|
+
/** 钩子在提示里显示成什么样(命令太长就截断)。 */
|
|
158
|
+
export declare function hookLabel(hook: LifecycleHook): string;
|
|
159
|
+
/**
|
|
160
|
+
* 把一次执行结果折成裁决。
|
|
161
|
+
*
|
|
162
|
+
* @param run - {@link runLifecycleCommand} 的返回值。
|
|
163
|
+
* @param hook - 跑的那条钩子。
|
|
164
|
+
* @param config - 当前配置(决定失败方向与缺省超时)。
|
|
165
|
+
*/
|
|
166
|
+
export declare function judgeLifecycleRun(run: HookRun, hook: LifecycleHook, config: LifecycleHooksConfig): HookJudgement;
|
|
167
|
+
/**
|
|
168
|
+
* 命令被白名单挡下时的裁决:钩子本该守在门口却没跑成,所以按失败方向处理。
|
|
169
|
+
*
|
|
170
|
+
* @param hook - 被挡下的那条钩子。
|
|
171
|
+
* @param config - 当前配置(白名单与失败方向都从这儿来)。
|
|
172
|
+
*/
|
|
173
|
+
export declare function judgeBlockedByAllowlist(hook: LifecycleHook, config: LifecycleHooksConfig): HookJudgement;
|
|
174
|
+
/**
|
|
175
|
+
* 钩子说的话进模型之前包一层围栏,来源写 `hook:<事件名>`。
|
|
176
|
+
*
|
|
177
|
+
* @param event - 哪条事件的话。
|
|
178
|
+
* @param text - 钩子脚本给的原文。
|
|
179
|
+
*/
|
|
180
|
+
export declare function wrapHookOutput(event: LifecycleEvent, text: string): string;
|
|
181
|
+
/**
|
|
182
|
+
* 拼出回给模型的那句话:被拦下时模型得知道是谁拦的、为什么,以及别重试。
|
|
183
|
+
*
|
|
184
|
+
* @param event - 哪条事件拦下的。
|
|
185
|
+
* @param judgement - 裁决(`message` 是钩子给的原因)。
|
|
186
|
+
*/
|
|
187
|
+
export declare function denyReasonFor(event: LifecycleEvent, judgement: HookJudgement): string;
|
|
188
|
+
/** 事件上的 matcher 是否命中这次的主题(工具名 / 会话来源)。 */
|
|
189
|
+
export declare function subjectHits(event: LifecycleEvent, matcher: string, subject: string): boolean;
|