@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,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 技能变更台账:`~/.dsc/skills/.ledger.jsonl`(每次技能落盘都追加一行,回滚靠它查)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有一份台账:技能是会被「下一次的我」当成操作手册照做的文件,改错了不会当场报错,
|
|
5
|
+
* 而是在几天后的一次执行里出事。所以每次变更都留一条「谁、什么时候、动了哪个技能、
|
|
6
|
+
* 改前改后的内容指纹、原文件的副本在哪」,用户 `/skills-ledger rollback <id>` 就能退回去。
|
|
7
|
+
*
|
|
8
|
+
* 三条设计上的取舍:
|
|
9
|
+
* 1. **台账本身不是闸门**:写台账失败不影响这次写入(日志级问题不该让功能瘫掉),
|
|
10
|
+
* 但 `rollbackEntry` 反过来——它拿不到副本就明确报错,不许「假装回滚成功」。
|
|
11
|
+
* 2. 指纹用 sha256 前 16 位:人要在 `/skills-ledger` 里看得懂,128 位已经足够拦住
|
|
12
|
+
* 「文件被外面改过」这一类误判。
|
|
13
|
+
* 3. 回滚本身也记一条台账。回滚不是「撤销历史」,而是又一次变更,历史链条不能断。
|
|
14
|
+
*
|
|
15
|
+
* @module dsc/core/learnings/ledger
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import { basename, dirname, join } from 'node:path';
|
|
20
|
+
import { archiveRoot, skillsRoot, SKILL_FILE } from './skill-write.js';
|
|
21
|
+
/** 空内容的指纹:技能「本来不存在」与「存在但为空」在台账里必须能分开看。 */
|
|
22
|
+
export const EMPTY_HASH = hashText('');
|
|
23
|
+
/** 内容指纹:sha256 前 16 位。 */
|
|
24
|
+
export function hashText(text) {
|
|
25
|
+
return createHash('sha256').update(text, 'utf8').digest('hex').slice(0, 16);
|
|
26
|
+
}
|
|
27
|
+
/** 文件指纹;文件不存在返回 {@link EMPTY_HASH}。 */
|
|
28
|
+
export function hashFileOf(file) {
|
|
29
|
+
try {
|
|
30
|
+
return existsSync(file) ? hashText(readFileSync(file, 'utf8')) : EMPTY_HASH;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return EMPTY_HASH;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** 台账文件路径。 */
|
|
37
|
+
export function ledgerFile() {
|
|
38
|
+
return join(skillsRoot(), '.ledger.jsonl');
|
|
39
|
+
}
|
|
40
|
+
/** 某条台账对应的原文件副本路径(技能目录里,与 SKILL.md 同级)。 */
|
|
41
|
+
export function backupPathOf(entry) {
|
|
42
|
+
if (entry.backup === undefined || entry.backup === '')
|
|
43
|
+
return null;
|
|
44
|
+
return join(skillsRoot(), entry.skill, basename(entry.backup));
|
|
45
|
+
}
|
|
46
|
+
/** 短 id:8 位十六进制,够手打。 */
|
|
47
|
+
function newLedgerId() {
|
|
48
|
+
return createHash('sha1').update(`${String(Date.now())}:${Math.random()}`).digest('hex').slice(0, 8);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 追加一条台账。
|
|
52
|
+
*
|
|
53
|
+
* 用「读全文 + 追加 + tmp + rename」而不是 `appendFileSync`:这个文件同时被回滚与设置页读,
|
|
54
|
+
* 追加写只保证一行不撕裂,不保证读的人看到的是完整行;整份重写的代价在几百行的量级完全不值一提。
|
|
55
|
+
* 写失败直接抛给调用方——调用方(skill-write)会把它当成 `notice` 里的提醒而不是拒绝理由。
|
|
56
|
+
*/
|
|
57
|
+
export function appendLedger(entry) {
|
|
58
|
+
const file = ledgerFile();
|
|
59
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
60
|
+
const record = {
|
|
61
|
+
id: entry.id ?? newLedgerId(),
|
|
62
|
+
ts: entry.ts ?? Date.now(),
|
|
63
|
+
actor: entry.actor,
|
|
64
|
+
action: entry.action,
|
|
65
|
+
skill: entry.skill,
|
|
66
|
+
beforeHash: entry.beforeHash,
|
|
67
|
+
afterHash: entry.afterHash,
|
|
68
|
+
...(entry.backup === undefined ? {} : { backup: entry.backup }),
|
|
69
|
+
...(entry.note === undefined ? {} : { note: entry.note }),
|
|
70
|
+
};
|
|
71
|
+
const existing = existsSync(file) ? readFileSync(file, 'utf8') : '';
|
|
72
|
+
const head = existing === '' || existing.endsWith('\n') ? existing : `${existing}\n`;
|
|
73
|
+
const tmp = `${file}.tmp`;
|
|
74
|
+
writeFileSync(tmp, `${head}${JSON.stringify(record)}\n`, 'utf8');
|
|
75
|
+
try {
|
|
76
|
+
renameSync(tmp, file);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
try {
|
|
80
|
+
unlinkSync(tmp);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// 临时文件已经不在了:忽略
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
return record;
|
|
88
|
+
}
|
|
89
|
+
function parseEntry(line) {
|
|
90
|
+
let doc;
|
|
91
|
+
try {
|
|
92
|
+
doc = JSON.parse(line);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
if (doc === null || typeof doc !== 'object' || Array.isArray(doc))
|
|
98
|
+
return null;
|
|
99
|
+
const raw = doc;
|
|
100
|
+
const actions = ['create', 'patch', 'write_file', 'archive', 'rollback'];
|
|
101
|
+
const id = typeof raw.id === 'string' ? raw.id : '';
|
|
102
|
+
const skill = typeof raw.skill === 'string' ? raw.skill : '';
|
|
103
|
+
const action = raw.action;
|
|
104
|
+
if (id === '' || skill === '' || typeof action !== 'string' || !actions.includes(action))
|
|
105
|
+
return null;
|
|
106
|
+
const ts = Number(raw.ts);
|
|
107
|
+
return {
|
|
108
|
+
id,
|
|
109
|
+
ts: Number.isFinite(ts) ? Math.trunc(ts) : 0,
|
|
110
|
+
actor: raw.actor === 'model' ? 'model' : 'user',
|
|
111
|
+
action: action,
|
|
112
|
+
skill,
|
|
113
|
+
beforeHash: typeof raw.beforeHash === 'string' ? raw.beforeHash : '',
|
|
114
|
+
afterHash: typeof raw.afterHash === 'string' ? raw.afterHash : '',
|
|
115
|
+
...(typeof raw.backup === 'string' && raw.backup !== '' ? { backup: raw.backup } : {}),
|
|
116
|
+
...(typeof raw.note === 'string' && raw.note !== '' ? { note: raw.note } : {}),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** 读台账,新的在前;坏行跳过。`limit` 只取最近若干条。 */
|
|
120
|
+
export function readLedger(limit) {
|
|
121
|
+
const file = ledgerFile();
|
|
122
|
+
if (!existsSync(file))
|
|
123
|
+
return [];
|
|
124
|
+
let text = '';
|
|
125
|
+
try {
|
|
126
|
+
text = readFileSync(file, 'utf8');
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
const out = [];
|
|
132
|
+
for (const line of text.split(/\r?\n/)) {
|
|
133
|
+
if (line.trim() === '')
|
|
134
|
+
continue;
|
|
135
|
+
const parsed = parseEntry(line);
|
|
136
|
+
if (parsed !== null)
|
|
137
|
+
out.push(parsed);
|
|
138
|
+
}
|
|
139
|
+
out.sort((a, b) => b.ts - a.ts);
|
|
140
|
+
const trimmed = limit === undefined || limit <= 0 ? out : out.slice(0, limit);
|
|
141
|
+
return trimmed;
|
|
142
|
+
}
|
|
143
|
+
/** 按 id 找一条。 */
|
|
144
|
+
export function findLedgerEntry(id) {
|
|
145
|
+
return readLedger().find((entry) => entry.id === id);
|
|
146
|
+
}
|
|
147
|
+
/** 台账里某个技能最新的一条非回滚变更(self-improve 自检探针钉住;插件侧暂无调用方)。 */
|
|
148
|
+
export function lastChangeOf(skill) {
|
|
149
|
+
return readLedger().find((entry) => entry.skill === skill && entry.action !== 'rollback');
|
|
150
|
+
}
|
|
151
|
+
/** 台账一行在命令里的显示文案。 */
|
|
152
|
+
export function formatLedgerEntry(entry) {
|
|
153
|
+
const when = new Date(entry.ts).toLocaleString('zh-CN', { hour12: false });
|
|
154
|
+
const backup = entry.backup === undefined ? '' : ` · 副本 ${entry.backup}`;
|
|
155
|
+
return `[${entry.id}] ${when} · ${entry.actor} · ${entry.action} · ${entry.skill} · ${entry.beforeHash}→${entry.afterHash}${backup}${entry.note === undefined ? '' : ` · ${entry.note}`}`;
|
|
156
|
+
}
|
|
157
|
+
/** 原子写一个文本文件(tmp + rename):回滚恢复也用这条路径,保证不会写出一份半截文件。 */
|
|
158
|
+
function atomicWriteText(file, text) {
|
|
159
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
160
|
+
const tmp = `${file}.tmp`;
|
|
161
|
+
writeFileSync(tmp, text, 'utf8');
|
|
162
|
+
try {
|
|
163
|
+
renameSync(tmp, file);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
try {
|
|
167
|
+
unlinkSync(tmp);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// 忽略
|
|
171
|
+
}
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 回滚一条变更:把 SKILL.md 恢复成那条变更改之前的内容。
|
|
177
|
+
*
|
|
178
|
+
* 三种情况分开处理:
|
|
179
|
+
* - 台账里记了副本(patch / write_file)→ 用副本内容盖回去,写完核对指纹对不对;
|
|
180
|
+
* - `create` 且没有副本(文件本来不存在)→ 把整个技能目录搬进 `.archive/`,**绝不删**;
|
|
181
|
+
* - 其余(副本丢了、动作没有可恢复的语义)→ 明确报错,不许假装成功。
|
|
182
|
+
*
|
|
183
|
+
* @param id - 台账 id。
|
|
184
|
+
* @param now - 回滚那条台账的时间戳(自检要造历史时用)。
|
|
185
|
+
*/
|
|
186
|
+
export function rollbackEntry(id, now = Date.now()) {
|
|
187
|
+
const entry = findLedgerEntry(id);
|
|
188
|
+
if (entry === undefined)
|
|
189
|
+
return { ok: false, error: `台账里没有 id 为 ${id} 的记录(/skills-ledger 看清单)`, notice: '' };
|
|
190
|
+
const skillMd = join(skillsRoot(), entry.skill, SKILL_FILE);
|
|
191
|
+
const currentHash = hashFileOf(skillMd);
|
|
192
|
+
const backup = backupPathOf(entry);
|
|
193
|
+
if (backup !== null && existsSync(backup)) {
|
|
194
|
+
let original = '';
|
|
195
|
+
try {
|
|
196
|
+
original = readFileSync(backup, 'utf8');
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return { ok: false, error: `副本读不出来:${error instanceof Error ? error.message : String(error)}`, notice: '' };
|
|
200
|
+
}
|
|
201
|
+
if (hashText(original) !== entry.beforeHash) {
|
|
202
|
+
return { ok: false, error: `副本内容与台账记的改前指纹对不上(${hashText(original)} ≠ ${entry.beforeHash}),这次不回滚`, notice: '' };
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
atomicWriteText(skillMd, original);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
return { ok: false, error: `恢复失败:${error instanceof Error ? error.message : String(error)}`, notice: '' };
|
|
209
|
+
}
|
|
210
|
+
appendLedger({
|
|
211
|
+
actor: 'user',
|
|
212
|
+
action: 'rollback',
|
|
213
|
+
skill: entry.skill,
|
|
214
|
+
beforeHash: currentHash,
|
|
215
|
+
afterHash: entry.beforeHash,
|
|
216
|
+
backup: basename(backup),
|
|
217
|
+
note: `回滚 ${entry.id}(${entry.action})`,
|
|
218
|
+
ts: now,
|
|
219
|
+
});
|
|
220
|
+
return { ok: true, error: '', notice: `已把 ${entry.skill}/SKILL.md 还原成 ${entry.id} 之前的内容(${entry.beforeHash})` };
|
|
221
|
+
}
|
|
222
|
+
if (entry.action === 'create' && entry.beforeHash === EMPTY_HASH) {
|
|
223
|
+
const dir = join(skillsRoot(), entry.skill);
|
|
224
|
+
if (!existsSync(dir))
|
|
225
|
+
return { ok: false, error: `技能 ${entry.skill} 已经不在了,没什么可回滚`, notice: '' };
|
|
226
|
+
const target = join(archiveRoot(), `${entry.skill}-${String(Math.floor(now / 1000))}-rollback`);
|
|
227
|
+
try {
|
|
228
|
+
mkdirSync(archiveRoot(), { recursive: true });
|
|
229
|
+
renameSync(dir, target);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
return { ok: false, error: `搬进归档区失败:${error instanceof Error ? error.message : String(error)}`, notice: '' };
|
|
233
|
+
}
|
|
234
|
+
appendLedger({
|
|
235
|
+
actor: 'user',
|
|
236
|
+
action: 'rollback',
|
|
237
|
+
skill: entry.skill,
|
|
238
|
+
beforeHash: currentHash,
|
|
239
|
+
afterHash: EMPTY_HASH,
|
|
240
|
+
note: `回滚 ${entry.id}:这个技能是那次 create 建出来的,已整目录搬进归档区`,
|
|
241
|
+
ts: now,
|
|
242
|
+
});
|
|
243
|
+
return { ok: true, error: '', notice: `已把 ${entry.skill} 整个目录搬进归档区 ${target}(只搬不删,要恢复就把它搬回来)` };
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
ok: false,
|
|
247
|
+
error: `这条记录没有可用的副本(${entry.backup === undefined ? '台账里没记副本' : `副本 ${entry.backup} 不见了`}),回滚不了`,
|
|
248
|
+
notice: '',
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** 台账文件多大(设置页显示与「该整理了」这类判断用)。 */
|
|
252
|
+
export function ledgerSize() {
|
|
253
|
+
const file = ledgerFile();
|
|
254
|
+
try {
|
|
255
|
+
return existsSync(file) ? readFileSync(file, 'utf8').length : 0;
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/** 把一个文件复制成 `<原名>.bak.<秒级时间戳>`,返回副本文件名;失败返回空串。 */
|
|
262
|
+
export function copyToBackup(file, now = Date.now()) {
|
|
263
|
+
try {
|
|
264
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
265
|
+
const backup = `${basename(file)}.bak.${String(Math.floor(now / 1000))}`;
|
|
266
|
+
copyFileSync(file, join(dirname(file), backup));
|
|
267
|
+
return backup;
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
// 留不下副本也得继续往下走:副本是保险,不是这条规矩的全部
|
|
271
|
+
return '';
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { type ChatMessage } from '../llm.js';
|
|
2
|
+
import { type LedgerEntry } from './ledger.js';
|
|
3
|
+
/** 技能主文件名。 */
|
|
4
|
+
export declare const SKILL_FILE = "SKILL.md";
|
|
5
|
+
/** 技能根目录(用户级技能目录,与 core/skills.js 的 DSC_SKILLS_DIR 是同一个)。 */
|
|
6
|
+
export declare function skillsRoot(): string;
|
|
7
|
+
/** 归档区(只进不出地堆在这里,永不删)。 */
|
|
8
|
+
export declare function archiveRoot(): string;
|
|
9
|
+
/** 使用台账文件。 */
|
|
10
|
+
export declare function usageFile(): string;
|
|
11
|
+
/** 技能的硬约束(设置里只暴露体积与描述长度,名字长度按 hermes 固定 64)。 */
|
|
12
|
+
export interface SkillLimits {
|
|
13
|
+
/** description 的字符上限(hermes 的 SKILL_PROMPT_DESC_LIMIT)。 */
|
|
14
|
+
descriptionMax: number;
|
|
15
|
+
/** SKILL.md 整份的字符上限。 */
|
|
16
|
+
bodyMax: number;
|
|
17
|
+
/** 名字长度上限。 */
|
|
18
|
+
nameMax: number;
|
|
19
|
+
/** 单个附属文件(references/scripts 这类)的字节上限。 */
|
|
20
|
+
fileMax: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const DEFAULT_SKILL_LIMITS: SkillLimits;
|
|
23
|
+
/** 可以放附属文件的子目录(与 hermes 的 ALLOWED_SUBDIRS 一致,去掉 assets 换成 dsc 习惯的 assets 保留)。 */
|
|
24
|
+
export declare const ALLOWED_SUBDIRS: readonly string[];
|
|
25
|
+
/** 校验结果:失败带中文原因,成功带解析出来的字段。 */
|
|
26
|
+
export interface ValidateResult {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
error: string;
|
|
29
|
+
fields: SkillDraft | null;
|
|
30
|
+
}
|
|
31
|
+
/** 一份技能草稿的四个字段(L2 复盘让模型只回这四个)。 */
|
|
32
|
+
export interface SkillDraft {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
whenToUse: string;
|
|
36
|
+
content: string;
|
|
37
|
+
}
|
|
38
|
+
/** 名字合法吗;不合法给一句中文原因。 */
|
|
39
|
+
export declare function validateSkillName(name: string, limits?: SkillLimits): string;
|
|
40
|
+
/**
|
|
41
|
+
* 校验一份 SKILL.md 全文。
|
|
42
|
+
*
|
|
43
|
+
* 为什么 description 超限是**拒**而不是截断:技能目录里那份 description 是模型决定「要不要
|
|
44
|
+
* 加载这个技能」的唯一依据,截到 57 字符加省略号会把触发词本身砍掉(用户写「当用户说……
|
|
45
|
+
* 的时候」就没了后半句),于是这个技能永远不会被选中——静默失效比报错难查得多。
|
|
46
|
+
*/
|
|
47
|
+
export declare function validateSkillMarkdown(text: string, limits?: SkillLimits): ValidateResult;
|
|
48
|
+
/** 校验一份结构化草稿(L2 复盘与 `/learn` 走这条,插件自己拼 frontmatter)。 */
|
|
49
|
+
export declare function validateSkillDraft(draft: SkillDraft, limits?: SkillLimits): ValidateResult;
|
|
50
|
+
/**
|
|
51
|
+
* 把草稿拼成 SKILL.md 全文。
|
|
52
|
+
*
|
|
53
|
+
* frontmatter 的取值一律双引号包起来(JSON 字符串是合法 YAML 标量):description 里出现
|
|
54
|
+
* 冒号、引号、`#` 都不会把 YAML 解析带偏。`created_by: agent` 由这里盖章,
|
|
55
|
+
* 不接受调用方传值——它是「这份技能归自动化维护」的标记,老化归档只认它。
|
|
56
|
+
*/
|
|
57
|
+
export declare function renderSkillMarkdown(draft: SkillDraft): string;
|
|
58
|
+
/**
|
|
59
|
+
* 一段技能文本过不过安检。
|
|
60
|
+
*
|
|
61
|
+
* @returns 拦下的原因;空串表示放行。先做 NFKC 归一:全角与兼容字符先换成一副正经面孔再判,
|
|
62
|
+
* 不然一个全角的「ignore」就能绕过去。
|
|
63
|
+
*/
|
|
64
|
+
export declare function scanSkillThreat(text: string): string;
|
|
65
|
+
/** 整份技能目录的安检:SKILL.md 加全部附属文件一起看。 */
|
|
66
|
+
export declare function scanSkillDir(dir: string): string;
|
|
67
|
+
/** 原子写文本:tmp + rename(Windows 上 rename 会覆盖目标,所以不需要先删)。 */
|
|
68
|
+
export declare function atomicWriteText(file: string, text: string): void;
|
|
69
|
+
/** 技能目录路径。 */
|
|
70
|
+
export declare function skillDirOf(name: string): string;
|
|
71
|
+
/** 技能正文文件路径。 */
|
|
72
|
+
export declare function skillFileOf(name: string): string;
|
|
73
|
+
/** 一次技能写入的结果。 */
|
|
74
|
+
export interface SkillOpResult {
|
|
75
|
+
ok: boolean;
|
|
76
|
+
error: string;
|
|
77
|
+
/** 成功时给用户 / 模型看的一句话。 */
|
|
78
|
+
notice: string;
|
|
79
|
+
/** 这次写入记下的台账(失败时是 null)。 */
|
|
80
|
+
entry: LedgerEntry | null;
|
|
81
|
+
/** 改前留的副本文件名(没有副本就是空串)。 */
|
|
82
|
+
backup: string;
|
|
83
|
+
}
|
|
84
|
+
/** 新建技能的入参。 */
|
|
85
|
+
export interface CreateSkillInput {
|
|
86
|
+
name: string;
|
|
87
|
+
markdown: string;
|
|
88
|
+
actor: 'model' | 'user';
|
|
89
|
+
limits?: SkillLimits;
|
|
90
|
+
now?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 新建一个技能:校验 → 落盘 → 写后扫描(不过就删掉刚写的文件)→ 记台账 → **写进停用名单**。
|
|
94
|
+
*
|
|
95
|
+
* 为什么默认停用:一份刚由模型自己写出来的技能,还没经过用户看过一眼就进模型目录,
|
|
96
|
+
* 等于让模型用它自己写的手册指挥自己。停用之后用户 `/skills` 里点一下才生效。
|
|
97
|
+
*/
|
|
98
|
+
export declare function createSkill(input: CreateSkillInput): SkillOpResult;
|
|
99
|
+
/** patch 的入参。 */
|
|
100
|
+
export interface PatchSkillInput {
|
|
101
|
+
name: string;
|
|
102
|
+
oldString: string;
|
|
103
|
+
newString: string;
|
|
104
|
+
actor: 'model' | 'user';
|
|
105
|
+
limits?: SkillLimits;
|
|
106
|
+
/** replaceAll:默认 false,片段撞多处就拒(改错地方比不改更糟)。 */
|
|
107
|
+
replaceAll?: boolean;
|
|
108
|
+
/** read-before-write 是否满足(插件按会话状态判定后传进来)。 */
|
|
109
|
+
readConfirmed: boolean;
|
|
110
|
+
now?: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 改一处:先在内存里改,校验整份新内容,再留副本、落盘、扫描;不过就把原内容盖回去。
|
|
114
|
+
*
|
|
115
|
+
* 顺序不能反:先留副本再落盘(不然崩溃就两头空),先校验再落盘(不然写进去一份缺
|
|
116
|
+
* frontmatter 的文件,技能中心当场读不出来)。
|
|
117
|
+
*/
|
|
118
|
+
export declare function patchSkill(input: PatchSkillInput): SkillOpResult;
|
|
119
|
+
/** 写附属文件的入参。 */
|
|
120
|
+
export interface WriteSkillFileInput {
|
|
121
|
+
name: string;
|
|
122
|
+
/** 相对技能目录的路径,必须在 references/templates/scripts/assets 之下。 */
|
|
123
|
+
filePath: string;
|
|
124
|
+
content: string;
|
|
125
|
+
actor: 'model' | 'user';
|
|
126
|
+
limits?: SkillLimits;
|
|
127
|
+
readConfirmed: boolean;
|
|
128
|
+
now?: number;
|
|
129
|
+
}
|
|
130
|
+
/** 附属文件路径的合法性检查:不许跳出技能目录,必须落在允许的子目录里。 */
|
|
131
|
+
export declare function validateSkillFilePath(filePath: string): string;
|
|
132
|
+
/** 写一个附属文件(references/scripts 这类):路径受辖、体积受辖、写后照样过安检。 */
|
|
133
|
+
export declare function writeSkillFile(input: WriteSkillFileInput): SkillOpResult;
|
|
134
|
+
/** 秒级时间戳折成 `YYYYMMDDHHMMSS`(归档目录命名用,人一眼能看出是哪天搬的)。 */
|
|
135
|
+
export declare function formatStamp(now: number): string;
|
|
136
|
+
/** 把一个技能目录搬进归档区。 */
|
|
137
|
+
export declare function moveToArchive(name: string, now?: number, suffix?: string): {
|
|
138
|
+
ok: boolean;
|
|
139
|
+
error: string;
|
|
140
|
+
path: string;
|
|
141
|
+
};
|
|
142
|
+
/** 归档一个技能:只搬不删,台账里记一条。 */
|
|
143
|
+
export declare function archiveSkill(name: string, actor: 'model' | 'user', note?: string, now?: number): SkillOpResult;
|
|
144
|
+
/** 扫会话消息里 `skill` 工具的调用参数,得到本会话读过的技能名。 */
|
|
145
|
+
export declare function skillNamesReadInMessages(messages: readonly ChatMessage[]): string[];
|
|
146
|
+
/** read-before-write 的判定入参。 */
|
|
147
|
+
export interface ReadBeforeWriteInput {
|
|
148
|
+
/** 会话状态里记的已读技能。 */
|
|
149
|
+
readSkills: readonly string[];
|
|
150
|
+
/** 会话状态里记的「本插件刚建的技能」(刚建的算已读)。 */
|
|
151
|
+
createdSkills: readonly string[];
|
|
152
|
+
messages: readonly ChatMessage[];
|
|
153
|
+
name: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* read-before-write:本会话必须读过这个技能才准改。
|
|
157
|
+
*
|
|
158
|
+
* 为什么要查会话消息而不是只信会话状态:状态是插件自己写的,模型看不到也改不了,
|
|
159
|
+
* 但「读过」这个事实本来就在会话里(`skill` 工具的调用参数)。两边取并集,
|
|
160
|
+
* 重启恢复的老会话也能认出「这个会话确实读过它」。
|
|
161
|
+
*/
|
|
162
|
+
export declare function readBeforeWriteCheck(input: ReadBeforeWriteInput): {
|
|
163
|
+
ok: boolean;
|
|
164
|
+
error: string;
|
|
165
|
+
};
|
|
166
|
+
/** 从会话消息里取出最后一条用户消息的纯文本(L1 的纠正语气判定用)。 */
|
|
167
|
+
export declare function lastUserText(messages: readonly ChatMessage[]): string;
|
|
168
|
+
/** 最后一个用户消息之前那条用户消息(L1 记「上一轮用户说了什么」用)。 */
|
|
169
|
+
export declare function previousUserText(messages: readonly ChatMessage[]): string;
|
|
170
|
+
/** 本轮用了多少次工具迭代(从末尾往回数 tool 消息,遇到 user 消息停)。 */
|
|
171
|
+
export declare function toolIterationsOfTurn(messages: readonly ChatMessage[]): number;
|
|
172
|
+
/** 本轮用户消息是第几条(0 起算;没有用户消息返回 -1)。 */
|
|
173
|
+
export declare function userTurnIndex(messages: readonly ChatMessage[]): number;
|
|
174
|
+
/** 取最后一条 assistant 消息的正文(L2 复盘结果就是这一条)。 */
|
|
175
|
+
export declare function lastAssistantText(messages: readonly ChatMessage[]): string;
|
|
176
|
+
/** 技能的生命周期档位。 */
|
|
177
|
+
export type SkillLifecycle = 'active' | 'stale' | 'archived';
|
|
178
|
+
/** 一个技能的使用记录。 */
|
|
179
|
+
export interface SkillUsageRecord {
|
|
180
|
+
/** `agent` = 这份技能归自动化维护(老化归档只动这一档);其它值(user / installed)不自动动它。 */
|
|
181
|
+
createdBy: string;
|
|
182
|
+
/** 被 `skill` 工具读出来的次数。 */
|
|
183
|
+
useCount: number;
|
|
184
|
+
/** 被 patch / write_file 改过的次数。 */
|
|
185
|
+
patchCount: number;
|
|
186
|
+
createdAt: number;
|
|
187
|
+
/** 最后一次被读出来的时间;从没读过就是 null。 */
|
|
188
|
+
lastUsedAt: number | null;
|
|
189
|
+
lastPatchedAt: number | null;
|
|
190
|
+
state: SkillLifecycle;
|
|
191
|
+
/** 钉住:挡住一切自动改写与自动归档。 */
|
|
192
|
+
pinned: boolean;
|
|
193
|
+
archivedAt: number | null;
|
|
194
|
+
}
|
|
195
|
+
/** 使用台账整份文件。 */
|
|
196
|
+
export interface UsageDoc {
|
|
197
|
+
version: number;
|
|
198
|
+
skills: Record<string, SkillUsageRecord>;
|
|
199
|
+
}
|
|
200
|
+
/** 读使用台账;文件缺失或坏了都当空台账(它只是遥测,不该让技能功能瘫掉)。 */
|
|
201
|
+
export declare function readUsage(): UsageDoc;
|
|
202
|
+
/** 写使用台账(tmp + rename)。 */
|
|
203
|
+
export declare function writeUsage(doc: UsageDoc): void;
|
|
204
|
+
/** 记一次命中(`skill` 工具把它读出来了):stale 的重新变 active。 */
|
|
205
|
+
export declare function bumpSkillUse(name: string, now?: number): void;
|
|
206
|
+
/** 记一次改动(patch / write_file)。 */
|
|
207
|
+
export declare function bumpSkillPatch(name: string, now?: number): void;
|
|
208
|
+
/** 新建技能时起一条记录:`createdBy: agent` 是「允许自动化维护它」的唯一凭据。 */
|
|
209
|
+
export declare function recordSkillCreated(name: string, now?: number, createdBy?: string): void;
|
|
210
|
+
/** 钉住 / 取消钉住;返回钉住后的状态。 */
|
|
211
|
+
export declare function setSkillPinned(name: string, pinned: boolean, now?: number): boolean;
|
|
212
|
+
/** 这个技能被钉住了吗。 */
|
|
213
|
+
export declare function isSkillPinned(name: string): boolean;
|
|
214
|
+
/** 老化判定用的阈值。 */
|
|
215
|
+
export interface AgingOptions {
|
|
216
|
+
/** 多少天没命中算 stale。 */
|
|
217
|
+
staleAfterDays: number;
|
|
218
|
+
/** 多少天没命中就归档。 */
|
|
219
|
+
archiveAfterDays: number;
|
|
220
|
+
}
|
|
221
|
+
export declare const DEFAULT_AGING: AgingOptions;
|
|
222
|
+
/**
|
|
223
|
+
* 一条记录现在该是什么档:活跃时间取「最后一次被读 / 被改 / 创建」里最新的那个。
|
|
224
|
+
*
|
|
225
|
+
* 为什么把 patch 也算活跃:被改过说明它还在被维护,用「最近一次命中」单算会把
|
|
226
|
+
* 一个正在被反复改的技能判成 stale。
|
|
227
|
+
*/
|
|
228
|
+
export declare function classifyAging(record: SkillUsageRecord, now: number, options?: AgingOptions): SkillLifecycle;
|
|
229
|
+
/** 一次整理的账。 */
|
|
230
|
+
export interface CurateReport {
|
|
231
|
+
/** 这一轮降级成 stale 的技能。 */
|
|
232
|
+
stale: string[];
|
|
233
|
+
/** 这一轮归档的技能。 */
|
|
234
|
+
archived: string[];
|
|
235
|
+
/** 看着没事的、以及不该自动动的(用户手写、钉住、已归档)。 */
|
|
236
|
+
skipped: string[];
|
|
237
|
+
/** 整理后剩下的技能数。 */
|
|
238
|
+
total: number;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* 整理一次:把久未命中的技能降级,把过期的搬进归档区。
|
|
242
|
+
*
|
|
243
|
+
* **只动 `createdBy: 'agent'` 的技能**(与 hermes 的 curator 同一条规矩):用户手写的技能
|
|
244
|
+
* 是用户的东西,自动化没有资格替他把目录搬走。钉住的技能一律跳过。
|
|
245
|
+
*/
|
|
246
|
+
export declare function curateSkills(now?: number, options?: AgingOptions): CurateReport;
|
|
247
|
+
/** 技能目录里有哪些本地技能(整理与设置页显示用)。 */
|
|
248
|
+
export declare function localSkillNames(): string[];
|
|
249
|
+
/** 归档区里堆了多少个(设置页显示「只搬不删」的现状)。 */
|
|
250
|
+
export declare function archivedCount(): number;
|