@vascend/talos 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -0
- package/dist/backend/asset-events.d.ts +31 -0
- package/dist/backend/asset-events.js +149 -0
- package/dist/backend/assets.d.ts +31 -0
- package/dist/backend/assets.js +210 -0
- package/dist/backend/auth.d.ts +18 -0
- package/dist/backend/auth.js +59 -0
- package/dist/backend/config.d.ts +14 -0
- package/dist/backend/config.js +41 -0
- package/dist/backend/conversations.d.ts +21 -0
- package/dist/backend/conversations.js +141 -0
- package/dist/backend/crypto.d.ts +9 -0
- package/dist/backend/crypto.js +68 -0
- package/dist/backend/engine.d.ts +13 -0
- package/dist/backend/engine.js +78 -0
- package/dist/backend/http.d.ts +25 -0
- package/dist/backend/http.js +112 -0
- package/dist/backend/index.d.ts +1 -0
- package/dist/backend/index.js +24 -0
- package/dist/backend/routes.d.ts +14 -0
- package/dist/backend/routes.js +169 -0
- package/dist/backend/sdk.d.ts +12 -0
- package/dist/backend/sdk.js +11 -0
- package/dist/backend/server.d.ts +12 -0
- package/dist/backend/server.js +91 -0
- package/dist/backend/temp-image-store.d.ts +46 -0
- package/dist/backend/temp-image-store.js +197 -0
- package/dist/backend/types.d.ts +103 -0
- package/dist/backend/types.js +29 -0
- package/dist/backend/users.d.ts +13 -0
- package/dist/backend/users.js +76 -0
- package/dist/backend/ws-handler.d.ts +14 -0
- package/dist/backend/ws-handler.js +72 -0
- package/dist/backend/ws.d.ts +19 -0
- package/dist/backend/ws.js +146 -0
- package/dist/core/agent.d.ts +56 -0
- package/dist/core/agent.js +1783 -0
- package/dist/core/background.d.ts +45 -0
- package/dist/core/background.js +140 -0
- package/dist/core/bootstrap.d.ts +45 -0
- package/dist/core/bootstrap.js +294 -0
- package/dist/core/cli-args.d.ts +41 -0
- package/dist/core/cli-args.js +282 -0
- package/dist/core/collapsible-output.d.ts +38 -0
- package/dist/core/collapsible-output.js +143 -0
- package/dist/core/compaction-checkpoint.d.ts +9 -0
- package/dist/core/compaction-checkpoint.js +58 -0
- package/dist/core/compaction.d.ts +42 -0
- package/dist/core/compaction.js +270 -0
- package/dist/core/config.d.ts +49 -0
- package/dist/core/config.js +417 -0
- package/dist/core/context-ledger.d.ts +99 -0
- package/dist/core/context-ledger.js +222 -0
- package/dist/core/context-policy.d.ts +17 -0
- package/dist/core/context-policy.js +81 -0
- package/dist/core/continuation-review.d.ts +23 -0
- package/dist/core/continuation-review.js +64 -0
- package/dist/core/crash-report.d.ts +3 -0
- package/dist/core/crash-report.js +27 -0
- package/dist/core/credentials.d.ts +11 -0
- package/dist/core/credentials.js +183 -0
- package/dist/core/doctor.d.ts +24 -0
- package/dist/core/doctor.js +125 -0
- package/dist/core/effort.d.ts +5 -0
- package/dist/core/effort.js +42 -0
- package/dist/core/env-paths.d.ts +3 -0
- package/dist/core/env-paths.js +38 -0
- package/dist/core/execution-guidance.d.ts +9 -0
- package/dist/core/execution-guidance.js +73 -0
- package/dist/core/execution-target.d.ts +41 -0
- package/dist/core/execution-target.js +69 -0
- package/dist/core/file-coordination.d.ts +66 -0
- package/dist/core/file-coordination.js +176 -0
- package/dist/core/file-lease-store.d.ts +14 -0
- package/dist/core/file-lease-store.js +89 -0
- package/dist/core/image-limits.d.ts +26 -0
- package/dist/core/image-limits.js +205 -0
- package/dist/core/interruptible-completion.d.ts +3 -0
- package/dist/core/interruptible-completion.js +42 -0
- package/dist/core/kingdoms-mode-state.d.ts +24 -0
- package/dist/core/kingdoms-mode-state.js +139 -0
- package/dist/core/licenza.d.ts +38 -0
- package/dist/core/licenza.js +125 -0
- package/dist/core/model-limits.d.ts +2 -0
- package/dist/core/model-limits.js +36 -0
- package/dist/core/output-lifecycle.d.ts +44 -0
- package/dist/core/output-lifecycle.js +190 -0
- package/dist/core/package-update.d.ts +15 -0
- package/dist/core/package-update.js +121 -0
- package/dist/core/permission-queue.d.ts +2 -0
- package/dist/core/permission-queue.js +20 -0
- package/dist/core/prompt-attachment.d.ts +21 -0
- package/dist/core/prompt-attachment.js +123 -0
- package/dist/core/request-plan.d.ts +16 -0
- package/dist/core/request-plan.js +36 -0
- package/dist/core/run-timing.d.ts +17 -0
- package/dist/core/run-timing.js +123 -0
- package/dist/core/self-update.d.ts +17 -0
- package/dist/core/self-update.js +54 -0
- package/dist/core/session-refs.d.ts +27 -0
- package/dist/core/session-refs.js +126 -0
- package/dist/core/session-storage.d.ts +4 -0
- package/dist/core/session-storage.js +48 -0
- package/dist/core/session-title.d.ts +1 -0
- package/dist/core/session-title.js +21 -0
- package/dist/core/session-usage.d.ts +17 -0
- package/dist/core/session-usage.js +74 -0
- package/dist/core/session.d.ts +58 -0
- package/dist/core/session.js +296 -0
- package/dist/core/settings.d.ts +17 -0
- package/dist/core/settings.js +107 -0
- package/dist/core/storage-retention.d.ts +21 -0
- package/dist/core/storage-retention.js +227 -0
- package/dist/core/text-sanitize.d.ts +1 -0
- package/dist/core/text-sanitize.js +35 -0
- package/dist/core/tool-artifacts.d.ts +6 -0
- package/dist/core/tool-artifacts.js +51 -0
- package/dist/core/tool-compress.d.ts +8 -0
- package/dist/core/tool-compress.js +111 -0
- package/dist/core/tool-executor.d.ts +16 -0
- package/dist/core/tool-executor.js +97 -0
- package/dist/core/tool-result-index.d.ts +52 -0
- package/dist/core/tool-result-index.js +327 -0
- package/dist/core/tool-result-store.d.ts +38 -0
- package/dist/core/tool-result-store.js +190 -0
- package/dist/core/tool-scheduler.d.ts +16 -0
- package/dist/core/tool-scheduler.js +35 -0
- package/dist/core/trust.d.ts +21 -0
- package/dist/core/trust.js +95 -0
- package/dist/core/types.d.ts +402 -0
- package/dist/core/types.js +1 -0
- package/dist/core/update-check.d.ts +26 -0
- package/dist/core/update-check.js +89 -0
- package/dist/core/update-process.d.ts +10 -0
- package/dist/core/update-process.js +31 -0
- package/dist/core/user-inbox.d.ts +23 -0
- package/dist/core/user-inbox.js +56 -0
- package/dist/core/user-input.d.ts +10 -0
- package/dist/core/user-input.js +35 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +10 -0
- package/dist/core/vibe-modes.d.ts +38 -0
- package/dist/core/vibe-modes.js +383 -0
- package/dist/core/workspace-roots.d.ts +13 -0
- package/dist/core/workspace-roots.js +91 -0
- package/dist/core/workspace-sessions.d.ts +51 -0
- package/dist/core/workspace-sessions.js +243 -0
- package/dist/cowork/client.d.ts +29 -0
- package/dist/cowork/client.js +49 -0
- package/dist/cowork/engine-bridge.d.ts +22 -0
- package/dist/cowork/engine-bridge.js +98 -0
- package/dist/cowork/index.d.ts +11 -0
- package/dist/cowork/index.js +16 -0
- package/dist/cowork/ipc.d.ts +97 -0
- package/dist/cowork/ipc.js +96 -0
- package/dist/cowork/manager.d.ts +66 -0
- package/dist/cowork/manager.js +325 -0
- package/dist/cowork/store.d.ts +23 -0
- package/dist/cowork/store.js +182 -0
- package/dist/cowork/sync.d.ts +20 -0
- package/dist/cowork/sync.js +164 -0
- package/dist/cowork/types.d.ts +78 -0
- package/dist/cowork/types.js +21 -0
- package/dist/extensions/ext-tools.d.ts +3 -0
- package/dist/extensions/ext-tools.js +73 -0
- package/dist/extensions/loader.d.ts +91 -0
- package/dist/extensions/loader.js +474 -0
- package/dist/extensions/settings.d.ts +20 -0
- package/dist/extensions/settings.js +86 -0
- package/dist/extensions/types.d.ts +219 -0
- package/dist/extensions/types.js +1 -0
- package/dist/horizon/async-queue.d.ts +9 -0
- package/dist/horizon/async-queue.js +46 -0
- package/dist/horizon/engine.d.ts +85 -0
- package/dist/horizon/engine.js +603 -0
- package/dist/horizon/index.d.ts +4 -0
- package/dist/horizon/index.js +2 -0
- package/dist/horizon/main-team.d.ts +163 -0
- package/dist/horizon/main-team.js +774 -0
- package/dist/horizon/types.d.ts +233 -0
- package/dist/horizon/types.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +233 -0
- package/dist/mcp/protocol.d.ts +81 -0
- package/dist/mcp/protocol.js +122 -0
- package/dist/package.json +1 -0
- package/dist/packages/packages.d.ts +12 -0
- package/dist/packages/packages.js +323 -0
- package/dist/prompts/templates.d.ts +13 -0
- package/dist/prompts/templates.js +139 -0
- package/dist/providers/anthropic-oauth.d.ts +13 -0
- package/dist/providers/anthropic-oauth.js +124 -0
- package/dist/providers/anthropic.d.ts +27 -0
- package/dist/providers/anthropic.js +526 -0
- package/dist/providers/catalog.d.ts +15 -0
- package/dist/providers/catalog.js +166 -0
- package/dist/providers/effort.d.ts +12 -0
- package/dist/providers/effort.js +102 -0
- package/dist/providers/model-catalog.d.ts +43 -0
- package/dist/providers/model-catalog.js +70 -0
- package/dist/providers/model-effort.d.ts +5 -0
- package/dist/providers/model-effort.js +43 -0
- package/dist/providers/model-registry.d.ts +39 -0
- package/dist/providers/model-registry.js +142 -0
- package/dist/providers/models-dev.d.ts +9 -0
- package/dist/providers/models-dev.js +97 -0
- package/dist/providers/oauth-callback-server.d.ts +28 -0
- package/dist/providers/oauth-callback-server.js +184 -0
- package/dist/providers/oauth-orchestrator.d.ts +58 -0
- package/dist/providers/oauth-orchestrator.js +159 -0
- package/dist/providers/oauth-store.d.ts +12 -0
- package/dist/providers/oauth-store.js +139 -0
- package/dist/providers/open-browser.d.ts +20 -0
- package/dist/providers/open-browser.js +92 -0
- package/dist/providers/openai-compat.d.ts +14 -0
- package/dist/providers/openai-compat.js +523 -0
- package/dist/providers/openai-oauth.d.ts +15 -0
- package/dist/providers/openai-oauth.js +382 -0
- package/dist/providers/openrouter-auth.d.ts +73 -0
- package/dist/providers/openrouter-auth.js +321 -0
- package/dist/providers/openrouter-manual-fallback.d.ts +25 -0
- package/dist/providers/openrouter-manual-fallback.js +161 -0
- package/dist/providers/openrouter.d.ts +15 -0
- package/dist/providers/openrouter.js +107 -0
- package/dist/providers/plan-limits.d.ts +6 -0
- package/dist/providers/plan-limits.js +175 -0
- package/dist/providers/provider-reset.d.ts +4 -0
- package/dist/providers/provider-reset.js +83 -0
- package/dist/providers/quota-limits.d.ts +4 -0
- package/dist/providers/quota-limits.js +33 -0
- package/dist/providers/registry.d.ts +33 -0
- package/dist/providers/registry.js +213 -0
- package/dist/providers/retry.d.ts +37 -0
- package/dist/providers/retry.js +347 -0
- package/dist/rpc/server.d.ts +23 -0
- package/dist/rpc/server.js +222 -0
- package/dist/sdk.d.ts +67 -0
- package/dist/sdk.js +64 -0
- package/dist/skills/skills.d.ts +17 -0
- package/dist/skills/skills.js +155 -0
- package/dist/text-sanitize.js +28 -0
- package/dist/tools/ask-user.d.ts +2 -0
- package/dist/tools/ask-user.js +60 -0
- package/dist/tools/builtin.d.ts +48 -0
- package/dist/tools/builtin.js +2494 -0
- package/dist/tools/capabilities.d.ts +5 -0
- package/dist/tools/capabilities.js +55 -0
- package/dist/tools/computer-capture.d.ts +2 -0
- package/dist/tools/computer-capture.js +91 -0
- package/dist/tools/computer-posix.d.ts +5 -0
- package/dist/tools/computer-posix.js +136 -0
- package/dist/tools/computer-use.d.ts +14 -0
- package/dist/tools/computer-use.js +108 -0
- package/dist/tools/discovery.d.ts +12 -0
- package/dist/tools/discovery.js +205 -0
- package/dist/tools/execute.d.ts +2 -0
- package/dist/tools/execute.js +73 -0
- package/dist/tools/normalize-input.d.ts +17 -0
- package/dist/tools/normalize-input.js +174 -0
- package/dist/tools/output-artifact.d.ts +3 -0
- package/dist/tools/output-artifact.js +80 -0
- package/dist/tools/pagination.d.ts +15 -0
- package/dist/tools/pagination.js +93 -0
- package/dist/tools/plan-status.d.ts +2 -0
- package/dist/tools/plan-status.js +109 -0
- package/dist/tools/program-input.d.ts +3 -0
- package/dist/tools/program-input.js +19 -0
- package/dist/tools/program.d.ts +3 -0
- package/dist/tools/program.js +567 -0
- package/dist/tools/protocol-catalog.d.ts +12 -0
- package/dist/tools/protocol-catalog.js +46 -0
- package/dist/tools/ramification-tools.d.ts +12 -0
- package/dist/tools/ramification-tools.js +528 -0
- package/dist/tools/regex-compat.d.ts +9 -0
- package/dist/tools/regex-compat.js +96 -0
- package/dist/tools/registry.d.ts +51 -0
- package/dist/tools/registry.js +185 -0
- package/dist/tools/resolve.d.ts +2 -0
- package/dist/tools/resolve.js +107 -0
- package/dist/tools/shell-env.d.ts +2 -0
- package/dist/tools/shell-env.js +7 -0
- package/dist/tools/team-input.d.ts +3 -0
- package/dist/tools/team-input.js +129 -0
- package/dist/tools/team-tools.d.ts +7 -0
- package/dist/tools/team-tools.js +348 -0
- package/dist/tools/workspace-sessions.d.ts +2 -0
- package/dist/tools/workspace-sessions.js +35 -0
- package/dist/tui/account-entry.d.ts +1 -0
- package/dist/tui/account-entry.js +93 -0
- package/dist/tui/attachment-highlight.d.ts +1 -0
- package/dist/tui/attachment-highlight.js +24 -0
- package/dist/tui/attachment-refs.d.ts +2 -0
- package/dist/tui/attachment-refs.js +3 -0
- package/dist/tui/bottom-input.d.ts +219 -0
- package/dist/tui/bottom-input.js +1958 -0
- package/dist/tui/branding.d.ts +107 -0
- package/dist/tui/branding.js +750 -0
- package/dist/tui/clipboard-image.d.ts +10 -0
- package/dist/tui/clipboard-image.js +163 -0
- package/dist/tui/clipboard-text.d.ts +9 -0
- package/dist/tui/clipboard-text.js +51 -0
- package/dist/tui/clipboard-windows.d.ts +8 -0
- package/dist/tui/clipboard-windows.js +84 -0
- package/dist/tui/collapsible-command.d.ts +15 -0
- package/dist/tui/collapsible-command.js +48 -0
- package/dist/tui/command-feedback.d.ts +10 -0
- package/dist/tui/command-feedback.js +46 -0
- package/dist/tui/command-output-registry.d.ts +28 -0
- package/dist/tui/command-output-registry.js +103 -0
- package/dist/tui/command-transcript.d.ts +12 -0
- package/dist/tui/command-transcript.js +90 -0
- package/dist/tui/commands.d.ts +20 -0
- package/dist/tui/commands.js +131 -0
- package/dist/tui/context-bar.d.ts +4 -0
- package/dist/tui/context-bar.js +74 -0
- package/dist/tui/context-meter.d.ts +25 -0
- package/dist/tui/context-meter.js +81 -0
- package/dist/tui/cost-binding.d.ts +8 -0
- package/dist/tui/cost-binding.js +43 -0
- package/dist/tui/cost-tracker.d.ts +49 -0
- package/dist/tui/cost-tracker.js +122 -0
- package/dist/tui/diff.d.ts +9 -0
- package/dist/tui/diff.js +119 -0
- package/dist/tui/i18n-catalog.d.ts +5 -0
- package/dist/tui/i18n-catalog.js +184 -0
- package/dist/tui/i18n.d.ts +6 -0
- package/dist/tui/i18n.js +10 -0
- package/dist/tui/image-attachments.d.ts +46 -0
- package/dist/tui/image-attachments.js +167 -0
- package/dist/tui/images.d.ts +12 -0
- package/dist/tui/images.js +87 -0
- package/dist/tui/intro.d.ts +13 -0
- package/dist/tui/intro.js +109 -0
- package/dist/tui/language-preference.d.ts +6 -0
- package/dist/tui/language-preference.js +24 -0
- package/dist/tui/live-output.d.ts +2 -0
- package/dist/tui/live-output.js +18 -0
- package/dist/tui/locales.d.ts +19 -0
- package/dist/tui/locales.js +22 -0
- package/dist/tui/login-menu.d.ts +17 -0
- package/dist/tui/login-menu.js +58 -0
- package/dist/tui/logo.d.ts +8 -0
- package/dist/tui/logo.js +305 -0
- package/dist/tui/markdown-inline.d.ts +3 -0
- package/dist/tui/markdown-inline.js +99 -0
- package/dist/tui/markdown-table.d.ts +4 -0
- package/dist/tui/markdown-table.js +63 -0
- package/dist/tui/markdown.d.ts +11 -0
- package/dist/tui/markdown.js +257 -0
- package/dist/tui/mcp-transcript.d.ts +7 -0
- package/dist/tui/mcp-transcript.js +40 -0
- package/dist/tui/model-details.d.ts +2 -0
- package/dist/tui/model-details.js +21 -0
- package/dist/tui/model-selection.d.ts +7 -0
- package/dist/tui/model-selection.js +41 -0
- package/dist/tui/native-scrollback.d.ts +27 -0
- package/dist/tui/native-scrollback.js +134 -0
- package/dist/tui/onboarding.d.ts +72 -0
- package/dist/tui/onboarding.js +207 -0
- package/dist/tui/paste-collapse.d.ts +39 -0
- package/dist/tui/paste-collapse.js +117 -0
- package/dist/tui/perm-mode.d.ts +8 -0
- package/dist/tui/perm-mode.js +41 -0
- package/dist/tui/prompt-queue-store.d.ts +26 -0
- package/dist/tui/prompt-queue-store.js +87 -0
- package/dist/tui/prompt-queue.d.ts +47 -0
- package/dist/tui/prompt-queue.js +187 -0
- package/dist/tui/provider-menu.d.ts +33 -0
- package/dist/tui/provider-menu.js +175 -0
- package/dist/tui/question.d.ts +24 -0
- package/dist/tui/question.js +32 -0
- package/dist/tui/queue-screen.d.ts +25 -0
- package/dist/tui/queue-screen.js +152 -0
- package/dist/tui/queue-team.d.ts +3 -0
- package/dist/tui/queue-team.js +28 -0
- package/dist/tui/queued-questions.d.ts +20 -0
- package/dist/tui/queued-questions.js +163 -0
- package/dist/tui/quick-help.d.ts +1 -0
- package/dist/tui/quick-help.js +53 -0
- package/dist/tui/repl.d.ts +78 -0
- package/dist/tui/repl.js +4130 -0
- package/dist/tui/restore-queued-input.d.ts +3 -0
- package/dist/tui/restore-queued-input.js +20 -0
- package/dist/tui/review-detail.d.ts +6 -0
- package/dist/tui/review-detail.js +56 -0
- package/dist/tui/review-files.d.ts +3 -0
- package/dist/tui/review-files.js +22 -0
- package/dist/tui/review-render.d.ts +22 -0
- package/dist/tui/review-render.js +98 -0
- package/dist/tui/review-screen.d.ts +38 -0
- package/dist/tui/review-screen.js +358 -0
- package/dist/tui/review-store.d.ts +60 -0
- package/dist/tui/review-store.js +270 -0
- package/dist/tui/review-team.d.ts +2 -0
- package/dist/tui/review-team.js +27 -0
- package/dist/tui/selector-mouse.d.ts +26 -0
- package/dist/tui/selector-mouse.js +65 -0
- package/dist/tui/selector.d.ts +51 -0
- package/dist/tui/selector.js +299 -0
- package/dist/tui/session-replay.d.ts +10 -0
- package/dist/tui/session-replay.js +78 -0
- package/dist/tui/session-usage.d.ts +22 -0
- package/dist/tui/session-usage.js +55 -0
- package/dist/tui/skill-transcript.d.ts +5 -0
- package/dist/tui/skill-transcript.js +31 -0
- package/dist/tui/startup.d.ts +5 -0
- package/dist/tui/startup.js +61 -0
- package/dist/tui/status-line-loader.d.ts +8 -0
- package/dist/tui/status-line-loader.js +33 -0
- package/dist/tui/status-line.d.ts +38 -0
- package/dist/tui/status-line.js +213 -0
- package/dist/tui/system-language.d.ts +8 -0
- package/dist/tui/system-language.js +41 -0
- package/dist/tui/task-labels.d.ts +2 -0
- package/dist/tui/task-labels.js +7 -0
- package/dist/tui/term-bg.d.ts +4 -0
- package/dist/tui/term-bg.js +67 -0
- package/dist/tui/terminal-screen.d.ts +12 -0
- package/dist/tui/terminal-screen.js +1 -0
- package/dist/tui/terminal-text.d.ts +7 -0
- package/dist/tui/terminal-text.js +123 -0
- package/dist/tui/theme.d.ts +25 -0
- package/dist/tui/theme.js +383 -0
- package/dist/tui/tool-style.d.ts +7 -0
- package/dist/tui/tool-style.js +119 -0
- package/dist/tui/update-prompt.d.ts +14 -0
- package/dist/tui/update-prompt.js +104 -0
- package/dist/tui/usage-footer.d.ts +9 -0
- package/dist/tui/usage-footer.js +123 -0
- package/dist/tui/vascend-login.d.ts +68 -0
- package/dist/tui/vascend-login.js +355 -0
- package/dist/tui/web-login.d.ts +28 -0
- package/dist/tui/web-login.js +115 -0
- package/dist/vascend/activity-status.d.ts +12 -0
- package/dist/vascend/activity-status.js +68 -0
- package/dist/vascend/architecture-map.d.ts +73 -0
- package/dist/vascend/architecture-map.js +424 -0
- package/dist/vascend/attention-layout.d.ts +19 -0
- package/dist/vascend/attention-layout.js +141 -0
- package/dist/vascend/budget-allocator.d.ts +31 -0
- package/dist/vascend/budget-allocator.js +79 -0
- package/dist/vascend/candidate-collector.d.ts +20 -0
- package/dist/vascend/candidate-collector.js +220 -0
- package/dist/vascend/code-events.d.ts +24 -0
- package/dist/vascend/code-events.js +304 -0
- package/dist/vascend/code-graph-memory.d.ts +38 -0
- package/dist/vascend/code-graph-memory.js +334 -0
- package/dist/vascend/code-graph-runtime.d.ts +19 -0
- package/dist/vascend/code-graph-runtime.js +190 -0
- package/dist/vascend/code-graph-types.d.ts +58 -0
- package/dist/vascend/code-graph-types.js +50 -0
- package/dist/vascend/code-parser.d.ts +4 -0
- package/dist/vascend/code-parser.js +257 -0
- package/dist/vascend/competitor-knowledge.d.ts +53 -0
- package/dist/vascend/competitor-knowledge.js +262 -0
- package/dist/vascend/completeness.d.ts +16 -0
- package/dist/vascend/completeness.js +90 -0
- package/dist/vascend/context-autotuner.d.ts +45 -0
- package/dist/vascend/context-autotuner.js +231 -0
- package/dist/vascend/context-candidate.d.ts +45 -0
- package/dist/vascend/context-candidate.js +150 -0
- package/dist/vascend/context-capsule.d.ts +51 -0
- package/dist/vascend/context-capsule.js +133 -0
- package/dist/vascend/context-fabric.d.ts +108 -0
- package/dist/vascend/context-fabric.js +480 -0
- package/dist/vascend/context-feedback-loop.d.ts +56 -0
- package/dist/vascend/context-feedback-loop.js +204 -0
- package/dist/vascend/context-learning-identity.d.ts +4 -0
- package/dist/vascend/context-learning-identity.js +8 -0
- package/dist/vascend/context-links.d.ts +14 -0
- package/dist/vascend/context-links.js +83 -0
- package/dist/vascend/context-lint.d.ts +22 -0
- package/dist/vascend/context-lint.js +91 -0
- package/dist/vascend/context-market-selection.d.ts +17 -0
- package/dist/vascend/context-market-selection.js +50 -0
- package/dist/vascend/context-metrics.d.ts +25 -0
- package/dist/vascend/context-metrics.js +57 -0
- package/dist/vascend/context-pack-render.d.ts +16 -0
- package/dist/vascend/context-pack-render.js +52 -0
- package/dist/vascend/context-pareto.d.ts +33 -0
- package/dist/vascend/context-pareto.js +165 -0
- package/dist/vascend/context-pattern-explorer.d.ts +41 -0
- package/dist/vascend/context-pattern-explorer.js +276 -0
- package/dist/vascend/context-regret.d.ts +32 -0
- package/dist/vascend/context-regret.js +93 -0
- package/dist/vascend/context-retriever.d.ts +22 -0
- package/dist/vascend/context-retriever.js +243 -0
- package/dist/vascend/context-scope-index.d.ts +5 -0
- package/dist/vascend/context-scope-index.js +96 -0
- package/dist/vascend/context-scorer.d.ts +35 -0
- package/dist/vascend/context-scorer.js +162 -0
- package/dist/vascend/context-search-index.d.ts +12 -0
- package/dist/vascend/context-search-index.js +25 -0
- package/dist/vascend/context-snapshot.d.ts +22 -0
- package/dist/vascend/context-snapshot.js +135 -0
- package/dist/vascend/context-window-compiler.d.ts +42 -0
- package/dist/vascend/context-window-compiler.js +237 -0
- package/dist/vascend/contract-memory.d.ts +61 -0
- package/dist/vascend/contract-memory.js +435 -0
- package/dist/vascend/council.d.ts +58 -0
- package/dist/vascend/council.js +337 -0
- package/dist/vascend/decision-promotion.d.ts +48 -0
- package/dist/vascend/decision-promotion.js +410 -0
- package/dist/vascend/delta-context.d.ts +12 -0
- package/dist/vascend/delta-context.js +36 -0
- package/dist/vascend/dev-context-compiler.d.ts +27 -0
- package/dist/vascend/dev-context-compiler.js +133 -0
- package/dist/vascend/dev-context-layout.d.ts +30 -0
- package/dist/vascend/dev-context-layout.js +262 -0
- package/dist/vascend/evidence-slots.d.ts +14 -0
- package/dist/vascend/evidence-slots.js +55 -0
- package/dist/vascend/expansion-levels.d.ts +15 -0
- package/dist/vascend/expansion-levels.js +178 -0
- package/dist/vascend/file-lock.d.ts +7 -0
- package/dist/vascend/file-lock.js +95 -0
- package/dist/vascend/granular-kingdom.d.ts +25 -0
- package/dist/vascend/granular-kingdom.js +259 -0
- package/dist/vascend/granular-launcher.d.ts +48 -0
- package/dist/vascend/granular-launcher.js +202 -0
- package/dist/vascend/kingdom-bus.d.ts +25 -0
- package/dist/vascend/kingdom-bus.js +54 -0
- package/dist/vascend/kingdom-channel.d.ts +22 -0
- package/dist/vascend/kingdom-channel.js +180 -0
- package/dist/vascend/kingdom-kpi.d.ts +48 -0
- package/dist/vascend/kingdom-kpi.js +172 -0
- package/dist/vascend/kingdom-live.d.ts +28 -0
- package/dist/vascend/kingdom-live.js +61 -0
- package/dist/vascend/kingdom-run.d.ts +18 -0
- package/dist/vascend/kingdom-run.js +506 -0
- package/dist/vascend/kingdom-scribe.d.ts +20 -0
- package/dist/vascend/kingdom-scribe.js +52 -0
- package/dist/vascend/kingdom.d.ts +79 -0
- package/dist/vascend/kingdom.js +870 -0
- package/dist/vascend/lexical-index.d.ts +10 -0
- package/dist/vascend/lexical-index.js +99 -0
- package/dist/vascend/lexical-search.d.ts +29 -0
- package/dist/vascend/lexical-search.js +262 -0
- package/dist/vascend/long-term-context.d.ts +51 -0
- package/dist/vascend/long-term-context.js +194 -0
- package/dist/vascend/mandate.d.ts +33 -0
- package/dist/vascend/mandate.js +107 -0
- package/dist/vascend/memory-packet.d.ts +13 -0
- package/dist/vascend/memory-packet.js +155 -0
- package/dist/vascend/memory-status.d.ts +22 -0
- package/dist/vascend/memory-status.js +73 -0
- package/dist/vascend/memory-store.d.ts +62 -0
- package/dist/vascend/memory-store.js +273 -0
- package/dist/vascend/objective-revision.d.ts +69 -0
- package/dist/vascend/objective-revision.js +319 -0
- package/dist/vascend/patch-plan-store.d.ts +33 -0
- package/dist/vascend/patch-plan-store.js +240 -0
- package/dist/vascend/patch-plan.d.ts +97 -0
- package/dist/vascend/patch-plan.js +345 -0
- package/dist/vascend/plan-progress.d.ts +11 -0
- package/dist/vascend/plan-progress.js +68 -0
- package/dist/vascend/plan-store.d.ts +64 -0
- package/dist/vascend/plan-store.js +460 -0
- package/dist/vascend/proof-chains.d.ts +19 -0
- package/dist/vascend/proof-chains.js +120 -0
- package/dist/vascend/ramification-store.d.ts +25 -0
- package/dist/vascend/ramification-store.js +94 -0
- package/dist/vascend/ramification.d.ts +193 -0
- package/dist/vascend/ramification.js +583 -0
- package/dist/vascend/recall-planner.d.ts +17 -0
- package/dist/vascend/recall-planner.js +109 -0
- package/dist/vascend/requirements.d.ts +31 -0
- package/dist/vascend/requirements.js +151 -0
- package/dist/vascend/reviewer.d.ts +9 -0
- package/dist/vascend/reviewer.js +93 -0
- package/dist/vascend/room-graph.d.ts +29 -0
- package/dist/vascend/room-graph.js +242 -0
- package/dist/vascend/room-memory.d.ts +57 -0
- package/dist/vascend/room-memory.js +631 -0
- package/dist/vascend/runtime.d.ts +84 -0
- package/dist/vascend/runtime.js +286 -0
- package/dist/vascend/self-improve.d.ts +104 -0
- package/dist/vascend/self-improve.js +396 -0
- package/dist/vascend/session-search.d.ts +52 -0
- package/dist/vascend/session-search.js +349 -0
- package/dist/vascend/supersession-graph.d.ts +14 -0
- package/dist/vascend/supersession-graph.js +70 -0
- package/dist/vascend/team-areas.d.ts +9 -0
- package/dist/vascend/team-areas.js +28 -0
- package/dist/vascend/team-handoff.d.ts +24 -0
- package/dist/vascend/team-handoff.js +37 -0
- package/dist/vascend/team-scheduler.d.ts +13 -0
- package/dist/vascend/team-scheduler.js +74 -0
- package/dist/vascend/team-session.d.ts +42 -0
- package/dist/vascend/team-session.js +142 -0
- package/dist/vascend/test-failure-memory.d.ts +76 -0
- package/dist/vascend/test-failure-memory.js +354 -0
- package/dist/vascend/token-market.d.ts +42 -0
- package/dist/vascend/token-market.js +144 -0
- package/dist/vascend/tuner-baseline-store.d.ts +52 -0
- package/dist/vascend/tuner-baseline-store.js +446 -0
- package/dist/vascend/user-profile.d.ts +44 -0
- package/dist/vascend/user-profile.js +131 -0
- package/dist/vascend/vision.d.ts +94 -0
- package/dist/vascend/vision.js +375 -0
- package/dist/vascend/work-agent.d.ts +12 -0
- package/dist/vascend/work-agent.js +83 -0
- package/dist/vascend/work-queue.d.ts +62 -0
- package/dist/vascend/work-queue.js +255 -0
- package/dist/vascend/work-runner.d.ts +64 -0
- package/dist/vascend/work-runner.js +137 -0
- package/dist/vascend/worktree.d.ts +38 -0
- package/dist/vascend/worktree.js +206 -0
- package/dist/vendor/computer-use/README.md +7 -0
- package/dist/vendor/computer-use/computer-desktop.js +211 -0
- package/dist/vendor/computer-use/computer-observe.js +315 -0
- package/dist/vendor/computer-use/computer-scripts.js +1230 -0
- package/dist/vendor/computer-use/computer-tools.js +2136 -0
- package/dist/vendor/computer-use/package.json +1 -0
- package/dist/vendor/computer-use/rac/atomic-input.js +91 -0
- package/dist/vendor/computer-use/rac/grammatica.js +101 -0
- package/dist/vendor/computer-use/rac/parser.js +185 -0
- package/dist/vendor/computer-use/rac/protocol.js +136 -0
- package/install.ps1 +30 -0
- package/install.sh +50 -0
- package/package.json +56 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Bm25Params, type IndexedDoc, type ScoredDoc, type WeightedTerm } from "./lexical-search.js";
|
|
2
|
+
/** Immutable index versions share unchanged documents and posting lists. */
|
|
3
|
+
export declare class LexicalIndex<T> {
|
|
4
|
+
private readonly documents;
|
|
5
|
+
private readonly postings;
|
|
6
|
+
private readonly tokenCount;
|
|
7
|
+
private readonly fuzzy;
|
|
8
|
+
constructor(docs: readonly IndexedDoc<T>[], key: (ref: T) => string, previous?: LexicalIndex<T>);
|
|
9
|
+
score(query: readonly WeightedTerm[], params?: Bm25Params): readonly ScoredDoc<T>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { DEFAULT_BM25, fuzzyMatch } from "./lexical-search.js";
|
|
2
|
+
/** Immutable index versions share unchanged documents and posting lists. */
|
|
3
|
+
export class LexicalIndex {
|
|
4
|
+
documents;
|
|
5
|
+
postings;
|
|
6
|
+
tokenCount;
|
|
7
|
+
fuzzy = new Map();
|
|
8
|
+
constructor(docs, key, previous) {
|
|
9
|
+
const documents = new Map();
|
|
10
|
+
const postings = new Map(previous?.postings);
|
|
11
|
+
const changed = new Map();
|
|
12
|
+
let tokenCount = previous?.tokenCount ?? 0;
|
|
13
|
+
const editPosting = (term) => {
|
|
14
|
+
let posting = changed.get(term);
|
|
15
|
+
if (!posting) {
|
|
16
|
+
posting = new Map(postings.get(term));
|
|
17
|
+
changed.set(term, posting);
|
|
18
|
+
}
|
|
19
|
+
return posting;
|
|
20
|
+
};
|
|
21
|
+
const remove = (id, doc) => {
|
|
22
|
+
for (const term of doc.tf.keys())
|
|
23
|
+
editPosting(term).delete(id);
|
|
24
|
+
tokenCount -= doc.tokens.length;
|
|
25
|
+
};
|
|
26
|
+
for (const doc of docs) {
|
|
27
|
+
const id = key(doc.ref);
|
|
28
|
+
const old = previous?.documents.get(id);
|
|
29
|
+
if (old?.tokens === doc.tokens) {
|
|
30
|
+
documents.set(id, { ...old, ref: doc.ref });
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (old)
|
|
34
|
+
remove(id, old);
|
|
35
|
+
const tf = new Map();
|
|
36
|
+
for (const [position, term] of doc.tokens.entries()) {
|
|
37
|
+
const oldTerm = tf.get(term);
|
|
38
|
+
tf.set(term, { count: (oldTerm?.count ?? 0) + 1, position: oldTerm?.position ?? position });
|
|
39
|
+
}
|
|
40
|
+
for (const [term, posting] of tf)
|
|
41
|
+
editPosting(term).set(id, posting);
|
|
42
|
+
tokenCount += doc.tokens.length;
|
|
43
|
+
documents.set(id, { ...doc, tf });
|
|
44
|
+
}
|
|
45
|
+
for (const [id, doc] of previous?.documents ?? [])
|
|
46
|
+
if (!documents.has(id))
|
|
47
|
+
remove(id, doc);
|
|
48
|
+
for (const [term, posting] of changed) {
|
|
49
|
+
if (posting.size)
|
|
50
|
+
postings.set(term, posting);
|
|
51
|
+
else
|
|
52
|
+
postings.delete(term);
|
|
53
|
+
}
|
|
54
|
+
this.documents = documents;
|
|
55
|
+
this.postings = postings;
|
|
56
|
+
this.tokenCount = tokenCount;
|
|
57
|
+
}
|
|
58
|
+
score(query, params = DEFAULT_BM25) {
|
|
59
|
+
const n = this.documents.size || 1;
|
|
60
|
+
const avgdl = this.tokenCount / n || 1;
|
|
61
|
+
const scores = new Map();
|
|
62
|
+
const idf = (term) => {
|
|
63
|
+
const df = this.postings.get(term)?.size ?? 0;
|
|
64
|
+
return Math.log(1 + (n - df + 0.5) / (df + 0.5));
|
|
65
|
+
};
|
|
66
|
+
const add = (id, posting, weight, term) => {
|
|
67
|
+
const doc = this.documents.get(id);
|
|
68
|
+
const norm = params.k1 * (1 - params.b + params.b * ((doc.tokens.length || 1) / avgdl));
|
|
69
|
+
const tfNorm = posting.count * (params.k1 + 1) / (posting.count + norm);
|
|
70
|
+
const contribution = weight * idf(term) * tfNorm;
|
|
71
|
+
scores.set(id, (scores.get(id) ?? 0) + contribution);
|
|
72
|
+
};
|
|
73
|
+
for (const { term, weight } of query) {
|
|
74
|
+
const exact = this.postings.get(term);
|
|
75
|
+
for (const [id, posting] of exact ?? [])
|
|
76
|
+
add(id, posting, weight, term);
|
|
77
|
+
let similar = this.fuzzy.get(term);
|
|
78
|
+
if (!similar) {
|
|
79
|
+
similar = [...this.postings.keys()].filter((word) => word !== term && fuzzyMatch(term, word));
|
|
80
|
+
if (this.fuzzy.size >= 256)
|
|
81
|
+
this.fuzzy.delete(this.fuzzy.keys().next().value);
|
|
82
|
+
this.fuzzy.set(term, similar);
|
|
83
|
+
}
|
|
84
|
+
const best = new Map();
|
|
85
|
+
for (const word of similar)
|
|
86
|
+
for (const [id, posting] of this.postings.get(word) ?? []) {
|
|
87
|
+
if (exact?.has(id))
|
|
88
|
+
continue;
|
|
89
|
+
const old = best.get(id);
|
|
90
|
+
if (!old || posting.count > old.count || posting.count === old.count && posting.position < old.position) {
|
|
91
|
+
best.set(id, { ...posting, term: word });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const [id, posting] of best)
|
|
95
|
+
add(id, posting, weight * params.fuzzyWeight, posting.term);
|
|
96
|
+
}
|
|
97
|
+
return [...this.documents].map(([id, doc]) => ({ ref: doc.ref, score: scores.get(id) ?? 0 }));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare function foldAccents(s: string): string;
|
|
2
|
+
export declare function stem(token: string): string;
|
|
3
|
+
export declare function normalizeToken(token: string): string;
|
|
4
|
+
export declare const DEFAULT_SYNONYMS: readonly (readonly string[])[];
|
|
5
|
+
export type SynonymIndex = ReadonlyMap<string, readonly string[]>;
|
|
6
|
+
export declare function buildSynonyms(groups?: readonly (readonly string[])[]): SynonymIndex;
|
|
7
|
+
export interface WeightedTerm {
|
|
8
|
+
readonly term: string;
|
|
9
|
+
readonly weight: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function expandQuery(tokens: readonly string[], synonyms: SynonymIndex, synonymWeight?: number): readonly WeightedTerm[];
|
|
12
|
+
export declare const STOP: ReadonlySet<string>;
|
|
13
|
+
export declare function tokenize(s: string): string[];
|
|
14
|
+
export interface Bm25Params {
|
|
15
|
+
readonly k1: number;
|
|
16
|
+
readonly b: number;
|
|
17
|
+
readonly fuzzyWeight: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_BM25: Bm25Params;
|
|
20
|
+
export interface IndexedDoc<T> {
|
|
21
|
+
readonly ref: T;
|
|
22
|
+
readonly tokens: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
export interface ScoredDoc<T> {
|
|
25
|
+
readonly ref: T;
|
|
26
|
+
readonly score: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function fuzzyMatch(q: string, t: string): boolean;
|
|
29
|
+
export declare function bm25Score<T>(docs: readonly IndexedDoc<T>[], query: readonly WeightedTerm[], params?: Bm25Params): readonly ScoredDoc<T>[];
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// Motore di ricerca LESSICALE deterministico (BM25-lite) per la memoria stanze.
|
|
2
|
+
//
|
|
3
|
+
// Filosofia: nessun embedding semantico, nessuna dipendenza a runtime, output
|
|
4
|
+
// ripetibile. Aumenta il RICHIAMO su query con parole non perfettamente
|
|
5
|
+
// coincidenti tramite:
|
|
6
|
+
// 1) normalizzazione testuale -> fold accenti + stemming leggero IT/EN
|
|
7
|
+
// 2) espansione sinonimi -> tabella bidirezionale configurabile
|
|
8
|
+
// 3) scoring BM25 vero -> k1/b con normalizzazione per lunghezza doc
|
|
9
|
+
// + prefix/fuzzy match per termini quasi coincidenti
|
|
10
|
+
//
|
|
11
|
+
// Tutto e' puro e testabile in isolamento: room-memory.ts lo richiama per
|
|
12
|
+
// tokenize/score senza cambiare la sua API pubblica.
|
|
13
|
+
// --- normalizzazione testuale ----------------------------------------------
|
|
14
|
+
// Mappa di folding per i caratteri accentati/diacritici piu' comuni in IT/EN
|
|
15
|
+
// e lingue vicine. Deterministica e senza dipendenze (no Intl/normalize NFD
|
|
16
|
+
// per restare prevedibili su ogni runtime).
|
|
17
|
+
const FOLD = {
|
|
18
|
+
à: "a", á: "a", â: "a", ã: "a", ä: "a", å: "a", ā: "a", ă: "a",
|
|
19
|
+
è: "e", é: "e", ê: "e", ë: "e", ē: "e", ĕ: "e", ė: "e", ę: "e",
|
|
20
|
+
ì: "i", í: "i", î: "i", ï: "i", ī: "i", ĭ: "i",
|
|
21
|
+
ò: "o", ó: "o", ô: "o", õ: "o", ö: "o", ø: "o", ō: "o", ŏ: "o",
|
|
22
|
+
ù: "u", ú: "u", û: "u", ü: "u", ū: "u", ŭ: "u",
|
|
23
|
+
ç: "c", ñ: "n", ý: "y", ÿ: "y", ß: "ss",
|
|
24
|
+
};
|
|
25
|
+
// Abbatte gli accenti su una stringa (case gia' lower). Deterministico.
|
|
26
|
+
export function foldAccents(s) {
|
|
27
|
+
let out = "";
|
|
28
|
+
for (const ch of s)
|
|
29
|
+
out += FOLD[ch] ?? ch;
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
// Suffissi IT/EN rimossi in ordine di lunghezza decrescente: stemming LEGGERO
|
|
33
|
+
// (non un Porter completo). Obiettivo: far collassare le forme flesse comuni
|
|
34
|
+
// ("fatturazione"->"fattur", "calcoli"->"calcol") senza sovra-aggregare.
|
|
35
|
+
const SUFFIXES_IT = [
|
|
36
|
+
"azioni", "azione", "amento", "amenti", "imento", "imenti",
|
|
37
|
+
"zione", "zioni", "mente", "abile", "ibile", "anza", "enza",
|
|
38
|
+
"issimo", "issima",
|
|
39
|
+
"ando", "endo", "are", "ere", "ire", "ato", "ata", "ati", "ate",
|
|
40
|
+
"uto", "uta", "uti", "ute", "ito", "ita", "iti", "ite",
|
|
41
|
+
"ire", "ico", "ica", "ici", "iche", "oso", "osa", "osi", "ose",
|
|
42
|
+
];
|
|
43
|
+
const SUFFIXES_EN = [
|
|
44
|
+
"ization", "isation", "ational", "fulness", "ousness", "iveness",
|
|
45
|
+
"tion", "sion", "ment", "ness", "able", "ible", "ing", "edly",
|
|
46
|
+
"ies", "ied", "ous", "ive", "ize", "ise", "er", "ed", "ly", "es", "s",
|
|
47
|
+
];
|
|
48
|
+
// Lunghezza minima della RADICE dopo lo stemming: evita di ridurre parole
|
|
49
|
+
// gia' corte a frammenti inutili (es. non toccare "are" -> "").
|
|
50
|
+
const MIN_STEM = 4;
|
|
51
|
+
// Stemming leggero deterministico: prova i suffissi piu' lunghi prima, IT poi
|
|
52
|
+
// EN, e taglia solo se resta una radice >= MIN_STEM.
|
|
53
|
+
export function stem(token) {
|
|
54
|
+
let t = token;
|
|
55
|
+
// I token con separatori (path, kebab) non vanno stemmati: sono identificatori.
|
|
56
|
+
if (/[._/-]/.test(t))
|
|
57
|
+
return t;
|
|
58
|
+
for (const suf of SUFFIXES_IT) {
|
|
59
|
+
if (t.length - suf.length >= MIN_STEM && t.endsWith(suf))
|
|
60
|
+
return t.slice(0, -suf.length);
|
|
61
|
+
}
|
|
62
|
+
for (const suf of SUFFIXES_EN) {
|
|
63
|
+
if (t.length - suf.length >= MIN_STEM && t.endsWith(suf))
|
|
64
|
+
return t.slice(0, -suf.length);
|
|
65
|
+
}
|
|
66
|
+
return t;
|
|
67
|
+
}
|
|
68
|
+
// Normalizza un singolo token: lower + fold accenti + stem. Esposto per i test.
|
|
69
|
+
export function normalizeToken(token) {
|
|
70
|
+
return stem(foldAccents(token.toLowerCase()));
|
|
71
|
+
}
|
|
72
|
+
// --- sinonimi configurabili -------------------------------------------------
|
|
73
|
+
// Gruppi di sinonimi: ogni gruppo e' un insieme di termini equivalenti per la
|
|
74
|
+
// ricerca. La tabella d'espansione e' BIDIREZIONALE (ogni termine del gruppo
|
|
75
|
+
// espande a tutti gli altri). I termini sono gia' normalizzati (stem+fold) per
|
|
76
|
+
// allinearsi al matching. Configurabile: passa gruppi extra a buildSynonyms.
|
|
77
|
+
//
|
|
78
|
+
// Pensati per il dominio coding/Danilov in IT/EN cosi' una query in una lingua
|
|
79
|
+
// trova stanze nell'altra ("file"<->"documento", "errore"<->"bug").
|
|
80
|
+
export const DEFAULT_SYNONYMS = [
|
|
81
|
+
["file", "documento", "doc"],
|
|
82
|
+
["errore", "error", "bug", "difetto", "guasto"],
|
|
83
|
+
["correggi", "fix", "ripara", "sistema", "risolvi"],
|
|
84
|
+
["test", "prova", "verifica", "collaudo"],
|
|
85
|
+
["funzione", "function", "metodo", "method"],
|
|
86
|
+
["cancella", "elimina", "rimuovi", "delete", "remove"],
|
|
87
|
+
["aggiungi", "inserisci", "add", "insert"],
|
|
88
|
+
["cerca", "ricerca", "search", "trova", "find"],
|
|
89
|
+
["memoria", "memory", "ricordo", "recall"],
|
|
90
|
+
["stanza", "room", "castello", "castle"],
|
|
91
|
+
["calcolo", "calcola", "computa", "compute", "conteggio"],
|
|
92
|
+
["magazzino", "giacenza", "inventario", "inventory", "scorta"],
|
|
93
|
+
["fattura", "fatturazione", "invoice", "billing"],
|
|
94
|
+
["utente", "user", "account", "profilo"],
|
|
95
|
+
["configura", "configurazione", "config", "imposta", "setting"],
|
|
96
|
+
["server", "backend", "servizio", "service"],
|
|
97
|
+
["pagina", "page", "schermata", "view", "vista"],
|
|
98
|
+
];
|
|
99
|
+
export function buildSynonyms(groups = DEFAULT_SYNONYMS) {
|
|
100
|
+
const idx = new Map();
|
|
101
|
+
for (const group of groups) {
|
|
102
|
+
const norm = [...new Set(group.map((t) => normalizeToken(t)).filter(Boolean))];
|
|
103
|
+
for (const term of norm) {
|
|
104
|
+
const set = idx.get(term) ?? new Set();
|
|
105
|
+
for (const other of norm)
|
|
106
|
+
if (other !== term)
|
|
107
|
+
set.add(other);
|
|
108
|
+
idx.set(term, set);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Congela in array ordinati (determinismo dell'output).
|
|
112
|
+
const out = new Map();
|
|
113
|
+
for (const [k, v] of idx)
|
|
114
|
+
out.set(k, [...v].sort());
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
export function expandQuery(tokens, synonyms, synonymWeight = 0.6) {
|
|
118
|
+
const weight = new Map();
|
|
119
|
+
const bump = (t, w) => {
|
|
120
|
+
if (!t)
|
|
121
|
+
return;
|
|
122
|
+
weight.set(t, Math.max(weight.get(t) ?? 0, w));
|
|
123
|
+
};
|
|
124
|
+
for (const tok of tokens) {
|
|
125
|
+
bump(tok, 1);
|
|
126
|
+
for (const syn of synonyms.get(tok) ?? [])
|
|
127
|
+
bump(syn, synonymWeight);
|
|
128
|
+
}
|
|
129
|
+
return [...weight.entries()]
|
|
130
|
+
.map(([term, w]) => ({ term, weight: w }))
|
|
131
|
+
.sort((a, b) => (b.weight - a.weight) || a.term.localeCompare(b.term));
|
|
132
|
+
}
|
|
133
|
+
// --- tokenizzazione ---------------------------------------------------------
|
|
134
|
+
// Stop-word IT/EN: rumore per l'indice lessicale. Condivisa col formato dei
|
|
135
|
+
// record (room-memory importa STOP da qui per restare allineato).
|
|
136
|
+
export const STOP = new Set([
|
|
137
|
+
// EN
|
|
138
|
+
"the", "and", "for", "this", "that", "with", "from", "into", "you", "are",
|
|
139
|
+
// IT articoli/preposizioni/congiunzioni comuni (rumore per l'INDICE)
|
|
140
|
+
"il", "lo", "la", "le", "gli", "un", "uno", "una", "di", "da", "in", "su",
|
|
141
|
+
"al", "allo", "alla", "ai", "agli", "alle", "del", "dello", "della", "dei",
|
|
142
|
+
"degli", "delle", "nel", "nella", "che", "con", "per", "non", "ed", "tra",
|
|
143
|
+
"fra", "come", "piu", "gia", "poi", "anche", "ogni", "questo", "questa",
|
|
144
|
+
// IT verbi/filler ricorrenti nei prompt (azione generica, non concetto)
|
|
145
|
+
"crea", "creare", "fai", "fare", "usa", "usare", "usando", "aggiungi",
|
|
146
|
+
"aggiungere", "elenca", "elencare", "leggi", "leggere", "scrivi", "scrivere",
|
|
147
|
+
"modifica", "modificare", "chiamato", "chiamata", "dentro", "parola", "parole",
|
|
148
|
+
"strumento", "niente", "prosa", "quindi", "vuoi", "deve", "essere",
|
|
149
|
+
// troncamenti di preposizioni articolate apostrofate (dell', all', nell', ...)
|
|
150
|
+
"dell", "all", "nell", "sull", "dall", "quell", "un'",
|
|
151
|
+
]);
|
|
152
|
+
// Tokenizza GREZZO: lower + estrazione lessemi, senza normalizzazione. Mantiene
|
|
153
|
+
// la stessa classe di caratteri del tokenizer storico (path, kebab, numeri).
|
|
154
|
+
function rawTokens(s) {
|
|
155
|
+
return s.toLowerCase().match(/[a-z0-9_./-]{2,}/g) ?? [];
|
|
156
|
+
}
|
|
157
|
+
// Tokenizza per l'INDICE/ricerca: grezzo -> filtro STOP (sulla forma foldata)
|
|
158
|
+
// -> normalizzazione (fold + stem). Lo STOP-check usa la forma foldata cosi'
|
|
159
|
+
// "piu'"/"piu" e "gia"/"già" vengono filtrati comunque.
|
|
160
|
+
export function tokenize(s) {
|
|
161
|
+
const out = [];
|
|
162
|
+
for (const raw of rawTokens(s)) {
|
|
163
|
+
const folded = foldAccents(raw);
|
|
164
|
+
if (STOP.has(folded))
|
|
165
|
+
continue;
|
|
166
|
+
const norm = stem(folded);
|
|
167
|
+
if (norm.length >= 2)
|
|
168
|
+
out.push(norm);
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
export const DEFAULT_BM25 = { k1: 1.5, b: 0.75, fuzzyWeight: 0.45 };
|
|
173
|
+
// Distanza di edit limitata (Levenshtein con cutoff): determina se due token
|
|
174
|
+
// "quasi coincidono". Cutoff piccolo -> deterministico ed economico.
|
|
175
|
+
function withinEditDistance(a, b, max) {
|
|
176
|
+
if (a === b)
|
|
177
|
+
return true;
|
|
178
|
+
const la = a.length;
|
|
179
|
+
const lb = b.length;
|
|
180
|
+
if (Math.abs(la - lb) > max)
|
|
181
|
+
return false;
|
|
182
|
+
// DP a una riga.
|
|
183
|
+
let prev = Array.from({ length: lb + 1 }, (_, j) => j);
|
|
184
|
+
for (let i = 1; i <= la; i += 1) {
|
|
185
|
+
const curr = [i];
|
|
186
|
+
let rowMin = i;
|
|
187
|
+
for (let j = 1; j <= lb; j += 1) {
|
|
188
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
189
|
+
const v = Math.min((prev[j] ?? 0) + 1, (curr[j - 1] ?? 0) + 1, (prev[j - 1] ?? 0) + cost);
|
|
190
|
+
curr[j] = v;
|
|
191
|
+
if (v < rowMin)
|
|
192
|
+
rowMin = v;
|
|
193
|
+
}
|
|
194
|
+
if (rowMin > max)
|
|
195
|
+
return false; // early exit: nessuna cella sotto soglia
|
|
196
|
+
prev = curr;
|
|
197
|
+
}
|
|
198
|
+
return (prev[lb] ?? Infinity) <= max;
|
|
199
|
+
}
|
|
200
|
+
// Decide se un token di query "matcha fuzzy" un token di documento: prefisso
|
|
201
|
+
// (uno e' prefisso dell'altro, len>=4) oppure edit-distance 1 per token >=5.
|
|
202
|
+
// Pensato per termini quasi coincidenti (refusi, plurali sfuggiti allo stem).
|
|
203
|
+
export function fuzzyMatch(q, t) {
|
|
204
|
+
if (q.length >= 4 && (t.startsWith(q) || q.startsWith(t)))
|
|
205
|
+
return true;
|
|
206
|
+
if (Math.min(q.length, t.length) >= 5)
|
|
207
|
+
return withinEditDistance(q, t, 1);
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
// BM25 deterministico su documenti pre-tokenizzati e query pesata (sinonimi).
|
|
211
|
+
// Per ogni termine di query: match ESATTO a peso pieno; in assenza, il miglior
|
|
212
|
+
// match FUZZY a peso ridotto (fuzzyWeight). idf clampato a >= 0.
|
|
213
|
+
export function bm25Score(docs, query, params = DEFAULT_BM25) {
|
|
214
|
+
const n = docs.length || 1;
|
|
215
|
+
const { k1, b, fuzzyWeight } = params;
|
|
216
|
+
// df e avgdl in un passo.
|
|
217
|
+
const df = new Map();
|
|
218
|
+
let totalLen = 0;
|
|
219
|
+
const tfs = docs.map((d) => {
|
|
220
|
+
const tf = new Map();
|
|
221
|
+
for (const t of d.tokens)
|
|
222
|
+
tf.set(t, (tf.get(t) ?? 0) + 1);
|
|
223
|
+
for (const t of tf.keys())
|
|
224
|
+
df.set(t, (df.get(t) ?? 0) + 1);
|
|
225
|
+
totalLen += d.tokens.length;
|
|
226
|
+
return tf;
|
|
227
|
+
});
|
|
228
|
+
const avgdl = totalLen / n || 1;
|
|
229
|
+
// idf "lite" non-negativo: BM25 con +1 dentro il log per evitare valori <0.
|
|
230
|
+
const idf = (term) => Math.log(1 + (n - (df.get(term) ?? 0) + 0.5) / ((df.get(term) ?? 0) + 0.5));
|
|
231
|
+
const out = docs.map((d, i) => {
|
|
232
|
+
const tf = tfs[i];
|
|
233
|
+
const dl = d.tokens.length || 1;
|
|
234
|
+
const norm = k1 * (1 - b + b * (dl / avgdl));
|
|
235
|
+
let score = 0;
|
|
236
|
+
for (const { term, weight } of query) {
|
|
237
|
+
let f = tf.get(term) ?? 0;
|
|
238
|
+
let qIdf = idf(term);
|
|
239
|
+
let effWeight = weight;
|
|
240
|
+
if (!f) {
|
|
241
|
+
// Nessun match esatto: cerca il miglior match fuzzy nel documento.
|
|
242
|
+
let bestF = 0;
|
|
243
|
+
let bestTerm = "";
|
|
244
|
+
for (const [docTerm, count] of tf) {
|
|
245
|
+
if (fuzzyMatch(term, docTerm) && count > bestF) {
|
|
246
|
+
bestF = count;
|
|
247
|
+
bestTerm = docTerm;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (!bestF)
|
|
251
|
+
continue;
|
|
252
|
+
f = bestF;
|
|
253
|
+
qIdf = idf(bestTerm);
|
|
254
|
+
effWeight = weight * fuzzyWeight;
|
|
255
|
+
}
|
|
256
|
+
const tfNorm = (f * (k1 + 1)) / (f + norm);
|
|
257
|
+
score += effWeight * qIdf * tfNorm;
|
|
258
|
+
}
|
|
259
|
+
return { ref: d.ref, score };
|
|
260
|
+
});
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface VisionFeatureLike {
|
|
2
|
+
readonly title?: string;
|
|
3
|
+
readonly text?: string;
|
|
4
|
+
readonly priority?: "core" | "important" | "optional" | "must" | "should" | "could" | string;
|
|
5
|
+
readonly status?: "proposed" | "agreed" | "built" | "dropped" | string;
|
|
6
|
+
readonly done?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface VisionValueLike {
|
|
9
|
+
readonly statement?: string;
|
|
10
|
+
readonly beneficiary?: string;
|
|
11
|
+
readonly metric?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface VisionAssetRefLike {
|
|
14
|
+
readonly id?: string;
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
readonly kind?: "image" | "file" | "snippet" | string;
|
|
17
|
+
}
|
|
18
|
+
export interface VisionLike {
|
|
19
|
+
readonly id?: string;
|
|
20
|
+
readonly taskId?: string;
|
|
21
|
+
readonly goal?: string;
|
|
22
|
+
readonly finalGoal?: string;
|
|
23
|
+
readonly objective?: string;
|
|
24
|
+
readonly value?: string | VisionValueLike;
|
|
25
|
+
readonly features?: readonly (string | VisionFeatureLike)[];
|
|
26
|
+
readonly constraints?: readonly string[];
|
|
27
|
+
readonly nonGoals?: readonly string[];
|
|
28
|
+
readonly assets?: readonly VisionAssetRefLike[];
|
|
29
|
+
readonly notes?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
export interface NormalizedVision {
|
|
32
|
+
readonly finalGoal: string;
|
|
33
|
+
readonly value: string;
|
|
34
|
+
readonly features: readonly string[];
|
|
35
|
+
readonly constraints: readonly string[];
|
|
36
|
+
readonly assets: readonly string[];
|
|
37
|
+
readonly notes: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
export declare function visionHasContent(v: NormalizedVision): boolean;
|
|
40
|
+
export declare function normalizeVision(vision: VisionLike | null | undefined): NormalizedVision;
|
|
41
|
+
export interface ImmediateContext {
|
|
42
|
+
readonly goal?: string;
|
|
43
|
+
readonly castle?: string;
|
|
44
|
+
readonly room?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface LongTermContextInput {
|
|
47
|
+
readonly vision?: VisionLike | null;
|
|
48
|
+
readonly immediate?: ImmediateContext;
|
|
49
|
+
}
|
|
50
|
+
export declare function buildLongTermContextBlock(input: LongTermContextInput): string;
|
|
51
|
+
export declare function injectLongTermContext(prompt: string, input: LongTermContextInput): string;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Provider di CONTESTO A LUNGO TERMINE (metodo Danilov).
|
|
2
|
+
//
|
|
3
|
+
// Inietta nei prompt la VISION finale di un task -- l'obiettivo ultimo, il
|
|
4
|
+
// valore atteso, le funzionalita' desiderate -- tenendola SEPARATA dagli
|
|
5
|
+
// obiettivi IMMEDIATI di stanze e castelli. La distinzione e' il cuore di
|
|
6
|
+
// questo modulo:
|
|
7
|
+
//
|
|
8
|
+
// - GOAL IMMEDIATO (momentaneo): cosa si sta facendo adesso, nella stanza o
|
|
9
|
+
// nel castello corrente. E' volatile, cambia a ogni passo.
|
|
10
|
+
// - VISION FINALE (a lungo termine): perche' lo si sta facendo, dove si vuole
|
|
11
|
+
// arrivare. E' stabile, sopravvive ai singoli passi e li orienta.
|
|
12
|
+
//
|
|
13
|
+
// Il provider produce un BLOCCO di contesto in notazione Danilov che il
|
|
14
|
+
// wrapper di prompt antepone all'input, marcando chiaramente i due piani cosi'
|
|
15
|
+
// che il modello non confonda il "qui e ora" con la "stella polare".
|
|
16
|
+
//
|
|
17
|
+
// Modulo PURO: nessun side-effect, nessuna dipendenza rigida. La forma dati
|
|
18
|
+
// Vision e' consumata STRUTTURALMENTE (duck-typed) tramite VisionLike, in modo
|
|
19
|
+
// da non dipendere dal modulo vision-schema finche' non e' mergiato; quando lo
|
|
20
|
+
// sara', VisionLike combaciera' (per struttura) con il tipo Vision reale.
|
|
21
|
+
import { sanitizeText } from "../core/text-sanitize.js";
|
|
22
|
+
// Vera se la Vision normalizzata porta almeno un'informazione utile.
|
|
23
|
+
export function visionHasContent(v) {
|
|
24
|
+
return Boolean(v.finalGoal ||
|
|
25
|
+
v.value ||
|
|
26
|
+
v.features.length ||
|
|
27
|
+
v.constraints.length ||
|
|
28
|
+
v.assets.length ||
|
|
29
|
+
v.notes.length);
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Normalizzazioni difensive.
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
function oneLine(value) {
|
|
35
|
+
return sanitizeText(value).replace(/\s+/g, " ").trim();
|
|
36
|
+
}
|
|
37
|
+
function escapeValue(value) {
|
|
38
|
+
return oneLine(value).replace(/"/g, "'");
|
|
39
|
+
}
|
|
40
|
+
function clip(value, max) {
|
|
41
|
+
const s = oneLine(value);
|
|
42
|
+
return s.length > max ? s.slice(0, max - 1).trimEnd() + "…" : s;
|
|
43
|
+
}
|
|
44
|
+
function firstNonEmpty(...vals) {
|
|
45
|
+
for (const v of vals) {
|
|
46
|
+
const t = (v ?? "").trim();
|
|
47
|
+
if (t)
|
|
48
|
+
return t;
|
|
49
|
+
}
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
const KNOWN_PRIORITIES = new Set(["core", "important", "optional", "must", "should", "could"]);
|
|
53
|
+
function featureText(f) {
|
|
54
|
+
if (typeof f === "string")
|
|
55
|
+
return oneLine(f);
|
|
56
|
+
// status 'dropped' = funzionalita' scartata: non fa parte della visione.
|
|
57
|
+
const status = (f.status ?? "").trim().toLowerCase();
|
|
58
|
+
if (status === "dropped")
|
|
59
|
+
return "";
|
|
60
|
+
const text = oneLine(f.title ?? f.text ?? "");
|
|
61
|
+
if (!text)
|
|
62
|
+
return "";
|
|
63
|
+
const pr = (f.priority ?? "").trim().toLowerCase();
|
|
64
|
+
const tag = KNOWN_PRIORITIES.has(pr) ? ` (${pr})` : "";
|
|
65
|
+
const built = f.done || status === "built" ? " [fatto]" : "";
|
|
66
|
+
return `${text}${tag}${built}`;
|
|
67
|
+
}
|
|
68
|
+
// Estrae il testo del valore atteso da stringa o VisionValue {statement,...}.
|
|
69
|
+
function valueText(value) {
|
|
70
|
+
if (!value)
|
|
71
|
+
return "";
|
|
72
|
+
if (typeof value === "string")
|
|
73
|
+
return oneLine(value);
|
|
74
|
+
const stmt = oneLine(value.statement ?? "");
|
|
75
|
+
const extra = [];
|
|
76
|
+
if (value.beneficiary)
|
|
77
|
+
extra.push(`per ${oneLine(value.beneficiary)}`);
|
|
78
|
+
if (value.metric)
|
|
79
|
+
extra.push(`metrica: ${oneLine(value.metric)}`);
|
|
80
|
+
if (!stmt)
|
|
81
|
+
return extra.join(", ");
|
|
82
|
+
return extra.length ? `${stmt} (${extra.join(", ")})` : stmt;
|
|
83
|
+
}
|
|
84
|
+
function assetText(a) {
|
|
85
|
+
const name = oneLine(a.name ?? a.id ?? "");
|
|
86
|
+
if (!name)
|
|
87
|
+
return "";
|
|
88
|
+
const kind = (a.kind ?? "").trim();
|
|
89
|
+
return kind ? `${name} (${kind})` : name;
|
|
90
|
+
}
|
|
91
|
+
function cleanList(items, max) {
|
|
92
|
+
if (!items)
|
|
93
|
+
return [];
|
|
94
|
+
const out = [];
|
|
95
|
+
const seen = new Set();
|
|
96
|
+
for (const raw of items) {
|
|
97
|
+
const t = oneLine(raw);
|
|
98
|
+
if (!t)
|
|
99
|
+
continue;
|
|
100
|
+
const key = t.toLowerCase();
|
|
101
|
+
if (seen.has(key))
|
|
102
|
+
continue;
|
|
103
|
+
seen.add(key);
|
|
104
|
+
out.push(t);
|
|
105
|
+
if (out.length >= max)
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
// Normalizza una VisionLike (o assente) nella vista interna pulita.
|
|
111
|
+
export function normalizeVision(vision) {
|
|
112
|
+
if (!vision) {
|
|
113
|
+
return { finalGoal: "", value: "", features: [], constraints: [], assets: [], notes: [] };
|
|
114
|
+
}
|
|
115
|
+
const finalGoal = clip(firstNonEmpty(vision.goal, vision.finalGoal, vision.objective), 240);
|
|
116
|
+
const value = clip(valueText(vision.value), 240);
|
|
117
|
+
const features = cleanList((vision.features ?? []).map(featureText), 8);
|
|
118
|
+
// constraints + nonGoals confluiscono nei "vincoli" (sono entrambi paletti).
|
|
119
|
+
const constraints = cleanList([...(vision.constraints ?? []), ...(vision.nonGoals ?? []).map((g) => `non-goal: ${g}`)], 6);
|
|
120
|
+
const assets = cleanList((vision.assets ?? []).map(assetText), 6);
|
|
121
|
+
const notes = cleanList(vision.notes ?? [], 4);
|
|
122
|
+
return { finalGoal, value, features, constraints, assets, notes };
|
|
123
|
+
}
|
|
124
|
+
// Costruisce il blocco. Ritorna stringa VUOTA se non c'e' Vision con contenuto:
|
|
125
|
+
// in tal caso il wrapper non aggiunge nulla (degrado con grazia, niente rumore).
|
|
126
|
+
export function buildLongTermContextBlock(input) {
|
|
127
|
+
const v = normalizeVision(input.vision);
|
|
128
|
+
if (!visionHasContent(v))
|
|
129
|
+
return "";
|
|
130
|
+
const imm = input.immediate ?? {};
|
|
131
|
+
const immGoal = clip(imm.goal ?? "", 200);
|
|
132
|
+
const immCastle = oneLine(imm.castle ?? "");
|
|
133
|
+
const immRoom = oneLine(imm.room ?? "");
|
|
134
|
+
const hasImmediate = Boolean(immGoal || immCastle || immRoom);
|
|
135
|
+
const lines = [];
|
|
136
|
+
lines.push("[VASCEND_VISION]");
|
|
137
|
+
lines.push("INDICE");
|
|
138
|
+
lines.push("1 = vision");
|
|
139
|
+
lines.push("2 = immediato");
|
|
140
|
+
lines.push("3 = separazione");
|
|
141
|
+
lines.push("");
|
|
142
|
+
lines.push("DEFINIZIONI");
|
|
143
|
+
// Piano 1: la VISION finale (a lungo termine).
|
|
144
|
+
lines.push(`@vision[finale]: stella_polare, stabile${v.finalGoal ? `, goal="${escapeValue(v.finalGoal)}"` : ""}`);
|
|
145
|
+
if (v.value)
|
|
146
|
+
lines.push(`@vision[valore]: "${escapeValue(v.value)}"`);
|
|
147
|
+
if (v.features.length) {
|
|
148
|
+
lines.push(`@vision[funzionalita]: ${v.features.map((f) => `"${escapeValue(f)}"`).join(", ")}`);
|
|
149
|
+
}
|
|
150
|
+
if (v.constraints.length) {
|
|
151
|
+
lines.push(`@vision[vincoli]: ${v.constraints.map((c) => `"${escapeValue(c)}"`).join(", ")}`);
|
|
152
|
+
}
|
|
153
|
+
if (v.assets.length) {
|
|
154
|
+
lines.push(`@vision[asset_esempio]: ${v.assets.map((a) => `"${escapeValue(a)}"`).join(", ")}`);
|
|
155
|
+
}
|
|
156
|
+
if (v.notes.length) {
|
|
157
|
+
lines.push(`@vision[note]: ${v.notes.map((n) => `"${escapeValue(n)}"`).join(", ")}`);
|
|
158
|
+
}
|
|
159
|
+
// Piano 2: il goal IMMEDIATO (momentaneo), esplicitamente distinto.
|
|
160
|
+
if (hasImmediate) {
|
|
161
|
+
const parts = ["momentaneo, volatile"];
|
|
162
|
+
if (immGoal)
|
|
163
|
+
parts.push(`goal="${escapeValue(immGoal)}"`);
|
|
164
|
+
if (immCastle)
|
|
165
|
+
parts.push(`gruppo="${escapeValue(immCastle)}"`);
|
|
166
|
+
if (immRoom)
|
|
167
|
+
parts.push(`attivita="${escapeValue(immRoom)}"`);
|
|
168
|
+
lines.push(`@immediato[corrente]: ${parts.join(", ")}`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
lines.push("@immediato[corrente]: momentaneo, volatile, valore=non_specificato");
|
|
172
|
+
}
|
|
173
|
+
lines.push("");
|
|
174
|
+
lines.push("RELAZIONI");
|
|
175
|
+
lines.push("@R1: @immediato[corrente] -> @vision[finale] [ il goal momentaneo SERVE la visione, non la sostituisce ]");
|
|
176
|
+
lines.push("@R2: @vision[finale] -> @immediato[corrente] [ la visione ORIENTA ogni passo, resta stabile mentre i goal cambiano ]");
|
|
177
|
+
lines.push("");
|
|
178
|
+
lines.push("OUTPUT: tieni la VISION finale come stella polare stabile e DISTINTA dal goal immediato; ogni decisione di attivita/gruppo deve avvicinare la visione senza confondersi con essa.");
|
|
179
|
+
return lines.join("\n");
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// Integrazione: antepone il blocco Vision a un prompt gia' costruito.
|
|
183
|
+
//
|
|
184
|
+
// Pensato per essere chiamato da wrapVascendPrompt (runtime.ts): riceve il
|
|
185
|
+
// prompt "immediato" gia' formato (GOAL momentaneo + INPUT_UTENTE) e gli
|
|
186
|
+
// premette, come piano separato, il contesto a lungo termine. Se non c'e'
|
|
187
|
+
// Vision con contenuto, ritorna il prompt invariato (nessun rumore).
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
export function injectLongTermContext(prompt, input) {
|
|
190
|
+
const block = buildLongTermContextBlock(input);
|
|
191
|
+
if (!block)
|
|
192
|
+
return prompt;
|
|
193
|
+
return `${block}\n\n${prompt}`;
|
|
194
|
+
}
|