@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,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Databases from the DB client: a database's whole schema, or one table.
|
|
3
|
+
*
|
|
4
|
+
* Browsed the way the DB client's sidebar is: a connection holds databases, a
|
|
5
|
+
* database holds schemas (on drivers that have them), and those hold the
|
|
6
|
+
* tables. A server-level connection usually lands on a home database with no
|
|
7
|
+
* tables of its own, so stopping at the connection showed nothing.
|
|
8
|
+
*
|
|
9
|
+
* Listing connections is a read of Clopen's own table; opening one connects
|
|
10
|
+
* to it (the same pooled connection the DB client uses), so the picker only
|
|
11
|
+
* does that when a connection is opened. Query results are attached from the
|
|
12
|
+
* DB client itself, where they are on screen.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
16
|
+
import type { DbClientDriverAdapter } from '$backend/db-client/drivers/types';
|
|
17
|
+
import type { DbClientObjectDetails, DbClientSchemaNode, DbClientSchemaNodeType } from '$shared/types/db-client';
|
|
18
|
+
import { buildContextDocument, type ContextSection } from '$shared/utils/context-document';
|
|
19
|
+
import { dbClientConnectionQueries } from '$backend/database/queries';
|
|
20
|
+
import { connectionManager } from '$backend/db-client/connection-manager';
|
|
21
|
+
import { rank, within } from '../shared';
|
|
22
|
+
import { refOptional, refString, type MentionSource } from '../types';
|
|
23
|
+
|
|
24
|
+
const CATEGORY = 'databases';
|
|
25
|
+
const PREFIX = 'database:';
|
|
26
|
+
/** A schema snapshot describes at most this many tables. */
|
|
27
|
+
const MAX_TABLES = 300;
|
|
28
|
+
/** Schemas looked into when a database is opened. */
|
|
29
|
+
const MAX_SCHEMAS = 30;
|
|
30
|
+
const LIST_BUDGET_MS = 10_000;
|
|
31
|
+
|
|
32
|
+
const TABLE_TYPES = new Set<DbClientSchemaNodeType>(['table', 'view', 'collection', 'key']);
|
|
33
|
+
/** The server's own bookkeeping, listed after the user's databases. */
|
|
34
|
+
const SYSTEM_DATABASES = new Set(['information_schema', 'mysql', 'performance_schema', 'sys', 'admin', 'local', 'config', 'master', 'model', 'msdb', 'tempdb']);
|
|
35
|
+
|
|
36
|
+
/** Where a list is: a connection, one of its databases, one schema in it. */
|
|
37
|
+
interface Place {
|
|
38
|
+
connectionId: string;
|
|
39
|
+
database?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function encodePlace(place: Place): string {
|
|
43
|
+
return `${PREFIX}${[place.connectionId, place.database].filter((part) => part !== undefined).map(encodeURIComponent).join('/')}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function decodePlace(category: string): Place {
|
|
47
|
+
const [connectionId, database] = category.slice(PREFIX.length).split('/').map(decodeURIComponent);
|
|
48
|
+
return { connectionId, ...(database !== undefined && { database }) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function connectionRow(connection: { id: string; name: string; driver: string; database: string | null; host: string | null }): MentionCandidate {
|
|
52
|
+
return {
|
|
53
|
+
key: `db-connection:${connection.id}`,
|
|
54
|
+
kind: 'db-connection',
|
|
55
|
+
group: 'Databases',
|
|
56
|
+
label: connection.name,
|
|
57
|
+
detail: [connection.driver, connection.host, connection.database].filter(Boolean).join(' · ') || connection.driver,
|
|
58
|
+
icon: 'lucide:database',
|
|
59
|
+
ref: { connectionId: connection.id },
|
|
60
|
+
browse: encodePlace({ connectionId: connection.id })
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The databases of a connection; empty when the driver has one database only. */
|
|
65
|
+
async function databasesOf(adapter: DbClientDriverAdapter): Promise<DbClientSchemaNode[]> {
|
|
66
|
+
if (!adapter.listDatabases) return [];
|
|
67
|
+
return within(adapter.listDatabases(), LIST_BUDGET_MS, []);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Every table-like object of a database, across its schemas, with the schema it is in. */
|
|
71
|
+
async function objectsOf(adapter: DbClientDriverAdapter, database: string | undefined): Promise<Array<DbClientSchemaNode & { schema?: string }>> {
|
|
72
|
+
const schemas = adapter.listSchemas ? (await within(adapter.listSchemas(database), LIST_BUDGET_MS, [])).slice(0, MAX_SCHEMAS) : [];
|
|
73
|
+
if (schemas.length === 0) {
|
|
74
|
+
const objects = adapter.listObjects ? await within(adapter.listObjects(database), LIST_BUDGET_MS, []) : [];
|
|
75
|
+
return objects.filter((object) => TABLE_TYPES.has(object.type));
|
|
76
|
+
}
|
|
77
|
+
const all: Array<DbClientSchemaNode & { schema?: string }> = [];
|
|
78
|
+
for (const schema of schemas) {
|
|
79
|
+
const objects = adapter.listObjects ? await within(adapter.listObjects(database, schema.name), LIST_BUDGET_MS, []) : [];
|
|
80
|
+
for (const object of objects) if (TABLE_TYPES.has(object.type)) all.push({ ...object, schema: schema.name });
|
|
81
|
+
}
|
|
82
|
+
return all;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function describeColumns(details: DbClientObjectDetails): string {
|
|
86
|
+
const lines: string[] = [];
|
|
87
|
+
for (const column of details.columns ?? []) {
|
|
88
|
+
const flags = [column.isPrimary && 'primary key', column.isUnique && 'unique', !column.nullable && 'not null', column.default !== null && `default ${column.default}`]
|
|
89
|
+
.filter(Boolean)
|
|
90
|
+
.join(', ');
|
|
91
|
+
lines.push(`- ${column.name}: ${column.type}${flags ? ` (${flags})` : ''}`);
|
|
92
|
+
}
|
|
93
|
+
for (const key of details.foreignKeys ?? []) lines.push(`- ${key.column} → ${key.refTable}.${key.refColumn}`);
|
|
94
|
+
for (const field of details.mongoFieldStats ?? []) lines.push(`- ${field.field}: ${field.types.join(' | ')}`);
|
|
95
|
+
return lines.join('\n');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function plural(count: number, noun: string): string {
|
|
99
|
+
return `${count.toLocaleString('en-US')} ${noun}${count === 1 ? '' : 's'}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const databaseSource: MentionSource = {
|
|
103
|
+
kinds: ['db-connection', 'db-table'],
|
|
104
|
+
|
|
105
|
+
categories: () =>
|
|
106
|
+
dbClientConnectionQueries.listRedacted().length
|
|
107
|
+
? [{ id: CATEGORY, label: 'Databases', detail: 'Schemas and tables from the DB client', icon: 'lucide:database', group: 'Data' }]
|
|
108
|
+
: [],
|
|
109
|
+
|
|
110
|
+
async list(_ctx, request) {
|
|
111
|
+
const connections = () => dbClientConnectionQueries.listRedacted();
|
|
112
|
+
if (request.category === CATEGORY) return rank(connections().map(connectionRow), request.query, (row) => [row.label, row.detail], request.limit);
|
|
113
|
+
|
|
114
|
+
if (request.category?.startsWith(PREFIX)) {
|
|
115
|
+
const place = decodePlace(request.category);
|
|
116
|
+
const connection = dbClientConnectionQueries.require(place.connectionId);
|
|
117
|
+
const adapter = await connectionManager.get(place.connectionId);
|
|
118
|
+
|
|
119
|
+
// A connection: its databases, when it has more than the one it is on.
|
|
120
|
+
if (place.database === undefined) {
|
|
121
|
+
const databases = await databasesOf(adapter);
|
|
122
|
+
if (databases.length > 1 || (databases.length === 1 && !connection.database)) {
|
|
123
|
+
const ordered = [...databases].sort((a, b) => Number(SYSTEM_DATABASES.has(a.name)) - Number(SYSTEM_DATABASES.has(b.name)));
|
|
124
|
+
const rows = ordered.map((database): MentionCandidate => ({
|
|
125
|
+
key: `db-database:${connection.id}:${database.name}`,
|
|
126
|
+
kind: 'db-connection',
|
|
127
|
+
group: connection.name,
|
|
128
|
+
label: database.name,
|
|
129
|
+
detail: database.name === connection.database ? 'Database · the connection’s default' : SYSTEM_DATABASES.has(database.name) ? 'System database' : 'Database',
|
|
130
|
+
icon: 'lucide:database',
|
|
131
|
+
ref: { connectionId: connection.id, database: database.name },
|
|
132
|
+
browse: encodePlace({ connectionId: connection.id, database: database.name })
|
|
133
|
+
}));
|
|
134
|
+
return rank(rows, request.query, (row) => [row.label], request.limit);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// A database: its schema as a whole, then every table in it.
|
|
139
|
+
const database = place.database ?? connection.database ?? undefined;
|
|
140
|
+
const objects = await objectsOf(adapter, database);
|
|
141
|
+
const schemas = new Set(objects.map((object) => object.schema).filter(Boolean));
|
|
142
|
+
// A SQLite "database" is a file path; the connection's name reads better.
|
|
143
|
+
const where = place.database ?? connection.name;
|
|
144
|
+
const whole: MentionCandidate = {
|
|
145
|
+
key: `db-connection:${connection.id}:${database ?? ''}:all`, kind: 'db-connection', group: where,
|
|
146
|
+
label: `Whole schema of ${where}`, detail: objects.length ? plural(objects.length, 'table') : 'No tables found',
|
|
147
|
+
icon: 'lucide:database', ref: { connectionId: connection.id, ...(database && { database }) }
|
|
148
|
+
};
|
|
149
|
+
const rows = objects.map((object): MentionCandidate => ({
|
|
150
|
+
key: `db-table:${connection.id}:${database ?? ''}:${object.schema ?? ''}:${object.name}`,
|
|
151
|
+
kind: 'db-table',
|
|
152
|
+
group: where,
|
|
153
|
+
label: schemas.size > 1 && object.schema ? `${object.schema}.${object.name}` : object.name,
|
|
154
|
+
detail: [object.type, object.schema && `schema ${object.schema}`].filter(Boolean).join(' · '),
|
|
155
|
+
icon: 'lucide:table',
|
|
156
|
+
ref: { connectionId: connection.id, name: object.name, type: object.type, ...(database && { database }), ...(object.schema && { schema: object.schema }) }
|
|
157
|
+
}));
|
|
158
|
+
return [...(request.query.trim() ? [] : [whole]), ...rank(rows, request.query, (row) => [row.label], request.limit)];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (request.category || !request.query.trim()) return [];
|
|
162
|
+
return rank(connections().map(connectionRow), request.query, (row) => [row.label], 2);
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
async capture(_ctx, kind, ref) {
|
|
166
|
+
const connectionId = refString(ref, 'connectionId');
|
|
167
|
+
const connection = dbClientConnectionQueries.require(connectionId);
|
|
168
|
+
const adapter = await connectionManager.get(connectionId);
|
|
169
|
+
const database = refOptional(ref, 'database') ?? connection.database ?? undefined;
|
|
170
|
+
const schema = refOptional(ref, 'schema');
|
|
171
|
+
const facts: Array<[string, string | null | undefined]> = [['Connection', connection.name], ['Driver', connection.driver], ['Database', database], ['Schema', schema]];
|
|
172
|
+
|
|
173
|
+
if (kind === 'db-table') {
|
|
174
|
+
const name = refString(ref, 'name');
|
|
175
|
+
const type = (refOptional(ref, 'type') ?? 'table') as DbClientSchemaNodeType;
|
|
176
|
+
const details = adapter.getObjectDetails ? await adapter.getObjectDetails(name, type, database, schema) : null;
|
|
177
|
+
let ddl = details?.ddl ?? null;
|
|
178
|
+
if (!ddl && adapter.getCreateStatement) ddl = await adapter.getCreateStatement(name, type, { database, schema }).catch(() => null);
|
|
179
|
+
const indexes = (details?.indexes ?? []).map((index) => `- ${index.name}${index.unique ? ' (unique)' : ''}: ${index.columns.join(', ')}`).join('\n');
|
|
180
|
+
const sections: ContextSection[] = [];
|
|
181
|
+
if (details) sections.push({ title: 'Columns', body: describeColumns(details) || '(none reported)' });
|
|
182
|
+
if (indexes) sections.push({ title: 'Indexes', body: indexes });
|
|
183
|
+
if (ddl) sections.push({ title: 'Definition', body: ddl, fence: 'sql' });
|
|
184
|
+
return {
|
|
185
|
+
documents: [buildContextDocument({
|
|
186
|
+
kind, label: schema ? `${schema}.${name}` : name, detail: `${type} in ${refOptional(ref, 'database') ?? connection.name}`,
|
|
187
|
+
facts: [...facts, ['Rows', details?.rowCount?.toLocaleString('en-US') ?? null]], sections
|
|
188
|
+
})]
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const objects = (await objectsOf(adapter, database)).slice(0, MAX_TABLES);
|
|
193
|
+
const sections: ContextSection[] = [];
|
|
194
|
+
for (const object of objects) {
|
|
195
|
+
const title = `${object.schema ? `${object.schema}.` : ''}${object.name} (${object.type})`;
|
|
196
|
+
try {
|
|
197
|
+
const details = adapter.getObjectDetails ? await within(adapter.getObjectDetails(object.name, object.type, database, object.schema), 5000, null) : null;
|
|
198
|
+
sections.push({ title, body: details ? describeColumns(details) || '(no columns reported)' : '(details unavailable)' });
|
|
199
|
+
} catch {
|
|
200
|
+
sections.push({ title, body: '(details unavailable)' });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
documents: [buildContextDocument({
|
|
205
|
+
kind: 'db-connection', label: refOptional(ref, 'database') ?? connection.name, detail: plural(objects.length, 'table'),
|
|
206
|
+
facts: [...facts, ...(objects.length >= MAX_TABLES ? [['Shown', `first ${MAX_TABLES}`] as [string, string]] : [])],
|
|
207
|
+
sections: sections.length ? sections : [{ body: 'No tables found in this database.' }]
|
|
208
|
+
})]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files, folders and lines of a file.
|
|
3
|
+
*
|
|
4
|
+
* A file is mentioned by reference — the engine reads the file itself, so it
|
|
5
|
+
* sees the current version. A folder is a listing of what is in it. Typing a
|
|
6
|
+
* path with lines (`@src/app.ts:10-24`) mentions those lines as they are now.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { readdir, readFile, stat } from 'fs/promises';
|
|
10
|
+
import { join, relative, resolve, sep, basename, dirname } from 'path';
|
|
11
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
12
|
+
import { buildContextDocument, countLines, fileReferenceDocument } from '$shared/utils/context-document';
|
|
13
|
+
import { SKIP_DIRS } from '$backend/ws/files/search';
|
|
14
|
+
import { gitText, rank, wants } from '../shared';
|
|
15
|
+
import { refOptional, refString, type MentionContext, type MentionSource } from '../types';
|
|
16
|
+
|
|
17
|
+
const CATEGORY = 'files';
|
|
18
|
+
|
|
19
|
+
/** How long a workspace's file list is reused between keystrokes. */
|
|
20
|
+
const LIST_TTL_MS = 5000;
|
|
21
|
+
/** A walk stops here; the picker only ever shows a handful. */
|
|
22
|
+
const MAX_FILES = 50_000;
|
|
23
|
+
/** A folder listing stops here. */
|
|
24
|
+
const MAX_LISTING = 2000;
|
|
25
|
+
/** Lines asked for beyond this are cut. */
|
|
26
|
+
const MAX_RANGE_LINES = 5000;
|
|
27
|
+
|
|
28
|
+
const cache = new Map<string, { at: number; files: Promise<string[]> }>();
|
|
29
|
+
|
|
30
|
+
/** Every file of a workspace, relative and `/`-separated: git's view when there is one. */
|
|
31
|
+
function workspaceFiles(root: string): Promise<string[]> {
|
|
32
|
+
const hit = cache.get(root);
|
|
33
|
+
if (hit && Date.now() - hit.at < LIST_TTL_MS) return hit.files;
|
|
34
|
+
const files = (async () => {
|
|
35
|
+
const listed = await gitText(['ls-files', '--cached', '--others', '--exclude-standard', '-z'], root, 10_000);
|
|
36
|
+
if (listed !== null) return listed.split('\0').filter(Boolean).slice(0, MAX_FILES);
|
|
37
|
+
const found: string[] = [];
|
|
38
|
+
await walk(root, root, found, 0);
|
|
39
|
+
return found;
|
|
40
|
+
})();
|
|
41
|
+
cache.set(root, { at: Date.now(), files });
|
|
42
|
+
return files;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function walk(root: string, dir: string, out: string[], depth: number): Promise<void> {
|
|
46
|
+
if (depth > 12 || out.length >= MAX_FILES) return;
|
|
47
|
+
let entries;
|
|
48
|
+
try {
|
|
49
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
50
|
+
} catch {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
if (out.length >= MAX_FILES) return;
|
|
55
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
56
|
+
const full = join(dir, entry.name);
|
|
57
|
+
if (entry.isFile()) out.push(relative(root, full).split(sep).join('/'));
|
|
58
|
+
else if (entry.isDirectory()) await walk(root, full, out, depth + 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The folders the files live in. */
|
|
63
|
+
function foldersOf(files: string[]): string[] {
|
|
64
|
+
const folders = new Set<string>();
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
let dir = dirname(file);
|
|
67
|
+
while (dir && dir !== '.' && !folders.has(dir)) {
|
|
68
|
+
folders.add(dir);
|
|
69
|
+
dir = dirname(dir);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [...folders];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A path inside the workspace, or an error. */
|
|
76
|
+
function insideRoot(root: string, path: string): string {
|
|
77
|
+
const absolute = resolve(root, path);
|
|
78
|
+
const base = resolve(root);
|
|
79
|
+
if (absolute !== base && !absolute.startsWith(base + sep)) throw new Error('That path is outside the project');
|
|
80
|
+
return absolute;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** `src/app.ts:10-24` → the path and its lines. */
|
|
84
|
+
function parseRange(query: string): { path: string; start: number; end: number } | null {
|
|
85
|
+
const match = /^(.+?):(\d+)(?:-(\d+))?$/.exec(query.trim());
|
|
86
|
+
if (!match) return null;
|
|
87
|
+
const start = Number(match[2]);
|
|
88
|
+
const end = match[3] ? Number(match[3]) : start;
|
|
89
|
+
if (start < 1 || end < start) return null;
|
|
90
|
+
return { path: match[1], start, end };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function fileRow(path: string): MentionCandidate {
|
|
94
|
+
return {
|
|
95
|
+
key: `file:${path}`,
|
|
96
|
+
kind: 'file',
|
|
97
|
+
group: 'Files',
|
|
98
|
+
label: basename(path),
|
|
99
|
+
detail: dirname(path) === '.' ? 'Project root' : dirname(path),
|
|
100
|
+
icon: 'lucide:file-code',
|
|
101
|
+
ref: { path }
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function folderRow(path: string): MentionCandidate {
|
|
106
|
+
return {
|
|
107
|
+
key: `folder:${path}`,
|
|
108
|
+
kind: 'folder',
|
|
109
|
+
group: 'Folders',
|
|
110
|
+
label: `${basename(path)}/`,
|
|
111
|
+
detail: dirname(path) === '.' ? 'Project root' : dirname(path),
|
|
112
|
+
icon: 'lucide:folder',
|
|
113
|
+
ref: { path }
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const filesSource: MentionSource = {
|
|
118
|
+
kinds: ['file', 'folder', 'code'],
|
|
119
|
+
|
|
120
|
+
categories: () => [{ id: CATEGORY, label: 'Files & folders', detail: 'By name or path; add :10-20 for lines', icon: 'lucide:file-code', group: 'Workspace' }],
|
|
121
|
+
|
|
122
|
+
async list(ctx: MentionContext, request) {
|
|
123
|
+
const mode = wants(request.category, CATEGORY);
|
|
124
|
+
if (!mode) return [];
|
|
125
|
+
// At the root a file only shows up once something is typed: listing the
|
|
126
|
+
// whole tree under an empty `@` would bury everything else.
|
|
127
|
+
if (mode === 'root' && !request.query.trim()) return [];
|
|
128
|
+
|
|
129
|
+
const files = await workspaceFiles(ctx.root);
|
|
130
|
+
const rows: MentionCandidate[] = [];
|
|
131
|
+
|
|
132
|
+
const range = parseRange(request.query);
|
|
133
|
+
if (range) {
|
|
134
|
+
const exact = files.find((file) => file === range.path) ?? rank(files, range.path, (file) => [file], 1)[0];
|
|
135
|
+
if (exact) {
|
|
136
|
+
rows.push({
|
|
137
|
+
key: `code:${exact}:${range.start}-${range.end}`,
|
|
138
|
+
kind: 'code',
|
|
139
|
+
group: 'Files',
|
|
140
|
+
label: `${basename(exact)}:${range.start}${range.end !== range.start ? `-${range.end}` : ''}`,
|
|
141
|
+
detail: `Lines ${range.start}–${range.end} of ${exact}`,
|
|
142
|
+
icon: 'lucide:text-select',
|
|
143
|
+
ref: { path: exact, start: range.start, end: range.end }
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const query = range ? range.path : request.query;
|
|
149
|
+
if (mode === 'root') {
|
|
150
|
+
rows.push(
|
|
151
|
+
...rank(files, query, (file) => [basename(file), file], 6).map(fileRow),
|
|
152
|
+
...rank(foldersOf(files), query, (folder) => [basename(folder), folder], 2).map(folderRow)
|
|
153
|
+
);
|
|
154
|
+
return rows;
|
|
155
|
+
}
|
|
156
|
+
// Ranked together, so a folder that matches best is not pushed past the
|
|
157
|
+
// end of the list by every file inside it.
|
|
158
|
+
const entries = [
|
|
159
|
+
...foldersOf(files).map((path) => ({ path, folder: true })),
|
|
160
|
+
...files.map((path) => ({ path, folder: false }))
|
|
161
|
+
];
|
|
162
|
+
// Browsing with nothing typed reads like a file tree: the top level
|
|
163
|
+
// first, folders before files, alphabetical within each.
|
|
164
|
+
if (!query.trim()) {
|
|
165
|
+
const depth = (path: string) => path.split('/').length;
|
|
166
|
+
entries.sort((a, b) => depth(a.path) - depth(b.path) || Number(b.folder) - Number(a.folder) || a.path.localeCompare(b.path));
|
|
167
|
+
}
|
|
168
|
+
const matched = rank(entries, query, (entry) => [basename(entry.path), entry.path], request.limit - rows.length);
|
|
169
|
+
rows.push(...matched.map((entry) => (entry.folder ? folderRow(entry.path) : fileRow(entry.path))));
|
|
170
|
+
return rows;
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
async capture(ctx, kind, ref) {
|
|
174
|
+
const path = refString(ref, 'path');
|
|
175
|
+
const absolute = insideRoot(ctx.root, path);
|
|
176
|
+
const display = relative(ctx.root, absolute).split(sep).join('/');
|
|
177
|
+
|
|
178
|
+
if (kind === 'file') {
|
|
179
|
+
const info = await stat(absolute);
|
|
180
|
+
if (!info.isFile()) throw new Error(`${display} is not a file`);
|
|
181
|
+
return { documents: [fileReferenceDocument(display)] };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (kind === 'folder') {
|
|
185
|
+
const files = (await workspaceFiles(ctx.root)).filter((file) => file.startsWith(`${display}/`));
|
|
186
|
+
const shown = files.slice(0, MAX_LISTING).map((file) => file.slice(display.length + 1));
|
|
187
|
+
let listing = shown.join('\n');
|
|
188
|
+
if (files.length === 0) {
|
|
189
|
+
// Not tracked by git (or empty): list what is on disk, one level.
|
|
190
|
+
const entries = await readdir(absolute, { withFileTypes: true });
|
|
191
|
+
listing = entries.map((entry) => `${entry.name}${entry.isDirectory() ? '/' : ''}`).join('\n');
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
documents: [
|
|
195
|
+
buildContextDocument({
|
|
196
|
+
kind: 'folder',
|
|
197
|
+
label: `${display}/`,
|
|
198
|
+
detail: `${files.length.toLocaleString('en-US')} files`,
|
|
199
|
+
facts: [
|
|
200
|
+
['Path', `${display}/`],
|
|
201
|
+
...(files.length > MAX_LISTING ? [['Shown', `first ${MAX_LISTING} of ${files.length}`] as [string, string]] : [])
|
|
202
|
+
],
|
|
203
|
+
sections: [{ title: 'Contents', body: listing, fence: '' }]
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Lines of a file, as they are on disk now.
|
|
210
|
+
const start = Math.max(1, Number(ref.start) || 1);
|
|
211
|
+
const end = Math.max(start, Math.min(Number(ref.end) || start, start + MAX_RANGE_LINES - 1));
|
|
212
|
+
const text = await readFile(absolute, 'utf8');
|
|
213
|
+
const lines = text.split(/\r?\n/).slice(start - 1, end);
|
|
214
|
+
const language = refOptional(ref, 'language') ?? languageOf(display);
|
|
215
|
+
return {
|
|
216
|
+
documents: [
|
|
217
|
+
buildContextDocument({
|
|
218
|
+
kind: 'code',
|
|
219
|
+
label: `${display}:${start}${end !== start ? `-${end}` : ''}`,
|
|
220
|
+
detail: countLines(lines.join('\n')),
|
|
221
|
+
facts: [['File', display], ['Lines', `${start}–${start + lines.length - 1}`]],
|
|
222
|
+
sections: [{ body: lines.join('\n'), fence: language }]
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/** A fence language from a file name; empty when unsure. */
|
|
230
|
+
export function languageOf(path: string): string {
|
|
231
|
+
const extension = path.split('.').pop()?.toLowerCase() ?? '';
|
|
232
|
+
const known: Record<string, string> = {
|
|
233
|
+
ts: 'ts', tsx: 'tsx', js: 'js', jsx: 'jsx', mjs: 'js', cjs: 'js', svelte: 'svelte', vue: 'vue',
|
|
234
|
+
py: 'python', rb: 'ruby', go: 'go', rs: 'rust', java: 'java', kt: 'kotlin', swift: 'swift',
|
|
235
|
+
c: 'c', h: 'c', cpp: 'cpp', cc: 'cpp', cs: 'csharp', php: 'php', sh: 'bash', zsh: 'bash',
|
|
236
|
+
json: 'json', yml: 'yaml', yaml: 'yaml', toml: 'toml', md: 'markdown', html: 'html',
|
|
237
|
+
css: 'css', scss: 'scss', sql: 'sql', xml: 'xml', dart: 'dart', lua: 'lua'
|
|
238
|
+
};
|
|
239
|
+
return known[extension] ?? '';
|
|
240
|
+
}
|