@myrialabs/clopen 0.4.49 → 0.4.51
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 +2 -1
- package/backend/chat/attachments.test.ts +106 -17
- package/backend/chat/attachments.ts +131 -34
- package/backend/chat/background-wait.test.ts +28 -0
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/message-pages.test.ts +17 -0
- package/backend/chat/message-pages.ts +6 -2
- package/backend/chat/stream-manager.ts +114 -19
- package/backend/containers/actions.ts +22 -0
- package/backend/control/actions/projects.ts +93 -37
- package/backend/control/folders.test.ts +27 -2
- package/backend/control/index.ts +2 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
- package/backend/database/migrations/086_single_owner.ts +66 -73
- package/backend/database/migrations/088_create_messages_fts_map.ts +52 -0
- package/backend/database/migrations/089_add_memory_layout_tiles.ts +58 -0
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +25 -2
- package/backend/database/queries/graph-queries.ts +392 -135
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/message-fts.test.ts +120 -0
- package/backend/database/queries/message-queries.ts +45 -9
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +6 -2
- package/backend/database/queries/utils-queries.ts +3 -0
- package/backend/database/utils/migration-runner.test.ts +196 -0
- package/backend/database/utils/migration-runner.ts +61 -16
- package/backend/database/utils/seeder-runner.ts +22 -16
- package/backend/engine/adapters/claude/environment.ts +4 -0
- package/backend/engine/adapters/claude/input-gate.test.ts +59 -0
- package/backend/engine/adapters/claude/input-gate.ts +74 -0
- package/backend/engine/adapters/claude/message-converter.test.ts +16 -0
- package/backend/engine/adapters/claude/message-converter.ts +8 -0
- package/backend/engine/adapters/claude/stream.ts +20 -0
- package/backend/engine/adapters/cursor/environment.ts +1 -1
- package/backend/engine/adapters/qwen/session-store.ts +10 -1
- package/backend/engine/types.ts +7 -0
- package/backend/git/identity/cli.ts +35 -0
- package/backend/git/identity/env.test.ts +52 -1
- package/backend/git/identity/env.ts +69 -10
- package/backend/git/identity/index.ts +25 -6
- package/backend/git/identity/resolve.ts +2 -1
- package/backend/git/identity/scope-config.test.ts +7 -4
- package/backend/git/identity/scope-config.ts +13 -7
- package/backend/git-hosts/accounts.ts +106 -0
- package/backend/git-hosts/auth/client-ids.ts +34 -0
- package/backend/git-hosts/auth/connect.ts +110 -0
- package/backend/git-hosts/auth/endpoints.ts +130 -0
- package/backend/git-hosts/auth/flows.ts +355 -0
- package/backend/git-hosts/auth/local.ts +152 -0
- package/backend/git-hosts/ci.ts +18 -0
- package/backend/git-hosts/cli.test.ts +82 -0
- package/backend/git-hosts/cli.ts +342 -0
- package/backend/git-hosts/credentials.ts +173 -0
- package/backend/git-hosts/git-credential.ts +30 -0
- package/backend/git-hosts/health.ts +39 -0
- package/backend/git-hosts/http.ts +174 -0
- package/backend/git-hosts/index.ts +34 -0
- package/backend/git-hosts/providers/bitbucket.ts +186 -0
- package/backend/git-hosts/providers/gitea.ts +208 -0
- package/backend/git-hosts/providers/github.ts +270 -0
- package/backend/git-hosts/providers/gitlab-client.ts +70 -0
- package/backend/git-hosts/providers/gitlab.ts +285 -0
- package/backend/git-hosts/providers/locators.test.ts +68 -0
- package/backend/git-hosts/registry.ts +50 -0
- package/backend/git-hosts/service.ts +432 -0
- package/backend/git-hosts/types.ts +82 -0
- package/backend/git-hosts/urls.test.ts +42 -0
- package/backend/git-hosts/urls.ts +69 -0
- package/backend/index.ts +84 -17
- package/backend/integrations/accounts.ts +50 -3
- package/backend/integrations/registry/define.ts +9 -0
- package/backend/integrations/registry/index.ts +11 -0
- package/backend/integrations/registry/providers/bitbucket.ts +51 -0
- package/backend/integrations/registry/providers/gitea.ts +53 -0
- package/backend/integrations/registry/providers/github.ts +24 -7
- package/backend/integrations/registry/providers/gitlab.ts +57 -0
- package/backend/integrations/registry/types.ts +13 -1
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
- package/backend/memory/README.md +7 -4
- package/backend/memory/layout.test.ts +377 -0
- package/backend/memory/layout.ts +1029 -265
- package/backend/memory/view.ts +257 -386
- package/backend/mentions/diff.ts +63 -0
- package/backend/mentions/index.ts +109 -0
- package/backend/mentions/mentions.test.ts +27 -0
- package/backend/mentions/shared.ts +82 -0
- package/backend/mentions/sources/ai-changes.ts +140 -0
- package/backend/mentions/sources/chats.ts +122 -0
- package/backend/mentions/sources/database.ts +211 -0
- package/backend/mentions/sources/files.ts +240 -0
- package/backend/mentions/sources/git.ts +308 -0
- package/backend/mentions/sources/notes-memory.ts +121 -0
- package/backend/mentions/sources/ops.ts +125 -0
- package/backend/mentions/sources/preview.ts +153 -0
- package/backend/mentions/sources/projects.ts +114 -0
- package/backend/mentions/sources/system.ts +135 -0
- package/backend/mentions/sources/terminal.ts +50 -0
- package/backend/mentions/types.ts +75 -0
- package/backend/preview/browser/bot-check-frames.test.ts +49 -0
- package/backend/preview/browser/bot-check-frames.ts +66 -0
- package/backend/preview/browser/browser-dialog-handler.ts +6 -5
- package/backend/preview/browser/browser-host-bridge.ts +4 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
- package/backend/preview/browser/browser-pool.ts +26 -17
- package/backend/preview/browser/browser-preview-service.ts +164 -2
- package/backend/preview/browser/browser-screenshot.test.ts +113 -0
- package/backend/preview/browser/browser-screenshot.ts +396 -0
- package/backend/preview/browser/browser-tab-manager.ts +35 -186
- package/backend/preview/browser/browser-video-capture.ts +12 -17
- package/backend/preview/browser/element-describe.ts +125 -0
- package/backend/preview/browser/page-binding.ts +141 -0
- package/backend/preview/browser/screenshot-files.test.ts +117 -0
- package/backend/preview/browser/screenshot-files.ts +134 -0
- package/backend/preview/browser/user-agent.test.ts +25 -0
- package/backend/preview/browser/user-agent.ts +100 -0
- package/backend/project/status-manager.ts +4 -2
- package/backend/projects/engine-transcripts.ts +153 -0
- package/backend/projects/folder-guard.ts +55 -0
- package/backend/projects/move.test.ts +208 -0
- package/backend/projects/move.ts +277 -0
- package/backend/projects/project-cleanup.integration.test.ts +3 -1
- package/backend/projects/project-cleanup.ts +10 -0
- package/backend/storage/actions.ts +260 -0
- package/backend/storage/chats.test.ts +57 -0
- package/backend/storage/chats.ts +170 -0
- package/backend/storage/database.ts +105 -0
- package/backend/storage/engine-homes.ts +145 -0
- package/backend/storage/fs-size.ts +111 -0
- package/backend/storage/history.ts +39 -0
- package/backend/storage/policy.ts +156 -0
- package/backend/storage/preview-profiles.ts +169 -0
- package/backend/storage/purge.ts +158 -0
- package/backend/storage/scanner.ts +339 -0
- package/backend/storage/session-index.ts +208 -0
- package/backend/storage/snapshots.ts +99 -0
- package/backend/storage/storage-flow.test.ts +137 -0
- package/backend/storage/transcripts/aliases.ts +75 -0
- package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
- package/backend/storage/transcripts/claude-dedupe.ts +152 -0
- package/backend/storage/transcripts/claude.ts +155 -0
- package/backend/storage/transcripts/cursor.ts +165 -0
- package/backend/storage/transcripts/file-stores.ts +224 -0
- package/backend/storage/transcripts/index.ts +207 -0
- package/backend/storage/transcripts/opencode.ts +124 -0
- package/backend/storage/transcripts/references.ts +42 -0
- package/backend/storage/transcripts/types.ts +58 -0
- package/backend/storage/worktrees.ts +114 -0
- package/backend/terminal/ptykit.ts +25 -0
- package/backend/update/registry.ts +24 -0
- package/backend/update/release-notes.test.ts +110 -0
- package/backend/update/release-notes.ts +132 -0
- package/backend/update/restart.ts +159 -0
- package/backend/utils/env.test.ts +64 -0
- package/backend/utils/env.ts +23 -55
- package/backend/utils/port-utils.ts +13 -0
- package/backend/work/index.ts +13 -2
- package/backend/work/providers/github/actions-logs.ts +1 -1
- package/backend/work/providers/github/adapter.ts +32 -1
- package/backend/work/providers/github/client.ts +7 -3
- package/backend/work/providers/gitlab/adapter.ts +770 -0
- package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
- package/backend/work/service.ts +60 -36
- package/backend/work/start-work.ts +1 -1
- package/backend/work/types.ts +4 -0
- package/backend/worktrees/index.ts +1 -0
- package/backend/worktrees/service.ts +23 -2
- package/backend/ws/chat/composer.ts +47 -6
- package/backend/ws/chat/stream.ts +19 -10
- package/backend/ws/files/search.ts +1 -1
- package/backend/ws/files/write.ts +27 -0
- package/backend/ws/hosting/index.ts +231 -0
- package/backend/ws/index.ts +12 -2
- package/backend/ws/integrations/crud.ts +31 -5
- package/backend/ws/integrations/hosting-auth.ts +227 -0
- package/backend/ws/integrations/index.ts +2 -0
- package/backend/ws/memory/crud.ts +118 -81
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/messages/crud.ts +3 -1
- package/backend/ws/preview/browser/screenshot.ts +184 -0
- package/backend/ws/preview/index.ts +23 -0
- package/backend/ws/projects/crud.ts +66 -58
- package/backend/ws/sessions/crud.ts +7 -95
- package/backend/ws/snapshot/changes.ts +3 -3
- package/backend/ws/storage/index.ts +102 -0
- package/backend/ws/system/index.ts +7 -0
- package/backend/ws/system/operations.ts +125 -69
- package/backend/ws/work/context.ts +3 -4
- package/backend/ws/work/crud.ts +33 -0
- package/backend/ws/work/schemas.ts +4 -1
- package/bin/clopen.ts +18 -18
- package/dist/assets/{index-DD0-3EWg.js → index-B9rHDvjg.js} +1 -1
- package/dist/assets/index-B9rHDvjg.js.br +0 -0
- package/dist/assets/index-B9rHDvjg.js.gz +0 -0
- package/dist/assets/{index-CrVWZH_D.js → index-DFlwOd7k.js} +1 -1
- package/dist/assets/index-DFlwOd7k.js.br +0 -0
- package/dist/assets/index-DFlwOd7k.js.gz +0 -0
- package/dist/assets/main-Bz_brxxS.css +1 -0
- package/dist/assets/main-Bz_brxxS.css.br +0 -0
- package/dist/assets/main-Bz_brxxS.css.gz +0 -0
- package/dist/assets/main-DRcX9SHx.js +1273 -0
- package/dist/assets/main-DRcX9SHx.js.br +0 -0
- package/dist/assets/main-DRcX9SHx.js.gz +0 -0
- package/dist/assets/pdf-DfwfQPLy.js +57 -0
- package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
- package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
- package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
- package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
- package/package.json +8 -9
- package/scripts/start.ts +21 -4
- package/shared/constants/binary-extensions.ts +20 -4
- package/shared/constants/support.test.ts +27 -0
- package/shared/constants/support.ts +79 -0
- package/shared/constants/tool-icons.ts +7 -1
- package/shared/types/database/schema.ts +6 -0
- package/shared/types/git-hosting.ts +241 -0
- package/shared/types/integrations.ts +51 -1
- package/shared/types/memory.ts +96 -73
- package/shared/types/mentions.ts +96 -0
- package/shared/types/release-notes.ts +31 -0
- package/shared/types/storage.ts +175 -0
- package/shared/types/stores/settings.ts +16 -0
- package/shared/types/unified/index.ts +2 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/stream.ts +22 -1
- package/shared/types/unified/tool.ts +4 -0
- package/shared/types/work.ts +6 -0
- package/shared/utils/attachment-mentions.test.ts +39 -0
- package/shared/utils/attachment-mentions.ts +100 -0
- package/shared/utils/context-document.test.ts +53 -0
- package/shared/utils/context-document.ts +226 -0
- package/shared/utils/device-frame.test.ts +73 -0
- package/shared/utils/device-frame.ts +320 -0
- package/shared/utils/fuzzy.ts +79 -0
- package/shared/utils/launcher-fingerprint.test.ts +73 -0
- package/shared/utils/launcher-fingerprint.ts +108 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/page-colors.test.ts +17 -0
- package/shared/utils/page-colors.ts +24 -0
- package/shared/utils/process-supervisor.test.ts +88 -1
- package/shared/utils/process-supervisor.ts +123 -29
- package/shared/utils/process-tree.ts +99 -0
- package/shared/utils/restart-intent.test.ts +57 -0
- package/shared/utils/restart-intent.ts +80 -0
- package/shared/utils/semver.test.ts +33 -0
- package/shared/utils/semver.ts +35 -0
- package/shared/utils/supervised-child.ts +44 -0
- package/shared/utils/supervisor-protocol.ts +20 -0
- package/.env.example +0 -9
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js +0 -1
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
- package/dist/assets/index-CrVWZH_D.js.br +0 -0
- package/dist/assets/index-CrVWZH_D.js.gz +0 -0
- package/dist/assets/index-DD0-3EWg.js.br +0 -0
- package/dist/assets/index-DD0-3EWg.js.gz +0 -0
- package/dist/assets/main-D2_TmcwQ.js +0 -1240
- package/dist/assets/main-D2_TmcwQ.js.br +0 -0
- package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
- package/dist/assets/main-Yucigcmf.css +0 -1
- package/dist/assets/main-Yucigcmf.css.br +0 -0
- package/dist/assets/main-Yucigcmf.css.gz +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified diffs of two texts, for snapshots that are not in git — the
|
|
3
|
+
* checkpoint blobs the AI-changes view reads.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { diffSequencesAsync, splitLines, type DiffOp } from '$shared/utils/diff-calculator';
|
|
7
|
+
|
|
8
|
+
const CONTEXT = 3;
|
|
9
|
+
|
|
10
|
+
/** A `diff -u` style diff of `before` → `after`, or '' when they are the same. */
|
|
11
|
+
export async function unifiedDiff(path: string, before: string, after: string): Promise<string> {
|
|
12
|
+
if (before === after) return '';
|
|
13
|
+
const a = splitLines(before);
|
|
14
|
+
const b = splitLines(after);
|
|
15
|
+
const ops = await diffSequencesAsync(a, b);
|
|
16
|
+
|
|
17
|
+
// Lines of the edit script, each with where it sits on either side.
|
|
18
|
+
type Line = { op: DiffOp['type']; text: string; oldLine: number; newLine: number };
|
|
19
|
+
const lines: Line[] = [];
|
|
20
|
+
let oldLine = 0;
|
|
21
|
+
let newLine = 0;
|
|
22
|
+
for (const op of ops) {
|
|
23
|
+
if (op.type === 'keep') lines.push({ op: 'keep', text: a[op.oldIndex], oldLine: ++oldLine, newLine: ++newLine });
|
|
24
|
+
else if (op.type === 'delete') lines.push({ op: 'delete', text: a[op.oldIndex], oldLine: ++oldLine, newLine });
|
|
25
|
+
else lines.push({ op: 'insert', text: b[op.newIndex], oldLine, newLine: ++newLine });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const header = [`--- ${before ? `a/${path}` : '/dev/null'}`, `+++ ${after ? `b/${path}` : '/dev/null'}`];
|
|
29
|
+
const hunks: string[] = [];
|
|
30
|
+
let i = 0;
|
|
31
|
+
while (i < lines.length) {
|
|
32
|
+
if (lines[i].op === 'keep') {
|
|
33
|
+
i++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const start = Math.max(0, i - CONTEXT);
|
|
37
|
+
let end = i;
|
|
38
|
+
// Extend while changes are within two contexts of each other.
|
|
39
|
+
while (end < lines.length) {
|
|
40
|
+
if (lines[end].op !== 'keep') {
|
|
41
|
+
end++;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
let next = end;
|
|
45
|
+
while (next < lines.length && lines[next].op === 'keep') next++;
|
|
46
|
+
if (next < lines.length && next - end <= CONTEXT * 2) end = next;
|
|
47
|
+
else break;
|
|
48
|
+
}
|
|
49
|
+
const stop = Math.min(lines.length, end + CONTEXT);
|
|
50
|
+
const slice = lines.slice(start, stop);
|
|
51
|
+
const first = slice[0];
|
|
52
|
+
const oldStart = first.op === 'insert' ? first.oldLine + 1 : first.oldLine;
|
|
53
|
+
const newStart = first.op === 'delete' ? first.newLine + 1 : first.newLine;
|
|
54
|
+
const oldCount = slice.filter((line) => line.op !== 'insert').length;
|
|
55
|
+
const newCount = slice.filter((line) => line.op !== 'delete').length;
|
|
56
|
+
hunks.push(
|
|
57
|
+
`@@ -${oldCount ? oldStart : oldStart - 1},${oldCount} +${newCount ? newStart : newStart - 1},${newCount} @@`,
|
|
58
|
+
...slice.map((line) => `${line.op === 'keep' ? ' ' : line.op === 'delete' ? '-' : '+'}${line.text}`)
|
|
59
|
+
);
|
|
60
|
+
i = stop;
|
|
61
|
+
}
|
|
62
|
+
return [...header, ...hunks].join('\n');
|
|
63
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@` picker's server side: every mention source, searched together, and
|
|
3
|
+
* the snapshot of whatever is picked.
|
|
4
|
+
*
|
|
5
|
+
* Adding a source is adding it to `SOURCES` — the composer, the prompt and
|
|
6
|
+
* the timeline already know what to do with whatever it captures.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { CapturedAttachment, ContextKind, MentionCandidate, MentionRef } from '$shared/types/mentions';
|
|
10
|
+
import { CONTEXT_MEDIA_TYPE } from '$shared/utils/context-document';
|
|
11
|
+
import { MAX_ATTACHMENT_BYTES } from '$shared/constants/attachments';
|
|
12
|
+
import { debug } from '$shared/utils/logger';
|
|
13
|
+
import { bestFuzzyScore } from '$shared/utils/fuzzy';
|
|
14
|
+
import { filesSource } from './sources/files';
|
|
15
|
+
import { gitSource } from './sources/git';
|
|
16
|
+
import { terminalSource } from './sources/terminal';
|
|
17
|
+
import { previewSource } from './sources/preview';
|
|
18
|
+
import { chatsSource } from './sources/chats';
|
|
19
|
+
import { aiChangesSource } from './sources/ai-changes';
|
|
20
|
+
import { projectsSource } from './sources/projects';
|
|
21
|
+
import { notesMemorySource } from './sources/notes-memory';
|
|
22
|
+
import { databaseSource } from './sources/database';
|
|
23
|
+
import { containersSource, deploymentsSource } from './sources/ops';
|
|
24
|
+
import { systemSource } from './sources/system';
|
|
25
|
+
import { within } from './shared';
|
|
26
|
+
import type { MentionCategory, MentionContext, MentionSource } from './types';
|
|
27
|
+
|
|
28
|
+
export type { MentionContext, MentionCategory } from './types';
|
|
29
|
+
|
|
30
|
+
/** In the order their rows are listed. */
|
|
31
|
+
const SOURCES: MentionSource[] = [
|
|
32
|
+
filesSource,
|
|
33
|
+
gitSource,
|
|
34
|
+
previewSource,
|
|
35
|
+
terminalSource,
|
|
36
|
+
chatsSource,
|
|
37
|
+
aiChangesSource,
|
|
38
|
+
projectsSource,
|
|
39
|
+
notesMemorySource,
|
|
40
|
+
databaseSource,
|
|
41
|
+
deploymentsSource,
|
|
42
|
+
containersSource,
|
|
43
|
+
systemSource
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/** How long one source may take at the root before the picker answers without it. */
|
|
47
|
+
const ROOT_BUDGET_MS = 1500;
|
|
48
|
+
/** Opening a category waits longer: that list is all the picker shows. */
|
|
49
|
+
const CATEGORY_BUDGET_MS = 20_000;
|
|
50
|
+
|
|
51
|
+
export interface MentionSearch {
|
|
52
|
+
category?: string;
|
|
53
|
+
query: string;
|
|
54
|
+
limit?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function searchMentions(
|
|
58
|
+
ctx: MentionContext,
|
|
59
|
+
search: MentionSearch
|
|
60
|
+
): Promise<{ items: MentionCandidate[]; categories: MentionCategory[] }> {
|
|
61
|
+
const query = search.query.trim();
|
|
62
|
+
const limit = Math.min(Math.max(search.limit ?? 50, 1), 200);
|
|
63
|
+
const budget = search.category ? CATEGORY_BUDGET_MS : ROOT_BUDGET_MS;
|
|
64
|
+
|
|
65
|
+
const answer = async <T>(source: MentionSource, work: () => Promise<T> | T, fallback: T): Promise<T> => {
|
|
66
|
+
try {
|
|
67
|
+
return await within(Promise.resolve(work()), budget, fallback);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
debug.warn('chat', `A mention source failed (${source.kinds[0]}):`, error);
|
|
70
|
+
return fallback;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const lists = await Promise.all(
|
|
75
|
+
SOURCES.map((source) => answer(source, () => source.list(ctx, { category: search.category, query, limit }), [] as MentionCandidate[]))
|
|
76
|
+
);
|
|
77
|
+
const items = lists.flat();
|
|
78
|
+
|
|
79
|
+
if (search.category) return { items: items.slice(0, limit), categories: [] };
|
|
80
|
+
|
|
81
|
+
const all = (await Promise.all(SOURCES.map((source) => answer(source, () => source.categories(ctx), [] as MentionCategory[])))).flat();
|
|
82
|
+
const categories = query
|
|
83
|
+
? all.filter((category) => bestFuzzyScore(query, [category.label, category.detail]) > 0)
|
|
84
|
+
: all;
|
|
85
|
+
return { items, categories };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Take the snapshot of what was picked: its documents, then its pictures. */
|
|
89
|
+
export async function captureMention(ctx: MentionContext, kind: ContextKind, ref: MentionRef): Promise<CapturedAttachment[]> {
|
|
90
|
+
const source = SOURCES.find((entry) => entry.kinds.includes(kind));
|
|
91
|
+
if (!source) throw new Error(`Nothing can be mentioned as ${kind}`);
|
|
92
|
+
const captured = await source.capture(ctx, kind, ref);
|
|
93
|
+
return [
|
|
94
|
+
...captured.documents.map((document) => ({
|
|
95
|
+
fileName: document.fileName,
|
|
96
|
+
mediaType: CONTEXT_MEDIA_TYPE,
|
|
97
|
+
data: withinLimit(document.text).toString('base64')
|
|
98
|
+
})),
|
|
99
|
+
...(captured.images ?? [])
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The document's bytes, cut to what an attachment may hold — the header always survives. */
|
|
104
|
+
function withinLimit(text: string): Buffer {
|
|
105
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
106
|
+
if (bytes.length <= MAX_ATTACHMENT_BYTES) return bytes;
|
|
107
|
+
const note = Buffer.from(`\n\n… cut here: the snapshot was larger than ${Math.round(MAX_ATTACHMENT_BYTES / (1024 * 1024))} MB.\n`, 'utf8');
|
|
108
|
+
return Buffer.concat([bytes.subarray(0, MAX_ATTACHMENT_BYTES - note.length), note]);
|
|
109
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { unifiedDiff } from './diff';
|
|
3
|
+
import { rank, stripAnsi } from './shared';
|
|
4
|
+
import { terminalText } from './sources/terminal';
|
|
5
|
+
|
|
6
|
+
describe('mention helpers', () => {
|
|
7
|
+
it('write a unified diff with context around each change', async () => {
|
|
8
|
+
const before = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'].join('\n');
|
|
9
|
+
const after = ['a', 'b', 'C', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'].join('\n');
|
|
10
|
+
expect(await unifiedDiff('x.txt', before, after)).toBe(
|
|
11
|
+
['--- a/x.txt', '+++ b/x.txt', '@@ -1,6 +1,6 @@', ' a', ' b', '-c', '+C', ' d', ' e', ' f', '@@ -8,3 +8,4 @@', ' h', ' i', ' j', '+k'].join('\n')
|
|
12
|
+
);
|
|
13
|
+
expect(await unifiedDiff('x.txt', 'same', 'same')).toBe('');
|
|
14
|
+
expect(await unifiedDiff('new.txt', '', 'hello')).toBe(['--- /dev/null', '+++ b/new.txt', '@@ -0,0 +1,1 @@', '+hello'].join('\n'));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('turn a terminal screen into the text a person saw', () => {
|
|
18
|
+
expect(stripAnsi('\u001b[1;31merror\u001b[0m: \u001b]0;title\u0007done')).toBe('error: done');
|
|
19
|
+
expect(terminalText('$ ls \r\nfile\r\n\r\n\r\n\r\n$ \u001b[K ')).toBe('$ ls\nfile\n\n$');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('rank by match, keeping the given order with no query', () => {
|
|
23
|
+
const items = ['readme.md', 'src/app.ts', 'src/apple.ts'];
|
|
24
|
+
expect(rank(items, '', (item) => [item], 2)).toEqual(['readme.md', 'src/app.ts']);
|
|
25
|
+
expect(rank(items, 'app', (item) => [item], 5)).toEqual(['src/app.ts', 'src/apple.ts']);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers the mention sources share.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { bestFuzzyScore } from '$shared/utils/fuzzy';
|
|
6
|
+
import { execGit } from '$backend/git/git-executor';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Keep what matches `query`, best first, at most `limit`. With no query the
|
|
10
|
+
* order given is kept — sources list most recent or most relevant first.
|
|
11
|
+
*/
|
|
12
|
+
export function rank<T>(items: T[], query: string, texts: (item: T) => Array<string | undefined | null>, limit: number): T[] {
|
|
13
|
+
if (!query.trim()) return items.slice(0, limit);
|
|
14
|
+
return items
|
|
15
|
+
.map((item, order) => ({ item, order, score: bestFuzzyScore(query, texts(item)) }))
|
|
16
|
+
.filter((entry) => entry.score > 0)
|
|
17
|
+
.sort((a, b) => b.score - a.score || a.order - b.order)
|
|
18
|
+
.slice(0, limit)
|
|
19
|
+
.map((entry) => entry.item);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Whether `category` is the one asked for, or the root is. */
|
|
23
|
+
export function wants(category: string | undefined, own: string): 'root' | 'own' | null {
|
|
24
|
+
if (!category) return 'root';
|
|
25
|
+
return category === own ? 'own' : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Resolve within `ms`, or with `fallback`. A slow source must not hold the picker. */
|
|
29
|
+
export async function within<T>(work: Promise<T>, ms: number, fallback: T): Promise<T> {
|
|
30
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
31
|
+
try {
|
|
32
|
+
return await Promise.race([
|
|
33
|
+
work,
|
|
34
|
+
new Promise<T>((resolve) => {
|
|
35
|
+
timer = setTimeout(() => resolve(fallback), ms);
|
|
36
|
+
})
|
|
37
|
+
]);
|
|
38
|
+
} finally {
|
|
39
|
+
if (timer) clearTimeout(timer);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A git command's output, or null when it fails (not a repo, no git, bad ref). */
|
|
44
|
+
export async function gitText(args: string[], cwd: string, timeout = 20_000, okExitCodes: number[] = []): Promise<string | null> {
|
|
45
|
+
try {
|
|
46
|
+
const result = await execGit(args, cwd, { timeout, okExitCodes });
|
|
47
|
+
return result.stdout;
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** "3 minutes ago" for a timestamp, for a row's detail line. */
|
|
54
|
+
export function ago(value: string | number | Date | null | undefined): string {
|
|
55
|
+
if (value === null || value === undefined || value === '') return '';
|
|
56
|
+
const time = new Date(value).getTime();
|
|
57
|
+
if (!Number.isFinite(time)) return '';
|
|
58
|
+
const seconds = Math.max(0, Math.round((Date.now() - time) / 1000));
|
|
59
|
+
if (seconds < 60) return 'just now';
|
|
60
|
+
const minutes = Math.round(seconds / 60);
|
|
61
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
62
|
+
const hours = Math.round(minutes / 60);
|
|
63
|
+
if (hours < 24) return `${hours} h ago`;
|
|
64
|
+
const days = Math.round(hours / 24);
|
|
65
|
+
if (days < 30) return `${days} d ago`;
|
|
66
|
+
return new Date(time).toISOString().slice(0, 10);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Remove terminal escape sequences, leaving the text a person saw. */
|
|
70
|
+
export function stripAnsi(text: string): string {
|
|
71
|
+
return (
|
|
72
|
+
text
|
|
73
|
+
// OSC (titles, hyperlinks), ended by BEL or ST.
|
|
74
|
+
.replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, '')
|
|
75
|
+
// CSI sequences: colours, cursor moves, erases.
|
|
76
|
+
.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, '')
|
|
77
|
+
// Other two-character escapes.
|
|
78
|
+
.replace(/\u001b[@-Z\\-_]/g, '')
|
|
79
|
+
// Lone control characters except tab and newline.
|
|
80
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '')
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the AI changed in this chat: one turn, or the whole chat net.
|
|
3
|
+
*
|
|
4
|
+
* Read from checkpoint snapshots — the same record the AI-changes panel shows
|
|
5
|
+
* — so a change made by a shell command counts as much as one made by an edit
|
|
6
|
+
* tool. Only turns still on the active branch are offered: a restored-away
|
|
7
|
+
* turn describes nothing on disk.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
11
|
+
import type { SessionScopedChanges } from '$shared/types/database/schema';
|
|
12
|
+
import { buildContextDocument, type ContextSection } from '$shared/utils/context-document';
|
|
13
|
+
import { loadMessage } from '$shared/utils/message-formatter';
|
|
14
|
+
import { snapshotQueries } from '$backend/database/queries';
|
|
15
|
+
import { extractMessageText } from '$backend/snapshot/helpers';
|
|
16
|
+
import { excerptPrompt, statusOf } from '$backend/snapshot/turn-changes';
|
|
17
|
+
import { activeCheckpoints, parseSessionChanges, readTextBlob } from '$backend/ws/snapshot/changes';
|
|
18
|
+
import { unifiedDiff } from '../diff';
|
|
19
|
+
import { ago, rank, wants } from '../shared';
|
|
20
|
+
import { type MentionContext, type MentionSource } from '../types';
|
|
21
|
+
|
|
22
|
+
const CATEGORY = 'ai-changes';
|
|
23
|
+
|
|
24
|
+
interface Turn {
|
|
25
|
+
checkpointId: string;
|
|
26
|
+
index: number;
|
|
27
|
+
prompt: string;
|
|
28
|
+
at: string;
|
|
29
|
+
changes: SessionScopedChanges;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** How long a chat's turn list is reused: the picker asks on every keystroke. */
|
|
33
|
+
const TURNS_TTL_MS = 10_000;
|
|
34
|
+
const turnsCache = new Map<string, { at: number; turns: Turn[] }>();
|
|
35
|
+
|
|
36
|
+
/** The turns that changed something, oldest first — read once per few keystrokes. */
|
|
37
|
+
function turnsOf(chatSessionId: string | null): Turn[] {
|
|
38
|
+
if (!chatSessionId) return [];
|
|
39
|
+
const hit = turnsCache.get(chatSessionId);
|
|
40
|
+
if (hit && Date.now() - hit.at < TURNS_TTL_MS) return hit.turns;
|
|
41
|
+
const turns = readTurns(chatSessionId);
|
|
42
|
+
turnsCache.set(chatSessionId, { at: Date.now(), turns });
|
|
43
|
+
if (turnsCache.size > 50) turnsCache.delete(turnsCache.keys().next().value!);
|
|
44
|
+
return turns;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function readTurns(chatSessionId: string): Turn[] {
|
|
48
|
+
return activeCheckpoints(chatSessionId)
|
|
49
|
+
.map((checkpoint, i) => ({
|
|
50
|
+
checkpointId: checkpoint.id,
|
|
51
|
+
index: i + 1,
|
|
52
|
+
prompt: excerptPrompt(extractMessageText(loadMessage(checkpoint)).replace(/\s+/g, ' ').trim(), 120),
|
|
53
|
+
at: checkpoint.created_at,
|
|
54
|
+
changes: parseSessionChanges(snapshotQueries.getByMessageId(checkpoint.id)?.session_changes)
|
|
55
|
+
}))
|
|
56
|
+
.filter((turn) => Object.keys(turn.changes).length > 0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function rows(ctx: MentionContext): MentionCandidate[] {
|
|
60
|
+
const turns = turnsOf(ctx.chatSessionId);
|
|
61
|
+
if (turns.length === 0) return [];
|
|
62
|
+
const files = new Set(turns.flatMap((turn) => Object.keys(turn.changes)));
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
key: 'ai-changes:all', kind: 'ai-changes', group: 'AI changes', label: 'Everything this chat changed',
|
|
66
|
+
detail: `${files.size} ${files.size === 1 ? 'file' : 'files'} over ${turns.length} ${turns.length === 1 ? 'turn' : 'turns'}`,
|
|
67
|
+
icon: 'lucide:sparkles', ref: {}
|
|
68
|
+
},
|
|
69
|
+
...[...turns].reverse().map((turn) => {
|
|
70
|
+
const count = Object.keys(turn.changes).length;
|
|
71
|
+
return {
|
|
72
|
+
key: `ai-changes:${turn.checkpointId}`, kind: 'ai-changes' as const, group: 'AI changes',
|
|
73
|
+
label: `Turn ${turn.index}: ${turn.prompt || '(no text)'}`,
|
|
74
|
+
detail: `${count} ${count === 1 ? 'file' : 'files'} · ${ago(turn.at)}`, icon: 'lucide:sparkles' as const,
|
|
75
|
+
ref: { checkpointId: turn.checkpointId }
|
|
76
|
+
};
|
|
77
|
+
})
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const aiChangesSource: MentionSource = {
|
|
82
|
+
kinds: ['ai-changes'],
|
|
83
|
+
|
|
84
|
+
categories(ctx) {
|
|
85
|
+
const turns = turnsOf(ctx.chatSessionId);
|
|
86
|
+
if (turns.length === 0) return [];
|
|
87
|
+
return [{ id: CATEGORY, label: 'AI changes', detail: `${turns.length} ${turns.length === 1 ? 'turn' : 'turns'} in this chat`, icon: 'lucide:sparkles', group: 'Chats' }];
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
async list(ctx, request) {
|
|
91
|
+
const mode = wants(request.category, CATEGORY);
|
|
92
|
+
if (!mode) return [];
|
|
93
|
+
const all = rows(ctx);
|
|
94
|
+
if (mode === 'root') return request.query.trim() ? rank(all, request.query, (row) => [row.label, 'ai changes'], 2) : [];
|
|
95
|
+
return rank(all, request.query, (row) => [row.label], request.limit);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
async capture(ctx, _kind, ref) {
|
|
99
|
+
// A capture reads the chat as it is now, not as it was a few seconds ago.
|
|
100
|
+
const turns = ctx.chatSessionId ? readTurns(ctx.chatSessionId) : [];
|
|
101
|
+
const checkpointId = typeof ref.checkpointId === 'string' ? ref.checkpointId : null;
|
|
102
|
+
const chosen = checkpointId ? turns.filter((turn) => turn.checkpointId === checkpointId) : turns;
|
|
103
|
+
if (chosen.length === 0) throw new Error('Those changes are no longer on this branch');
|
|
104
|
+
|
|
105
|
+
// Net over the turns: the first "before" and the last "after" of each file.
|
|
106
|
+
const net = new Map<string, { oldHash: string; newHash: string }>();
|
|
107
|
+
for (const turn of chosen) {
|
|
108
|
+
for (const [path, change] of Object.entries(turn.changes)) {
|
|
109
|
+
const known = net.get(path);
|
|
110
|
+
net.set(path, { oldHash: known ? known.oldHash : change.oldHash, newHash: change.newHash });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const sections: ContextSection[] = [];
|
|
115
|
+
const summary: string[] = [];
|
|
116
|
+
for (const [path, change] of net) {
|
|
117
|
+
if (change.oldHash === change.newHash) continue;
|
|
118
|
+
const status = statusOf(change.oldHash, change.newHash);
|
|
119
|
+
summary.push(`${status.padEnd(8)} ${path}`);
|
|
120
|
+
const before = change.oldHash ? await readTextBlob(change.oldHash) : '';
|
|
121
|
+
const after = change.newHash ? await readTextBlob(change.newHash) : '';
|
|
122
|
+
if (before === null || after === null) {
|
|
123
|
+
sections.push({ title: path, body: `Binary file ${status}.` });
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
sections.push({ title: path, body: await unifiedDiff(path, before, after), fence: 'diff' });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const label = checkpointId ? `Turn ${chosen[0].index}: ${chosen[0].prompt || '(no text)'}` : 'Everything this chat changed';
|
|
130
|
+
return {
|
|
131
|
+
documents: [buildContextDocument({
|
|
132
|
+
kind: 'ai-changes',
|
|
133
|
+
label,
|
|
134
|
+
detail: `${summary.length} ${summary.length === 1 ? 'file' : 'files'}`,
|
|
135
|
+
facts: [['Turns', chosen.map((turn) => turn.index).join(', ')]],
|
|
136
|
+
sections: [{ title: 'Files', body: summary.join('\n') || 'Nothing left changed.', fence: '' }, ...sections]
|
|
137
|
+
})]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Other chats — of this project or of any other — and single messages.
|
|
3
|
+
*
|
|
4
|
+
* A chat is attached as the transcript of its active branch: what was asked,
|
|
5
|
+
* answered and done, in the form the engine handoff already uses. A message
|
|
6
|
+
* is attached as its own text, for "do what this said".
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ChatSession } from '$shared/types/database/schema';
|
|
10
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
11
|
+
import { buildContextDocument } from '$shared/utils/context-document';
|
|
12
|
+
import { loadMessage } from '$shared/utils/message-formatter';
|
|
13
|
+
import { messageQueries, projectQueries, sessionQueries } from '$backend/database/queries';
|
|
14
|
+
import { extractMessageText } from '$backend/snapshot/helpers';
|
|
15
|
+
import { renderBranchTranscript } from '$backend/chat/engine-handoff';
|
|
16
|
+
import { ago, rank, wants } from '../shared';
|
|
17
|
+
import { refString, type MentionContext, type MentionSource } from '../types';
|
|
18
|
+
|
|
19
|
+
const HERE = 'chats';
|
|
20
|
+
const EVERYWHERE = 'chats-all';
|
|
21
|
+
|
|
22
|
+
function titleOf(session: ChatSession): string {
|
|
23
|
+
// Titles are cut from the first message and keep its line breaks.
|
|
24
|
+
return (session.title || session.head_title || '').replace(/\s+/g, ' ').trim() || 'Untitled chat';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function lastActive(session: ChatSession): string {
|
|
28
|
+
return session.last_message_at || session.started_at;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function sessionRow(session: ChatSession, projectName: string | null): MentionCandidate {
|
|
32
|
+
const messages = session.user_count ?? 0;
|
|
33
|
+
return {
|
|
34
|
+
key: `chat-session:${session.id}`,
|
|
35
|
+
kind: 'chat-session',
|
|
36
|
+
group: projectName ? 'Chats in other projects' : 'Chats',
|
|
37
|
+
label: titleOf(session),
|
|
38
|
+
detail: [projectName, `${messages} ${messages === 1 ? 'message' : 'messages'}`, ago(lastActive(session))].filter(Boolean).join(' · '),
|
|
39
|
+
icon: 'lucide:messages-square',
|
|
40
|
+
ref: { sessionId: session.id }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Chats of this project that have something in them, latest first, without the one being written in. */
|
|
45
|
+
function projectChats(ctx: MentionContext): ChatSession[] {
|
|
46
|
+
return sessionQueries
|
|
47
|
+
.getByProjectId(ctx.projectId)
|
|
48
|
+
.filter((session) => session.id !== ctx.chatSessionId && (session.message_count ?? 0) > 0)
|
|
49
|
+
.sort((a, b) => lastActive(b).localeCompare(lastActive(a)));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Chats of the other listed projects: matched by content when searching, latest otherwise. */
|
|
53
|
+
function otherChats(ctx: MentionContext, query: string, limit: number): MentionCandidate[] {
|
|
54
|
+
const names = new Map(projectQueries.getListed().map((project) => [project.id, project.name]));
|
|
55
|
+
const sessions = query.trim()
|
|
56
|
+
? sessionQueries.searchGlobal(query, limit * 2)
|
|
57
|
+
: sessionQueries.getAll().filter((session) => names.has(session.project_id)).sort((a, b) => lastActive(b).localeCompare(lastActive(a))).slice(0, limit * 2);
|
|
58
|
+
return sessions
|
|
59
|
+
.filter((session) => session.project_id !== ctx.projectId && names.has(session.project_id) && (session.message_count ?? 0) > 0)
|
|
60
|
+
.slice(0, limit)
|
|
61
|
+
.map((session) => sessionRow(session, names.get(session.project_id) ?? null));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const chatsSource: MentionSource = {
|
|
65
|
+
kinds: ['chat-session', 'chat-message'],
|
|
66
|
+
|
|
67
|
+
categories: () => [
|
|
68
|
+
{ id: HERE, label: 'Chats', detail: 'Other chats in this project', icon: 'lucide:messages-square', group: 'Chats' },
|
|
69
|
+
{ id: EVERYWHERE, label: 'Chats in other projects', detail: 'Search every project’s chats', icon: 'lucide:messages-square', group: 'Chats' }
|
|
70
|
+
],
|
|
71
|
+
|
|
72
|
+
async list(ctx, request) {
|
|
73
|
+
if (wants(request.category, HERE) === 'own') {
|
|
74
|
+
return rank(projectChats(ctx).map((session) => sessionRow(session, null)), request.query, (row) => [row.label], request.limit);
|
|
75
|
+
}
|
|
76
|
+
if (wants(request.category, EVERYWHERE) === 'own') return otherChats(ctx, request.query, request.limit);
|
|
77
|
+
if (request.category) return [];
|
|
78
|
+
if (!request.query.trim()) return [];
|
|
79
|
+
const here = rank(projectChats(ctx).map((session) => sessionRow(session, null)), request.query, (row) => [row.label], 3);
|
|
80
|
+
return [...here, ...otherChats(ctx, request.query, 2)];
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
async capture(_ctx, kind, ref) {
|
|
84
|
+
if (kind === 'chat-message') {
|
|
85
|
+
const row = messageQueries.getById(refString(ref, 'messageId'));
|
|
86
|
+
if (!row) throw new Error('That message is gone');
|
|
87
|
+
const message = loadMessage(row);
|
|
88
|
+
const session = sessionQueries.getById(row.session_id);
|
|
89
|
+
const text = extractMessageText(message).trim();
|
|
90
|
+
const role = message.type === 'user' ? 'User' : 'Assistant';
|
|
91
|
+
return {
|
|
92
|
+
documents: [buildContextDocument({
|
|
93
|
+
kind,
|
|
94
|
+
label: `${role} message in "${session ? titleOf(session) : 'a chat'}"`,
|
|
95
|
+
detail: text.split('\n')[0].slice(0, 80),
|
|
96
|
+
facts: [['From', role], ['Sent', row.created_at], ['Chat', session ? titleOf(session) : null]],
|
|
97
|
+
sections: [{ title: 'Message', body: text || '(no text)' }]
|
|
98
|
+
})]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const session = sessionQueries.getById(refString(ref, 'sessionId'));
|
|
103
|
+
if (!session || !projectQueries.isListed(session.project_id)) throw new Error('That chat is gone');
|
|
104
|
+
const transcript = renderBranchTranscript(session.id);
|
|
105
|
+
if (!transcript) throw new Error('That chat has nothing in it yet');
|
|
106
|
+
const project = projectQueries.getById(session.project_id);
|
|
107
|
+
return {
|
|
108
|
+
documents: [buildContextDocument({
|
|
109
|
+
kind,
|
|
110
|
+
label: titleOf(session),
|
|
111
|
+
detail: `${transcript.turns} turns`,
|
|
112
|
+
facts: [
|
|
113
|
+
['Project', project ? `${project.name} (${project.path})` : null],
|
|
114
|
+
['Engine', session.model_name ? `${session.engine} · ${session.model_name}` : session.engine],
|
|
115
|
+
['Started', session.started_at],
|
|
116
|
+
['Last message', session.last_message_at]
|
|
117
|
+
],
|
|
118
|
+
sections: [{ title: 'Transcript', body: transcript.text }]
|
|
119
|
+
})]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
};
|