@myrialabs/clopen 0.4.50 → 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/engine-handoff.ts +42 -6
- package/backend/chat/stream-manager.ts +41 -5
- 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/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +11 -2
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-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/stream.ts +5 -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.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 +50 -10
- 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/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/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/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/mentions/index.ts +81 -0
- 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 +15 -16
- package/dist/assets/{index-By6KdSLT.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-DV4TiDn1.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 +6 -7
- 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/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 +1 -0
- package/shared/types/unified/message.ts +26 -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 +18 -1
- package/shared/utils/process-supervisor.ts +12 -23
- 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/index-By6KdSLT.js.br +0 -0
- package/dist/assets/index-By6KdSLT.js.gz +0 -0
- package/dist/assets/index-DV4TiDn1.js.br +0 -0
- package/dist/assets/index-DV4TiDn1.js.gz +0 -0
- package/dist/assets/main-DIESTGTD.css +0 -1
- package/dist/assets/main-DIESTGTD.css.br +0 -0
- package/dist/assets/main-DIESTGTD.css.gz +0 -0
- package/dist/assets/main-Da3JKoua.js +0 -1240
- package/dist/assets/main-Da3JKoua.js.br +0 -0
- package/dist/assets/main-Da3JKoua.js.gz +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git: the working tree, the index, one file's diff, a commit, a branch's
|
|
3
|
+
* difference from another, a stash, the files left in conflict.
|
|
4
|
+
*
|
|
5
|
+
* Always the repository of the workspace on screen (the project, or the
|
|
6
|
+
* worktree being viewed). Every snapshot is git's own text output — the
|
|
7
|
+
* format models already read best.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { readFile } from 'fs/promises';
|
|
11
|
+
import { join } from 'path';
|
|
12
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
13
|
+
import { buildContextDocument, countLines, type ContextSection } from '$shared/utils/context-document';
|
|
14
|
+
import { assertSafeGitPathOperand, assertSafeGitRevish } from '$backend/git/git-spawn-validation';
|
|
15
|
+
import { ago, gitText, rank, wants } from '../shared';
|
|
16
|
+
import { refOptional, refString, type MentionContext, type MentionSource } from '../types';
|
|
17
|
+
|
|
18
|
+
const GIT = 'git';
|
|
19
|
+
const COMMITS = 'git-commits';
|
|
20
|
+
const BRANCHES = 'git-branches';
|
|
21
|
+
|
|
22
|
+
const STATUS_TTL_MS = 2000;
|
|
23
|
+
|
|
24
|
+
interface StatusEntry {
|
|
25
|
+
path: string;
|
|
26
|
+
index: string;
|
|
27
|
+
work: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface RepoState {
|
|
31
|
+
isRepo: boolean;
|
|
32
|
+
branch: string | null;
|
|
33
|
+
entries: StatusEntry[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const statusCache = new Map<string, { at: number; state: Promise<RepoState> }>();
|
|
37
|
+
|
|
38
|
+
/** `git status`, reused across the keystrokes of one search. */
|
|
39
|
+
function repoState(root: string): Promise<RepoState> {
|
|
40
|
+
const hit = statusCache.get(root);
|
|
41
|
+
if (hit && Date.now() - hit.at < STATUS_TTL_MS) return hit.state;
|
|
42
|
+
const state = (async (): Promise<RepoState> => {
|
|
43
|
+
const out = await gitText(['status', '--porcelain=v1', '-z', '--branch', '--untracked-files=all'], root, 10_000);
|
|
44
|
+
if (out === null) return { isRepo: false, branch: null, entries: [] };
|
|
45
|
+
const records = out.split('\0');
|
|
46
|
+
let branch: string | null = null;
|
|
47
|
+
const entries: StatusEntry[] = [];
|
|
48
|
+
for (let i = 0; i < records.length; i++) {
|
|
49
|
+
const record = records[i];
|
|
50
|
+
if (!record) continue;
|
|
51
|
+
if (record.startsWith('## ')) {
|
|
52
|
+
branch = record.slice(3).split('...')[0].replace(/^No commits yet on /, '') || null;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const entry = { index: record[0], work: record[1], path: record.slice(3) };
|
|
56
|
+
// A rename is followed by its old path.
|
|
57
|
+
if (entry.index === 'R' || entry.index === 'C') i++;
|
|
58
|
+
entries.push(entry);
|
|
59
|
+
}
|
|
60
|
+
return { isRepo: true, branch, entries };
|
|
61
|
+
})();
|
|
62
|
+
statusCache.set(root, { at: Date.now(), state });
|
|
63
|
+
return state;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isConflict = (entry: StatusEntry) =>
|
|
67
|
+
entry.index === 'U' || entry.work === 'U' || (entry.index === 'A' && entry.work === 'A') || (entry.index === 'D' && entry.work === 'D');
|
|
68
|
+
const isStaged = (entry: StatusEntry) => entry.index !== ' ' && entry.index !== '?' && !isConflict(entry);
|
|
69
|
+
const isUnstaged = (entry: StatusEntry) => entry.work !== ' ' && !isConflict(entry);
|
|
70
|
+
|
|
71
|
+
function plural(count: number, noun: string): string {
|
|
72
|
+
return `${count} ${noun}${count === 1 ? '' : 's'}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The rows that describe the working tree right now. */
|
|
76
|
+
async function stateRows(ctx: MentionContext): Promise<MentionCandidate[]> {
|
|
77
|
+
const state = await repoState(ctx.root);
|
|
78
|
+
if (!state.isRepo) return [];
|
|
79
|
+
const rows: MentionCandidate[] = [];
|
|
80
|
+
const unstaged = state.entries.filter(isUnstaged);
|
|
81
|
+
const staged = state.entries.filter(isStaged);
|
|
82
|
+
const conflicts = state.entries.filter(isConflict);
|
|
83
|
+
if (unstaged.length) {
|
|
84
|
+
rows.push({
|
|
85
|
+
key: 'git-changes', kind: 'git-changes', group: 'Git', label: 'Working changes',
|
|
86
|
+
detail: `${plural(unstaged.length, 'file')} not staged`, icon: 'lucide:file-diff', ref: {}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (staged.length) {
|
|
90
|
+
rows.push({
|
|
91
|
+
key: 'git-staged', kind: 'git-staged', group: 'Git', label: 'Staged changes',
|
|
92
|
+
detail: plural(staged.length, 'file'), icon: 'lucide:git-commit-horizontal', ref: {}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (conflicts.length) {
|
|
96
|
+
rows.push({
|
|
97
|
+
key: 'git-conflicts', kind: 'git-conflicts', group: 'Git', label: 'Merge conflicts',
|
|
98
|
+
detail: `${plural(conflicts.length, 'file')} in conflict`, icon: 'lucide:git-merge', ref: {}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return rows;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function fileRows(state: RepoState): MentionCandidate[] {
|
|
105
|
+
const rows: MentionCandidate[] = [];
|
|
106
|
+
for (const entry of state.entries) {
|
|
107
|
+
if (isConflict(entry)) continue;
|
|
108
|
+
if (isStaged(entry)) {
|
|
109
|
+
rows.push({
|
|
110
|
+
key: `git-file:staged:${entry.path}`, kind: 'git-file', group: 'Changed files', label: entry.path,
|
|
111
|
+
detail: `staged · ${describeStatus(entry.index)}`, icon: 'lucide:file-diff', ref: { path: entry.path, staged: true }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (isUnstaged(entry)) {
|
|
115
|
+
rows.push({
|
|
116
|
+
key: `git-file:work:${entry.path}`, kind: 'git-file', group: 'Changed files', label: entry.path,
|
|
117
|
+
detail: entry.work === '?' ? 'untracked' : describeStatus(entry.work), icon: 'lucide:file-diff',
|
|
118
|
+
ref: { path: entry.path, staged: false, untracked: entry.work === '?' }
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return rows;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function describeStatus(code: string): string {
|
|
126
|
+
return ({ M: 'modified', A: 'added', D: 'deleted', R: 'renamed', C: 'copied', T: 'type changed' } as Record<string, string>)[code] ?? 'changed';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function commitRows(root: string, query: string, limit: number): Promise<MentionCandidate[]> {
|
|
130
|
+
const out = await gitText(['log', '-n', '300', '--format=%H%x1f%h%x1f%s%x1f%an%x1f%aI'], root, 10_000);
|
|
131
|
+
if (!out) return [];
|
|
132
|
+
const commits = out.split('\n').filter(Boolean).map((line) => {
|
|
133
|
+
const [hash, short, subject, author, date] = line.split('\x1f');
|
|
134
|
+
return { hash, short, subject, author, date };
|
|
135
|
+
});
|
|
136
|
+
return rank(commits, query, (commit) => [commit.subject, commit.short, commit.hash, commit.author], limit).map((commit) => ({
|
|
137
|
+
key: `git-commit:${commit.hash}`, kind: 'git-commit', group: 'Commits', label: commit.subject || commit.short,
|
|
138
|
+
detail: `${commit.short} · ${commit.author} · ${ago(commit.date)}`, icon: 'lucide:git-commit-horizontal',
|
|
139
|
+
ref: { hash: commit.hash }
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function branchRows(root: string, current: string | null, query: string, limit: number): Promise<MentionCandidate[]> {
|
|
144
|
+
const out = await gitText(['for-each-ref', '--sort=-committerdate', '--format=%(refname:short)', 'refs/heads', 'refs/remotes'], root, 10_000);
|
|
145
|
+
if (!out) return [];
|
|
146
|
+
const branches = out.split('\n').filter((name) => name && name !== current && !name.endsWith('/HEAD'));
|
|
147
|
+
return rank(branches, query, (name) => [name], limit).map((name) => ({
|
|
148
|
+
key: `git-branch:${name}`, kind: 'git-branch', group: 'Branches', label: `${current ?? 'HEAD'} compared with ${name}`,
|
|
149
|
+
detail: 'Commits and changes since they diverged', icon: 'lucide:git-compare', ref: { base: name }
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function stashRows(root: string): Promise<MentionCandidate[]> {
|
|
154
|
+
const out = await gitText(['stash', 'list', '--format=%gd%x1f%s%x1f%cI'], root, 10_000);
|
|
155
|
+
if (!out) return [];
|
|
156
|
+
return out.split('\n').filter(Boolean).map((line) => {
|
|
157
|
+
const [ref, subject, date] = line.split('\x1f');
|
|
158
|
+
return {
|
|
159
|
+
key: `git-stash:${ref}`, kind: 'git-stash' as const, group: 'Stashes', label: subject || ref,
|
|
160
|
+
detail: `${ref} · ${ago(date)}`, icon: 'lucide:archive' as const, ref: { stash: ref }
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function diffSection(title: string, diff: string | null): ContextSection {
|
|
166
|
+
return { title, body: diff?.trim() ? diff : 'No differences.', fence: 'diff' };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const gitSource: MentionSource = {
|
|
170
|
+
kinds: ['git-changes', 'git-staged', 'git-file', 'git-commit', 'git-branch', 'git-stash', 'git-conflicts'],
|
|
171
|
+
|
|
172
|
+
async categories(ctx) {
|
|
173
|
+
const state = await repoState(ctx.root);
|
|
174
|
+
if (!state.isRepo) return [];
|
|
175
|
+
return [
|
|
176
|
+
{ id: GIT, label: 'Git changes', detail: state.entries.length ? plural(state.entries.length, 'changed file') : 'Clean', icon: 'lucide:file-diff', group: 'Git' },
|
|
177
|
+
{ id: COMMITS, label: 'Commits', detail: state.branch ? `History of ${state.branch}` : 'History of this branch', icon: 'lucide:git-commit-horizontal', group: 'Git' },
|
|
178
|
+
{ id: BRANCHES, label: 'Branches', detail: 'Compare with another branch', icon: 'lucide:git-branch', group: 'Git' }
|
|
179
|
+
];
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
async list(ctx, request) {
|
|
183
|
+
const query = request.query;
|
|
184
|
+
if (!request.category) {
|
|
185
|
+
const rows = await stateRows(ctx);
|
|
186
|
+
if (!query.trim()) return rows;
|
|
187
|
+
// Typing a hash finds its commit straight from the root.
|
|
188
|
+
const commits = /^[0-9a-f]{5,40}$/i.test(query.trim()) ? await commitRows(ctx.root, query, 2) : [];
|
|
189
|
+
return [...rank(rows, query, (row) => [row.label, 'git', 'diff'], 3), ...commits];
|
|
190
|
+
}
|
|
191
|
+
if (wants(request.category, GIT) === 'own') {
|
|
192
|
+
const state = await repoState(ctx.root);
|
|
193
|
+
const rows = [...(await stateRows(ctx)), ...fileRows(state), ...(await stashRows(ctx.root))];
|
|
194
|
+
return rank(rows, query, (row) => [row.label, row.detail], request.limit);
|
|
195
|
+
}
|
|
196
|
+
if (wants(request.category, COMMITS) === 'own') return commitRows(ctx.root, query, request.limit);
|
|
197
|
+
if (wants(request.category, BRANCHES) === 'own') {
|
|
198
|
+
const state = await repoState(ctx.root);
|
|
199
|
+
return branchRows(ctx.root, state.branch, query, request.limit);
|
|
200
|
+
}
|
|
201
|
+
return [];
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
async capture(ctx, kind, ref) {
|
|
205
|
+
const root = ctx.root;
|
|
206
|
+
const state = await repoState(root);
|
|
207
|
+
if (!state.isRepo) throw new Error('This project is not a git repository');
|
|
208
|
+
statusCache.delete(root);
|
|
209
|
+
const branchFact: [string, string | null] = ['Branch', state.branch];
|
|
210
|
+
|
|
211
|
+
switch (kind) {
|
|
212
|
+
case 'git-changes': {
|
|
213
|
+
const status = await gitText(['status', '--short'], root);
|
|
214
|
+
const diff = await gitText(['diff'], root, 60_000);
|
|
215
|
+
return {
|
|
216
|
+
documents: [buildContextDocument({
|
|
217
|
+
kind, label: 'Working changes', detail: countLines(diff ?? ''), facts: [branchFact],
|
|
218
|
+
sections: [{ title: 'Status', body: status ?? '', fence: '' }, diffSection('Unstaged diff', diff)]
|
|
219
|
+
})]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
case 'git-staged': {
|
|
223
|
+
const diff = await gitText(['diff', '--cached'], root, 60_000);
|
|
224
|
+
return {
|
|
225
|
+
documents: [buildContextDocument({
|
|
226
|
+
kind, label: 'Staged changes', detail: countLines(diff ?? ''), facts: [branchFact],
|
|
227
|
+
sections: [diffSection('Staged diff', diff)]
|
|
228
|
+
})]
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
case 'git-file': {
|
|
232
|
+
const path = refString(ref, 'path');
|
|
233
|
+
assertSafeGitPathOperand(path, 'diff path');
|
|
234
|
+
const diff = ref.untracked
|
|
235
|
+
? await gitText(['diff', '--no-index', '--', '/dev/null', path], root, 30_000, [1])
|
|
236
|
+
: await gitText(ref.staged ? ['diff', '--cached', '--', path] : ['diff', '--', path], root, 30_000);
|
|
237
|
+
return {
|
|
238
|
+
documents: [buildContextDocument({
|
|
239
|
+
kind, label: path, detail: ref.staged ? 'staged' : ref.untracked ? 'untracked' : 'not staged',
|
|
240
|
+
facts: [branchFact, ['File', path]], sections: [diffSection('Diff', diff)]
|
|
241
|
+
})]
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
case 'git-commit': {
|
|
245
|
+
const hash = refString(ref, 'hash');
|
|
246
|
+
assertSafeGitRevish(hash, 'commit hash');
|
|
247
|
+
const shown = await gitText(['show', '--stat', '--patch', '--format=fuller', hash], root, 60_000);
|
|
248
|
+
if (shown === null) throw new Error('That commit was not found');
|
|
249
|
+
const subject = (await gitText(['log', '-1', '--format=%s', hash], root))?.trim() || hash.slice(0, 7);
|
|
250
|
+
return {
|
|
251
|
+
documents: [buildContextDocument({
|
|
252
|
+
kind, label: subject, detail: hash.slice(0, 12), facts: [['Commit', hash]],
|
|
253
|
+
sections: [{ title: 'Commit', body: shown, fence: 'diff' }]
|
|
254
|
+
})]
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
case 'git-branch': {
|
|
258
|
+
const base = refString(ref, 'base');
|
|
259
|
+
assertSafeGitRevish(base, 'branch');
|
|
260
|
+
const head = state.branch ?? 'HEAD';
|
|
261
|
+
const log = await gitText(['log', '--oneline', `${base}..HEAD`], root, 30_000);
|
|
262
|
+
const diff = await gitText(['diff', `${base}...HEAD`], root, 60_000);
|
|
263
|
+
return {
|
|
264
|
+
documents: [buildContextDocument({
|
|
265
|
+
kind, label: `${head} vs ${base}`, detail: plural((log ?? '').split('\n').filter(Boolean).length, 'commit'),
|
|
266
|
+
facts: [['Branch', head], ['Compared with', base]],
|
|
267
|
+
sections: [{ title: `Commits on ${head} not on ${base}`, body: log ?? '', fence: '' }, diffSection('Diff', diff)]
|
|
268
|
+
})]
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
case 'git-stash': {
|
|
272
|
+
const stash = refString(ref, 'stash');
|
|
273
|
+
if (!/^stash@\{\d+\}$/.test(stash)) throw new Error('Not a stash');
|
|
274
|
+
const diff = await gitText(['stash', 'show', '-p', '--include-untracked', stash], root, 30_000)
|
|
275
|
+
?? await gitText(['stash', 'show', '-p', stash], root, 30_000);
|
|
276
|
+
return {
|
|
277
|
+
documents: [buildContextDocument({
|
|
278
|
+
kind, label: refOptional(ref, 'label') ?? stash, detail: stash, facts: [branchFact],
|
|
279
|
+
sections: [diffSection('Stashed changes', diff)]
|
|
280
|
+
})]
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
case 'git-conflicts': {
|
|
284
|
+
const conflicted = state.entries.filter(isConflict).map((entry) => entry.path);
|
|
285
|
+
const sections: ContextSection[] = [];
|
|
286
|
+
for (const path of conflicted) {
|
|
287
|
+
let body: string;
|
|
288
|
+
try {
|
|
289
|
+
body = await readFile(join(root, path), 'utf8');
|
|
290
|
+
} catch {
|
|
291
|
+
body = '(deleted on one side)';
|
|
292
|
+
}
|
|
293
|
+
sections.push({ title: path, body, fence: '' });
|
|
294
|
+
}
|
|
295
|
+
const operation = await gitText(['rev-parse', '--verify', '-q', 'MERGE_HEAD'], root) ? 'merge'
|
|
296
|
+
: await gitText(['rev-parse', '--verify', '-q', 'REBASE_HEAD'], root) ? 'rebase' : 'operation';
|
|
297
|
+
return {
|
|
298
|
+
documents: [buildContextDocument({
|
|
299
|
+
kind, label: 'Merge conflicts', detail: plural(conflicted.length, 'file'),
|
|
300
|
+
facts: [branchFact, ['In progress', operation], ['Files', conflicted.join(', ')]], sections
|
|
301
|
+
})]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
default:
|
|
305
|
+
throw new Error(`Git cannot capture ${kind}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notes (this project's and the global ones) and memories from the memory
|
|
3
|
+
* graph.
|
|
4
|
+
*
|
|
5
|
+
* A note is attached as its markdown. A memory is attached with the memories
|
|
6
|
+
* it is connected to, because the one that answers the question is often
|
|
7
|
+
* next to the one that was found.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
11
|
+
import type { GraphNode } from '$shared/types/memory';
|
|
12
|
+
import { buildContextDocument } from '$shared/utils/context-document';
|
|
13
|
+
import { noteCollectionQueries, noteQueries } from '$backend/database/queries/note-queries';
|
|
14
|
+
import { canAccessCollection } from '$backend/notes/access';
|
|
15
|
+
import { retrieve } from '$backend/memory/retrieval';
|
|
16
|
+
import { buildNodeDetail } from '$backend/memory/view';
|
|
17
|
+
import { graphQueries } from '$backend/database/queries';
|
|
18
|
+
import { ago, rank, wants } from '../shared';
|
|
19
|
+
import { refString, type MentionContext, type MentionSource } from '../types';
|
|
20
|
+
|
|
21
|
+
const NOTES = 'notes';
|
|
22
|
+
const MEMORY = 'memory';
|
|
23
|
+
|
|
24
|
+
function notesOf(ctx: MentionContext) {
|
|
25
|
+
const collections = [
|
|
26
|
+
...noteCollectionQueries.listByScope('project', ctx.projectId),
|
|
27
|
+
...noteCollectionQueries.listByScope('global', null)
|
|
28
|
+
].filter(canAccessCollection);
|
|
29
|
+
const names = new Map(collections.map((collection) => [collection.id, collection]));
|
|
30
|
+
return noteQueries
|
|
31
|
+
.listByCollections(collections.map((collection) => collection.id))
|
|
32
|
+
.sort((a, b) => b.updated_at.localeCompare(a.updated_at))
|
|
33
|
+
.map((note) => ({ note, collection: names.get(note.collection_id)! }));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function noteTitle(note: { title: string | null; content: string }): string {
|
|
37
|
+
return note.title?.trim() || note.content.trim().split('\n')[0].replace(/^#+\s*/, '').slice(0, 80) || 'Untitled note';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function memoryRow(node: GraphNode): MentionCandidate {
|
|
41
|
+
return {
|
|
42
|
+
key: `memory:${node.id}`, kind: 'memory', group: 'Memory', label: node.label,
|
|
43
|
+
detail: `${node.subkind} · ${ago(node.updatedAt)}`, icon: 'lucide:brain', ref: { nodeId: node.id }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Below this a memory search matches everything and nothing in particular. */
|
|
48
|
+
const MIN_MEMORY_QUERY = 3;
|
|
49
|
+
|
|
50
|
+
/** Opened with nothing typed: the user's standing instructions, then what was learned lately. */
|
|
51
|
+
function recentMemories(ctx: MentionContext, limit: number): MentionCandidate[] {
|
|
52
|
+
const seen = new Set<string>();
|
|
53
|
+
const nodes = [...graphQueries.standingInstructions(ctx.projectId, limit), ...graphQueries.timeline({ projectId: ctx.projectId, limit })];
|
|
54
|
+
return nodes.filter((node) => !seen.has(node.id) && seen.add(node.id)).slice(0, limit).map(memoryRow);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function memories(ctx: MentionContext, query: string, limit: number): MentionCandidate[] {
|
|
58
|
+
if (query.trim().length < MIN_MEMORY_QUERY) return [];
|
|
59
|
+
const result = retrieve({ query, projectIds: [ctx.projectId], limit, expandHops: 0, precise: true });
|
|
60
|
+
return result.hits.map((hit) => memoryRow(hit.node));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const notesMemorySource: MentionSource = {
|
|
64
|
+
kinds: ['note', 'memory'],
|
|
65
|
+
|
|
66
|
+
categories: () => [
|
|
67
|
+
{ id: NOTES, label: 'Notes', detail: 'This project’s notes and global ones', icon: 'lucide:notebook-pen', group: 'Knowledge' },
|
|
68
|
+
{ id: MEMORY, label: 'Memory', detail: 'Search what past sessions learned', icon: 'lucide:brain', group: 'Knowledge' }
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
async list(ctx, request) {
|
|
72
|
+
const noteRows = () =>
|
|
73
|
+
notesOf(ctx).map(({ note, collection }): MentionCandidate => ({
|
|
74
|
+
key: `note:${note.id}`, kind: 'note', group: 'Notes', label: noteTitle(note),
|
|
75
|
+
detail: `${collection.name}${collection.scope === 'global' ? ' (global)' : ''} · ${ago(note.updated_at)}`,
|
|
76
|
+
icon: 'lucide:notebook-pen', ref: { noteId: note.id }
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
if (wants(request.category, NOTES) === 'own') return rank(noteRows(), request.query, (row) => [row.label, row.detail], request.limit);
|
|
80
|
+
if (wants(request.category, MEMORY) === 'own') {
|
|
81
|
+
return request.query.trim() ? memories(ctx, request.query, request.limit) : recentMemories(ctx, request.limit);
|
|
82
|
+
}
|
|
83
|
+
if (request.category || !request.query.trim()) return [];
|
|
84
|
+
return [...rank(noteRows(), request.query, (row) => [row.label], 2), ...memories(ctx, request.query, 2)];
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
async capture(_ctx, kind, ref) {
|
|
88
|
+
if (kind === 'note') {
|
|
89
|
+
const noteId = refString(ref, 'noteId');
|
|
90
|
+
const collection = noteCollectionQueries.getForNote(noteId);
|
|
91
|
+
if (!collection || !canAccessCollection(collection)) throw new Error('That note is gone');
|
|
92
|
+
const note = noteQueries.getById(noteId);
|
|
93
|
+
if (!note) throw new Error('That note is gone');
|
|
94
|
+
return {
|
|
95
|
+
documents: [buildContextDocument({
|
|
96
|
+
kind, label: noteTitle(note), detail: collection.name,
|
|
97
|
+
facts: [['Collection', `${collection.name} (${collection.scope})`], ['Updated', note.updated_at],
|
|
98
|
+
['Images', note.images.length ? note.images.map((image) => image.file_name).join(', ') : null]],
|
|
99
|
+
sections: [{ title: 'Note', body: note.content }]
|
|
100
|
+
})]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const detail = buildNodeDetail(refString(ref, 'nodeId'), 1);
|
|
105
|
+
if (!detail?.node) throw new Error('That memory is gone');
|
|
106
|
+
const { node, neighbours } = detail;
|
|
107
|
+
const related = neighbours
|
|
108
|
+
.filter((entry) => entry.node.id !== node.id)
|
|
109
|
+
.slice(0, 12)
|
|
110
|
+
.map((entry) => `### ${entry.node.label} (${entry.node.subkind})\n\n${entry.node.body}`)
|
|
111
|
+
.join('\n\n');
|
|
112
|
+
return {
|
|
113
|
+
documents: [buildContextDocument({
|
|
114
|
+
kind, label: node.label, detail: node.subkind,
|
|
115
|
+
facts: [['Kind', node.subkind], ['Scope', node.scope], ['Confidence', node.confidence.toFixed(2)],
|
|
116
|
+
['Paths', node.relatedPaths?.length ? node.relatedPaths.join(', ') : null]],
|
|
117
|
+
sections: [{ title: 'Memory', body: node.body }, ...(related ? [{ title: 'Connected memories', body: related }] : [])]
|
|
118
|
+
})]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the project runs: its deployments and the containers on this machine.
|
|
3
|
+
*
|
|
4
|
+
* A deployment is attached with its build log — the thing asked about when a
|
|
5
|
+
* build fails. A container is attached with how it is set up and what it wrote
|
|
6
|
+
* last. Both talk to something outside Clopen, so they are only listed when
|
|
7
|
+
* their category is opened, never on a keystroke at the root.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { MentionCandidate } from '$shared/types/mentions';
|
|
11
|
+
import { LOCAL_HOST_ID } from '$shared/types/host';
|
|
12
|
+
import { buildContextDocument, countLines } from '$shared/utils/context-document';
|
|
13
|
+
import { deployService } from '$backend/deployments/service';
|
|
14
|
+
import { containerMonitor } from '$backend/containers/monitor';
|
|
15
|
+
import { inspectContainer, readRecentLogs } from '$backend/containers/actions';
|
|
16
|
+
import { sshConnectionQueries } from '$backend/database/queries';
|
|
17
|
+
import { ago, rank, within } from '../shared';
|
|
18
|
+
import { refOptional, refString, type MentionSource } from '../types';
|
|
19
|
+
|
|
20
|
+
const DEPLOYMENTS = 'deployments';
|
|
21
|
+
const CONTAINERS = 'containers';
|
|
22
|
+
|
|
23
|
+
/** The local machine, or a saved SSH host that still exists. */
|
|
24
|
+
function requireHost(hostId: string): void {
|
|
25
|
+
if (hostId !== LOCAL_HOST_ID) sshConnectionQueries.require(hostId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const deploymentsSource: MentionSource = {
|
|
29
|
+
kinds: ['deployment'],
|
|
30
|
+
|
|
31
|
+
categories: () => [{ id: DEPLOYMENTS, label: 'Deployments', detail: 'Builds and their logs', icon: 'lucide:rocket', group: 'Ops' }],
|
|
32
|
+
|
|
33
|
+
async list(ctx, request) {
|
|
34
|
+
if (request.category !== DEPLOYMENTS) return [];
|
|
35
|
+
const sources = await within(deployService.listSources(ctx.projectId, ctx.projectPath), 10_000, []);
|
|
36
|
+
const rows: MentionCandidate[] = [];
|
|
37
|
+
for (const source of sources.filter((entry) => entry.binding && entry.status === 'ok')) {
|
|
38
|
+
const page = await within(deployService.list(ctx.projectId, source.accountId, { environment: 'all' }), 10_000, null);
|
|
39
|
+
for (const deployment of page?.items.slice(0, 20) ?? []) {
|
|
40
|
+
rows.push({
|
|
41
|
+
key: `deployment:${source.accountId}:${deployment.id}`,
|
|
42
|
+
kind: 'deployment',
|
|
43
|
+
group: source.providerName,
|
|
44
|
+
label: deployment.commitMessage?.split('\n')[0] || deployment.name,
|
|
45
|
+
detail: [deployment.state, deployment.environment, deployment.branch, ago(deployment.createdAt)].filter(Boolean).join(' · '),
|
|
46
|
+
icon: 'lucide:rocket',
|
|
47
|
+
ref: { accountId: source.accountId, deploymentId: deployment.id }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return rank(rows, request.query, (row) => [row.label, row.detail], request.limit);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
async capture(ctx, _kind, ref) {
|
|
55
|
+
const accountId = refString(ref, 'accountId');
|
|
56
|
+
const deploymentId = refString(ref, 'deploymentId');
|
|
57
|
+
const detail = await deployService.get(ctx.projectId, accountId, deploymentId);
|
|
58
|
+
const logs = await deployService.fetchLogs(ctx.projectId, accountId, deploymentId).catch(() => null);
|
|
59
|
+
return {
|
|
60
|
+
documents: [buildContextDocument({
|
|
61
|
+
kind: 'deployment',
|
|
62
|
+
label: detail.commitMessage?.split('\n')[0] || detail.name,
|
|
63
|
+
detail: `${detail.state} · ${detail.environment}`,
|
|
64
|
+
facts: [
|
|
65
|
+
['Project', detail.name], ['State', `${detail.state} (${detail.stateDetail})`], ['Environment', detail.environment],
|
|
66
|
+
['URL', detail.url], ['Dashboard', detail.inspectorUrl], ['Branch', detail.branch], ['Commit', detail.commitSha],
|
|
67
|
+
['Created', detail.createdAt], ['Error', [detail.errorCode, detail.errorMessage].filter(Boolean).join(': ') || null]
|
|
68
|
+
],
|
|
69
|
+
sections: [{
|
|
70
|
+
title: `Build log${logs?.truncated ? ' (the provider cut it short)' : ''}`,
|
|
71
|
+
body: logs?.text || 'The provider returned no log.',
|
|
72
|
+
fence: 'text'
|
|
73
|
+
}]
|
|
74
|
+
})]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const containersSource: MentionSource = {
|
|
80
|
+
kinds: ['container'],
|
|
81
|
+
|
|
82
|
+
categories: () => [{ id: CONTAINERS, label: 'Containers', detail: 'On this machine', icon: 'lucide:container', group: 'Ops' }],
|
|
83
|
+
|
|
84
|
+
async list(_ctx, request) {
|
|
85
|
+
if (request.category !== CONTAINERS) return [];
|
|
86
|
+
const scan = await within(containerMonitor.scanOnce(LOCAL_HOST_ID), 15_000, null);
|
|
87
|
+
const rows = (scan?.entries ?? []).map((entry): MentionCandidate => ({
|
|
88
|
+
key: `container:${entry.id}`,
|
|
89
|
+
kind: 'container',
|
|
90
|
+
group: 'Containers',
|
|
91
|
+
label: entry.name,
|
|
92
|
+
detail: `${entry.image} · ${entry.statusText}`,
|
|
93
|
+
icon: 'lucide:container',
|
|
94
|
+
ref: { hostId: LOCAL_HOST_ID, containerId: entry.id, name: entry.name }
|
|
95
|
+
}));
|
|
96
|
+
return rank(rows, request.query, (row) => [row.label, row.detail], request.limit);
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
async capture(_ctx, _kind, ref) {
|
|
100
|
+
const hostId = refOptional(ref, 'hostId') ?? LOCAL_HOST_ID;
|
|
101
|
+
requireHost(hostId);
|
|
102
|
+
const containerId = refString(ref, 'containerId');
|
|
103
|
+
const entry = await containerMonitor.findContainer(hostId, containerId);
|
|
104
|
+
if (!entry) throw new Error('That container no longer exists');
|
|
105
|
+
const inspected = await inspectContainer(hostId, containerId).catch(() => null);
|
|
106
|
+
const logs = (await readRecentLogs(hostId, containerId)) ?? '';
|
|
107
|
+
return {
|
|
108
|
+
documents: [buildContextDocument({
|
|
109
|
+
kind: 'container',
|
|
110
|
+
label: entry.name,
|
|
111
|
+
detail: entry.statusText,
|
|
112
|
+
facts: [
|
|
113
|
+
['Host', hostId === LOCAL_HOST_ID ? 'this machine' : hostId], ['Image', entry.image], ['Id', entry.shortId],
|
|
114
|
+
['State', `${entry.state} · ${entry.statusText}`], ['Health', entry.health], ['Command', entry.command],
|
|
115
|
+
['Ports', entry.ports.map((port) => `${port.hostPort ? `${port.hostAddress ?? ''}:${port.hostPort}->` : ''}${port.containerPort}/${port.protocol}`).join(', ') || null],
|
|
116
|
+
['Compose', entry.composeProject ? `${entry.composeProject} / ${entry.composeService}` : null]
|
|
117
|
+
],
|
|
118
|
+
sections: [
|
|
119
|
+
...(inspected ? [{ title: 'Inspect', body: JSON.stringify(inspected, null, 2), fence: 'json' }] : []),
|
|
120
|
+
{ title: `Recent logs · ${countLines(logs)}`, body: logs || 'No output.', fence: 'text' }
|
|
121
|
+
]
|
|
122
|
+
})]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|