@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Projects: list, open, Home, and adding one by walking the
|
|
3
|
-
* folders (making, renaming or deleting folders on the way).
|
|
2
|
+
* Projects: list, open, Home, rename, and adding one by walking the
|
|
3
|
+
* machine's folders (making, renaming or deleting folders on the way).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { t } from 'elysia';
|
|
@@ -9,12 +9,13 @@ import { basename, dirname, isAbsolute, join, resolve, sep } from 'path';
|
|
|
9
9
|
import { homedir } from 'os';
|
|
10
10
|
import { projectQueries } from '$backend/database/queries';
|
|
11
11
|
import { ensureHomeProject } from '$backend/projects/home';
|
|
12
|
+
import { projectAtFolder, protectedFolderReason, validFolderName } from '$backend/projects/folder-guard';
|
|
13
|
+
import type { MoveOutcome } from '$backend/projects/move';
|
|
14
|
+
import { getProjectUsage } from '$backend/projects/move';
|
|
12
15
|
import { homeFirst, isHomeProject, HOME_PROJECT_NAME } from '$shared/utils/home-project';
|
|
13
16
|
import type { Project } from '$shared/types/database/schema';
|
|
14
17
|
import { defineAction } from '../define';
|
|
15
18
|
import type { ControlChoice, ControlResult } from '../types';
|
|
16
|
-
import { isPathInside } from '$backend/worktrees';
|
|
17
|
-
import { getClopenDir } from '$backend/utils/paths';
|
|
18
19
|
import { latestSession, projectLabel } from '../workspace';
|
|
19
20
|
import { paged } from '../paging';
|
|
20
21
|
|
|
@@ -96,30 +97,6 @@ function shortPath(path: string): string {
|
|
|
96
97
|
/** Folders not worth walking into when looking for a project. */
|
|
97
98
|
const SKIPPED_FOLDERS = new Set(['node_modules', 'Library', 'Applications', 'AppData']);
|
|
98
99
|
|
|
99
|
-
/**
|
|
100
|
-
* Why a folder must not be renamed or deleted from a chat, or null when it
|
|
101
|
-
* may. The home folder and everything above it, Clopen's own data, and any
|
|
102
|
-
* folder that is (or holds) a project are off limits: a project whose folder
|
|
103
|
-
* moved or vanished is broken in Clopen for everyone who has it.
|
|
104
|
-
*/
|
|
105
|
-
function protectedReason(folder: string): string | null {
|
|
106
|
-
if (folder === resolve(sep) || isPathInside(folder, homedir())) return 'it is your home folder or one above it';
|
|
107
|
-
const data = getClopenDir();
|
|
108
|
-
if (isPathInside(data, folder) || isPathInside(folder, data)) return "it holds Clopen's own data";
|
|
109
|
-
const project = projectQueries.getAll().find((entry) => isPathInside(folder, resolve(entry.path)));
|
|
110
|
-
if (project) return `it ${resolve(project.path) === folder ? 'is' : 'holds'} the project ${isHomeProject(project) ? HOME_PROJECT_NAME : project.name}`;
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** A folder name typed in a chat: one path segment, nothing that climbs out. */
|
|
115
|
-
function folderName(input: string | undefined): string {
|
|
116
|
-
const name = (input ?? '').trim();
|
|
117
|
-
if (!name || name === '.' || name === '..' || /[/\\\0]/.test(name) || name.length > 255) {
|
|
118
|
-
throw new Error('That is not a folder name. Use a single name, without slashes.');
|
|
119
|
-
}
|
|
120
|
-
return name;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
100
|
function existingFolder(path: string): string {
|
|
124
101
|
const folder = normalisePath(path);
|
|
125
102
|
if (!existsSync(folder) || !statSync(folder).isDirectory()) throw new Error(`There is no folder at ${shortPath(folder)}.`);
|
|
@@ -137,7 +114,7 @@ function browse(folder: string, page: number | undefined, note?: string): Contro
|
|
|
137
114
|
} catch {
|
|
138
115
|
throw new Error(`Clopen cannot read ${shortPath(folder)}.`);
|
|
139
116
|
}
|
|
140
|
-
const existing =
|
|
117
|
+
const existing = projectAtFolder(folder);
|
|
141
118
|
const { choices, range } = paged(
|
|
142
119
|
entries,
|
|
143
120
|
page,
|
|
@@ -145,13 +122,16 @@ function browse(folder: string, page: number | undefined, note?: string): Contro
|
|
|
145
122
|
{ action: 'projects.browse', args: { path: folder } }
|
|
146
123
|
);
|
|
147
124
|
const parent = dirname(folder);
|
|
148
|
-
const locked =
|
|
125
|
+
const locked = protectedFolderReason(folder) !== null;
|
|
126
|
+
// A project's own folder is renamed with the project, so it stays a project.
|
|
127
|
+
const renamable = existing && !isHomeProject(existing) && protectedFolderReason(folder, existing.id) === null;
|
|
149
128
|
const top: ControlChoice[] = [
|
|
150
129
|
existing
|
|
151
130
|
? { label: `📂 Open ${existing.name}`, action: 'projects.open', args: { projectId: existing.id } }
|
|
152
131
|
: { label: `✅ Add ${basename(folder) || folder} as a project`, action: 'projects.create', args: { path: folder } },
|
|
153
132
|
...(parent !== folder ? [{ label: '⬆️ Up', action: 'projects.browse', args: { path: parent } }] : []),
|
|
154
133
|
{ label: '➕ New folder here', action: 'projects.mkdir', args: { path: folder } },
|
|
134
|
+
...(renamable ? [{ label: '✏️ Rename this project', action: 'projects.rename', args: { projectId: existing.id } }] : []),
|
|
155
135
|
...(locked
|
|
156
136
|
? []
|
|
157
137
|
: [
|
|
@@ -196,7 +176,7 @@ export const makeFolder = defineAction({
|
|
|
196
176
|
if (args.name === undefined) {
|
|
197
177
|
return { text: `📂 \`${shortPath(parent)}\``, ask: { question: 'Name of the new folder?', action: 'projects.mkdir', args: { path: parent }, key: 'name' } };
|
|
198
178
|
}
|
|
199
|
-
const folder = join(parent,
|
|
179
|
+
const folder = join(parent, validFolderName(args.name));
|
|
200
180
|
if (existsSync(folder)) throw new Error(`${shortPath(folder)} already exists.`);
|
|
201
181
|
mkdirSync(folder);
|
|
202
182
|
return browse(folder, 0, `✅ Created \`${shortPath(folder)}\`.`);
|
|
@@ -211,12 +191,19 @@ export const renameFolder = defineAction({
|
|
|
211
191
|
args: t.Object({ path: t.String({ minLength: 1 }), name: t.Optional(t.String()) }),
|
|
212
192
|
async run(_ctx, args) {
|
|
213
193
|
const folder = existingFolder(args.path);
|
|
214
|
-
const
|
|
194
|
+
const project = projectAtFolder(folder);
|
|
195
|
+
if (project && !isHomeProject(project) && projectQueries.isListed(project.id)) {
|
|
196
|
+
return {
|
|
197
|
+
text: `📂 \`${shortPath(folder)}\` is the project **${escapeMd(project.name)}**: renaming it renames the project too.`,
|
|
198
|
+
choices: [{ label: '✏️ Rename this project', action: 'projects.rename', args: { projectId: project.id } }]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const reason = protectedFolderReason(folder);
|
|
215
202
|
if (reason) throw new Error(`${shortPath(folder)} cannot be renamed here: ${reason}.`);
|
|
216
203
|
if (args.name === undefined) {
|
|
217
204
|
return { text: `📂 \`${shortPath(folder)}\``, ask: { question: `New name for ${basename(folder)}?`, action: 'projects.rename-folder', args: { path: folder }, key: 'name' } };
|
|
218
205
|
}
|
|
219
|
-
const renamed = join(dirname(folder),
|
|
206
|
+
const renamed = join(dirname(folder), validFolderName(args.name));
|
|
220
207
|
if (renamed === folder) return browse(folder, 0);
|
|
221
208
|
if (existsSync(renamed)) throw new Error(`${shortPath(renamed)} already exists.`);
|
|
222
209
|
renameSync(folder, renamed);
|
|
@@ -242,7 +229,7 @@ export const deleteFolder = defineAction({
|
|
|
242
229
|
},
|
|
243
230
|
async run(_ctx, args) {
|
|
244
231
|
const folder = existingFolder(args.path);
|
|
245
|
-
const reason =
|
|
232
|
+
const reason = protectedFolderReason(folder);
|
|
246
233
|
if (reason) throw new Error(`${shortPath(folder)} cannot be deleted here: ${reason}.`);
|
|
247
234
|
rmSync(folder, { recursive: true, force: true });
|
|
248
235
|
return browse(dirname(folder), 0, `🗑️ Deleted \`${shortPath(folder)}\`.`);
|
|
@@ -253,12 +240,12 @@ export const createProject = defineAction({
|
|
|
253
240
|
id: 'projects.create',
|
|
254
241
|
group: 'projects',
|
|
255
242
|
title: 'Add project',
|
|
256
|
-
description: 'Add a folder on this machine as a project, and switch to it.',
|
|
257
|
-
args: t.Object({ path: t.String({ minLength: 1 })
|
|
243
|
+
description: 'Add a folder on this machine as a project, and switch to it. The project is named after the folder.',
|
|
244
|
+
args: t.Object({ path: t.String({ minLength: 1 }) }),
|
|
258
245
|
async run(ctx, args) {
|
|
259
246
|
const path = normalisePath(args.path);
|
|
260
247
|
if (!existsSync(path) || !statSync(path).isDirectory()) throw new Error(`There is no folder at ${shortPath(path)}.`);
|
|
261
|
-
const project = await ctx.call<Project>('projects:create', {
|
|
248
|
+
const project = await ctx.call<Project>('projects:create', { path });
|
|
262
249
|
return {
|
|
263
250
|
text: `📁 Added and opened **${escapeMd(project.name)}** (\`${shortPath(path)}\`).`,
|
|
264
251
|
target: { projectId: project.id, sessionId: latestSession(project.id)?.id ?? null }
|
|
@@ -266,6 +253,75 @@ export const createProject = defineAction({
|
|
|
266
253
|
}
|
|
267
254
|
});
|
|
268
255
|
|
|
256
|
+
/** The project an action names, or the one the conversation is in. */
|
|
257
|
+
function projectToRename(projectId: string | undefined, fallback: string): Project {
|
|
258
|
+
const project = projectQueries.getById(projectId ?? fallback);
|
|
259
|
+
if (!project || !projectQueries.isListed(project.id)) throw new Error('That project is not in Clopen any more.');
|
|
260
|
+
if (isHomeProject(project)) throw new Error(`${HOME_PROJECT_NAME} cannot be renamed. Open a project first with /projects.`);
|
|
261
|
+
return project;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function plural(count: number, noun: string): string {
|
|
265
|
+
return `${count} ${noun}${count === 1 ? '' : 's'}`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** "2 chats and 1 terminal", or with what each is doing — the words the web dialog uses. */
|
|
269
|
+
function describeUsage(usage: { chats: number; terminals: number }, withState = true): string {
|
|
270
|
+
const parts = [
|
|
271
|
+
...(usage.chats ? [`${plural(usage.chats, 'chat')}${withState ? ' still running' : ''}`] : []),
|
|
272
|
+
...(usage.terminals ? [`${plural(usage.terminals, 'terminal')}${withState ? ' open' : ''}`] : [])
|
|
273
|
+
];
|
|
274
|
+
return parts.join(' and ');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Renaming a project renames its folder: the project is always named after
|
|
279
|
+
* it. Work running there blocks it until the user asks to stop that work.
|
|
280
|
+
*/
|
|
281
|
+
export const renameProject = defineAction({
|
|
282
|
+
id: 'projects.rename',
|
|
283
|
+
group: 'projects',
|
|
284
|
+
title: 'Rename project',
|
|
285
|
+
description: 'Rename the project and its folder on disk. Chats, terminals and history follow it.',
|
|
286
|
+
args: t.Object({
|
|
287
|
+
projectId: t.Optional(t.String({ minLength: 1 })),
|
|
288
|
+
name: t.Optional(t.String()),
|
|
289
|
+
force: t.Optional(t.Boolean())
|
|
290
|
+
}),
|
|
291
|
+
command: { name: 'renameproject', argument: { keys: ['name'], hint: '<new name>' } },
|
|
292
|
+
confirm(args, ctx) {
|
|
293
|
+
if (!args.force || args.name === undefined) return null;
|
|
294
|
+
const project = projectToRename(args.projectId, ctx.target.projectId);
|
|
295
|
+
const usage = getProjectUsage(project.id);
|
|
296
|
+
if (!usage.chats && !usage.terminals) return null;
|
|
297
|
+
return `This stops ${describeUsage(usage, false)} in ${project.name}, then renames it to “${args.name.trim()}”.`;
|
|
298
|
+
},
|
|
299
|
+
async run(ctx, args) {
|
|
300
|
+
const project = projectToRename(args.projectId, ctx.target.projectId);
|
|
301
|
+
if (args.name === undefined) {
|
|
302
|
+
return {
|
|
303
|
+
text: `📁 **${escapeMd(project.name)}** (\`${shortPath(project.path)}\`)`,
|
|
304
|
+
ask: { question: `New name for ${project.name}? Its folder is renamed too.`, action: 'projects.rename', args: { projectId: project.id }, key: 'name' }
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
const name = validFolderName(args.name);
|
|
308
|
+
const outcome = await ctx.call<MoveOutcome>('projects:rename', { id: project.id, name, force: args.force ?? false }, { projectId: project.id });
|
|
309
|
+
if (outcome.status === 'busy') {
|
|
310
|
+
return {
|
|
311
|
+
text: `⏳ **${escapeMd(project.name)}** has ${describeUsage(outcome.usage)}. Renaming would leave them working in a folder that is gone.`,
|
|
312
|
+
choices: [{ label: '⏹️ Stop all & rename', action: 'projects.rename', args: { projectId: project.id, name, force: true } }]
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const lines = [
|
|
316
|
+
outcome.previousPath === outcome.project.path
|
|
317
|
+
? `📁 **${escapeMd(project.name)}** already has that name.`
|
|
318
|
+
: `✏️ Renamed to **${escapeMd(outcome.project.name)}** (\`${shortPath(outcome.project.path)}\`).`,
|
|
319
|
+
...outcome.warnings.map((warning) => `⚠️ ${warning}`)
|
|
320
|
+
];
|
|
321
|
+
return { text: lines.join('\n') };
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
269
325
|
/** Names are user data: keep `*`, `_` and friends literal inside Markdown. */
|
|
270
326
|
export function escapeMd(value: string): string {
|
|
271
327
|
return value.replace(/([\\`*_~[\]])/g, '\\$1');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Managing folders from a chat while adding a project: making, renaming and
|
|
3
|
-
* deleting work on ordinary folders, never on a project's or above home.
|
|
3
|
+
* deleting work on ordinary folders, never on a project's or above home. A
|
|
4
|
+
* project's own folder is renamed through the project, which moves with it.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import { describe, it, expect, beforeAll, afterAll } from 'bun:test';
|
|
@@ -9,7 +10,8 @@ import { homedir, tmpdir } from 'os';
|
|
|
9
10
|
import { join } from 'path';
|
|
10
11
|
import { initializeDatabase, closeDatabase } from '$backend/database';
|
|
11
12
|
import { projectQueries } from '$backend/database/queries';
|
|
12
|
-
import { createControlContext, getControlAction, runControlAction } from './index';
|
|
13
|
+
import { createControlContext, getControlAction, registerControlRouter, runControlAction } from './index';
|
|
14
|
+
import { projectsRouter } from '$backend/ws/projects';
|
|
13
15
|
|
|
14
16
|
const admin = { id: 'folders-admin', name: 'Admin', role: 'admin' } as never;
|
|
15
17
|
const ctx = () => createControlContext(admin, { projectId: 'none', sessionId: null });
|
|
@@ -19,6 +21,8 @@ let projectId: string;
|
|
|
19
21
|
|
|
20
22
|
beforeAll(async () => {
|
|
21
23
|
await initializeDatabase();
|
|
24
|
+
// The project rename goes through the same WebSocket route the web UI uses.
|
|
25
|
+
registerControlRouter(projectsRouter);
|
|
22
26
|
root = mkdtempSync(join(tmpdir(), 'clopen-folders-'));
|
|
23
27
|
mkdirSync(join(root, 'project'));
|
|
24
28
|
projectId = projectQueries.create({ name: 'folders-test', path: join(root, 'project'), created_at: new Date().toISOString(), last_opened_at: new Date().toISOString() } as never).id;
|
|
@@ -63,5 +67,26 @@ describe('folders while adding a project', () => {
|
|
|
63
67
|
expect(existsSync(join(root, 'project'))).toBe(true);
|
|
64
68
|
const menu = await runControlAction(ctx(), 'projects.browse', { path: join(root, 'project') });
|
|
65
69
|
expect(menu.choices?.some((choice) => choice.action === 'projects.delete-folder')).toBe(false);
|
|
70
|
+
expect(menu.choices?.some((choice) => choice.action === 'projects.rename')).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('renames a project with its folder: asks for the name, then moves both', async () => {
|
|
74
|
+
projectQueries.list(projectId);
|
|
75
|
+
const asked = await runControlAction(ctx(), 'projects.rename', { projectId });
|
|
76
|
+
expect(asked.ask).toMatchObject({ action: 'projects.rename', key: 'name', args: { projectId } });
|
|
77
|
+
|
|
78
|
+
const done = await runControlAction(ctx(), 'projects.rename', { projectId, name: 'project-renamed' });
|
|
79
|
+
expect(done.text).toContain('Renamed to');
|
|
80
|
+
expect(existsSync(join(root, 'project-renamed'))).toBe(true);
|
|
81
|
+
expect(existsSync(join(root, 'project'))).toBe(false);
|
|
82
|
+
expect(projectQueries.getById(projectId)).toMatchObject({ name: 'project-renamed', path: join(root, 'project-renamed') });
|
|
83
|
+
|
|
84
|
+
// A plain folder rename of a project's folder hands over to the project rename.
|
|
85
|
+
const handed = await runControlAction(ctx(), 'projects.rename-folder', { path: join(root, 'project-renamed'), name: 'x' });
|
|
86
|
+
expect(handed.choices?.[0]).toMatchObject({ action: 'projects.rename', args: { projectId } });
|
|
87
|
+
expect(existsSync(join(root, 'project-renamed'))).toBe(true);
|
|
88
|
+
|
|
89
|
+
await runControlAction(ctx(), 'projects.rename', { projectId, name: 'project' });
|
|
90
|
+
expect(projectQueries.getById(projectId)?.path).toBe(join(root, 'project'));
|
|
66
91
|
});
|
|
67
92
|
});
|
package/backend/control/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { Value } from '@sinclair/typebox/value';
|
|
|
19
19
|
import type { AuthUser } from '$backend/auth/auth-service';
|
|
20
20
|
import { callRouteAs } from './invoke';
|
|
21
21
|
import { CONTROL_GROUP_LABELS, type ControlAction, type ControlContext, type ControlGroup, type ControlResult, type ControlTarget } from './types';
|
|
22
|
-
import { browseFolders, createProject, deleteFolder, goHome, listProjects, makeFolder, openProject, renameFolder } from './actions/projects';
|
|
22
|
+
import { browseFolders, createProject, deleteFolder, goHome, listProjects, makeFolder, openProject, renameFolder, renameProject } from './actions/projects';
|
|
23
23
|
import { deleteSession, dropQueued, listSessions, newSession, openSession, runningSessions, searchSessions, sessionStatus, showQueue, stopSession } from './actions/sessions';
|
|
24
24
|
import { listSkills, runSkill } from './actions/skills';
|
|
25
25
|
import { getFile, turnDiff } from './actions/files';
|
|
@@ -57,6 +57,7 @@ export const CONTROL_ACTIONS: readonly ControlAction[] = [
|
|
|
57
57
|
renameFolder,
|
|
58
58
|
deleteFolder,
|
|
59
59
|
createProject,
|
|
60
|
+
renameProject,
|
|
60
61
|
listEngines,
|
|
61
62
|
listModels,
|
|
62
63
|
setModel,
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
2
|
import { debug } from '$shared/utils/logger';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Rebuilds a table, so the runner runs it with foreign keys off (see
|
|
6
|
+
* Migration.foreignKeysOff). The pragma lines below are kept from before the
|
|
7
|
+
* runner did this; inside its transaction they do nothing.
|
|
8
|
+
*/
|
|
9
|
+
export const foreignKeysOff = true;
|
|
10
|
+
|
|
4
11
|
export const description = 'Support mssql driver in db_client_connections CHECK constraint';
|
|
5
12
|
|
|
6
13
|
export const up = (db: DatabaseConnection): void => {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
2
|
import { debug } from '$shared/utils/logger';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Rebuilds a table, so the runner runs it with foreign keys off (see
|
|
6
|
+
* Migration.foreignKeysOff). The pragma lines below are kept from before the
|
|
7
|
+
* runner did this; inside its transaction they do nothing.
|
|
8
|
+
*/
|
|
9
|
+
export const foreignKeysOff = true;
|
|
10
|
+
|
|
4
11
|
export const description = 'Create integration_db_links and widen integration_projections to many rows per capability';
|
|
5
12
|
|
|
6
13
|
/**
|
|
@@ -187,82 +187,75 @@ function rebuildGitIdentities(db: DatabaseConnection): void {
|
|
|
187
187
|
export const up = (db: DatabaseConnection): void => {
|
|
188
188
|
debug.log('migration', '📋 Collapsing collaboration into a single owner...');
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
190
|
+
// One transaction with its record, opened by the migration runner.
|
|
191
|
+
const ownerId = pickOwner(db);
|
|
192
|
+
if (ownerId) {
|
|
193
|
+
const removed = removeOtherUsers(db, ownerId);
|
|
194
|
+
if (removed.length > 0) debug.log('migration', `Removed ${removed.length} non-owner account(s) and their data`);
|
|
195
|
+
}
|
|
197
196
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
db.exec('ALTER TABLE users DROP COLUMN role');
|
|
202
|
-
|
|
203
|
-
// Projects in the workspace list, with their saved workspace state. A
|
|
204
|
-
// project absent from here was "removed" (kept so its chats can be
|
|
205
|
-
// restored by adding the same folder again).
|
|
206
|
-
db.exec(`
|
|
207
|
-
CREATE TABLE workspace_projects (
|
|
208
|
-
project_id TEXT PRIMARY KEY REFERENCES projects(id) ON DELETE CASCADE,
|
|
209
|
-
joined_at TEXT NOT NULL,
|
|
210
|
-
current_session_id TEXT,
|
|
211
|
-
files_panel_state TEXT,
|
|
212
|
-
workspace_state TEXT
|
|
213
|
-
)
|
|
214
|
-
`);
|
|
215
|
-
if (ownerId) {
|
|
216
|
-
db.prepare(`
|
|
217
|
-
INSERT OR IGNORE INTO workspace_projects (project_id, joined_at, current_session_id, files_panel_state, workspace_state)
|
|
218
|
-
SELECT project_id, joined_at, current_session_id, files_panel_state, workspace_state
|
|
219
|
-
FROM user_projects
|
|
220
|
-
WHERE user_id = ? AND project_id IN (SELECT id FROM projects)
|
|
221
|
-
`).run(ownerId);
|
|
222
|
-
}
|
|
223
|
-
db.exec('DROP TABLE user_projects');
|
|
197
|
+
// Invites only ever created members.
|
|
198
|
+
db.exec('DROP TABLE IF EXISTS invite_tokens');
|
|
224
199
|
|
|
225
|
-
|
|
226
|
-
CREATE TABLE unread_sessions (
|
|
227
|
-
session_id TEXT PRIMARY KEY REFERENCES chat_sessions(id) ON DELETE CASCADE,
|
|
228
|
-
project_id TEXT NOT NULL,
|
|
229
|
-
marked_at TEXT NOT NULL
|
|
230
|
-
)
|
|
231
|
-
`);
|
|
232
|
-
db.exec('CREATE INDEX idx_unread_sessions_project ON unread_sessions(project_id)');
|
|
233
|
-
db.exec(`
|
|
234
|
-
INSERT OR IGNORE INTO unread_sessions (session_id, project_id, marked_at)
|
|
235
|
-
SELECT session_id, project_id, MAX(marked_at) FROM user_unread_sessions
|
|
236
|
-
WHERE session_id IN (SELECT id FROM chat_sessions)
|
|
237
|
-
GROUP BY session_id
|
|
238
|
-
`);
|
|
239
|
-
db.exec('DROP TABLE user_unread_sessions');
|
|
240
|
-
|
|
241
|
-
// One Home for the install.
|
|
242
|
-
db.exec('DROP INDEX IF EXISTS idx_projects_home_owner');
|
|
243
|
-
db.exec('ALTER TABLE projects DROP COLUMN owner_user_id');
|
|
244
|
-
db.exec(`CREATE UNIQUE INDEX idx_projects_single_home ON projects (kind) WHERE kind = 'home'`);
|
|
245
|
-
|
|
246
|
-
db.exec('DROP INDEX IF EXISTS idx_db_client_conn_owner');
|
|
247
|
-
db.exec('ALTER TABLE db_client_connections DROP COLUMN owner_user_id');
|
|
248
|
-
db.exec('DROP INDEX IF EXISTS idx_ssh_conn_owner');
|
|
249
|
-
db.exec('ALTER TABLE ssh_connections DROP COLUMN owner_user_id');
|
|
250
|
-
|
|
251
|
-
if (hasColumn(db, 'chat_sessions', 'sender_id')) db.exec('ALTER TABLE chat_sessions DROP COLUMN sender_id');
|
|
252
|
-
if (hasColumn(db, 'chat_sessions', 'sender_name')) db.exec('ALTER TABLE chat_sessions DROP COLUMN sender_name');
|
|
253
|
-
|
|
254
|
-
rebuildGitIdentities(db);
|
|
255
|
-
|
|
256
|
-
if (tableExists(db, 'channel_links') && hasColumn(db, 'channel_links', 'status')) {
|
|
257
|
-
// Only a member's chat could still be waiting for approval.
|
|
258
|
-
db.exec(`DELETE FROM channel_links WHERE status != 'approved'`);
|
|
259
|
-
db.exec('ALTER TABLE channel_links DROP COLUMN status');
|
|
260
|
-
}
|
|
200
|
+
db.exec('ALTER TABLE users DROP COLUMN role');
|
|
261
201
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
202
|
+
// Projects in the workspace list, with their saved workspace state. A
|
|
203
|
+
// project absent from here was "removed" (kept so its chats can be
|
|
204
|
+
// restored by adding the same folder again).
|
|
205
|
+
db.exec(`
|
|
206
|
+
CREATE TABLE workspace_projects (
|
|
207
|
+
project_id TEXT PRIMARY KEY REFERENCES projects(id) ON DELETE CASCADE,
|
|
208
|
+
joined_at TEXT NOT NULL,
|
|
209
|
+
current_session_id TEXT,
|
|
210
|
+
files_panel_state TEXT,
|
|
211
|
+
workspace_state TEXT
|
|
212
|
+
)
|
|
213
|
+
`);
|
|
214
|
+
if (ownerId) {
|
|
215
|
+
db.prepare(`
|
|
216
|
+
INSERT OR IGNORE INTO workspace_projects (project_id, joined_at, current_session_id, files_panel_state, workspace_state)
|
|
217
|
+
SELECT project_id, joined_at, current_session_id, files_panel_state, workspace_state
|
|
218
|
+
FROM user_projects
|
|
219
|
+
WHERE user_id = ? AND project_id IN (SELECT id FROM projects)
|
|
220
|
+
`).run(ownerId);
|
|
221
|
+
}
|
|
222
|
+
db.exec('DROP TABLE user_projects');
|
|
223
|
+
|
|
224
|
+
db.exec(`
|
|
225
|
+
CREATE TABLE unread_sessions (
|
|
226
|
+
session_id TEXT PRIMARY KEY REFERENCES chat_sessions(id) ON DELETE CASCADE,
|
|
227
|
+
project_id TEXT NOT NULL,
|
|
228
|
+
marked_at TEXT NOT NULL
|
|
229
|
+
)
|
|
230
|
+
`);
|
|
231
|
+
db.exec('CREATE INDEX idx_unread_sessions_project ON unread_sessions(project_id)');
|
|
232
|
+
db.exec(`
|
|
233
|
+
INSERT OR IGNORE INTO unread_sessions (session_id, project_id, marked_at)
|
|
234
|
+
SELECT session_id, project_id, MAX(marked_at) FROM user_unread_sessions
|
|
235
|
+
WHERE session_id IN (SELECT id FROM chat_sessions)
|
|
236
|
+
GROUP BY session_id
|
|
237
|
+
`);
|
|
238
|
+
db.exec('DROP TABLE user_unread_sessions');
|
|
239
|
+
|
|
240
|
+
// One Home for the install.
|
|
241
|
+
db.exec('DROP INDEX IF EXISTS idx_projects_home_owner');
|
|
242
|
+
db.exec('ALTER TABLE projects DROP COLUMN owner_user_id');
|
|
243
|
+
db.exec(`CREATE UNIQUE INDEX idx_projects_single_home ON projects (kind) WHERE kind = 'home'`);
|
|
244
|
+
|
|
245
|
+
db.exec('DROP INDEX IF EXISTS idx_db_client_conn_owner');
|
|
246
|
+
db.exec('ALTER TABLE db_client_connections DROP COLUMN owner_user_id');
|
|
247
|
+
db.exec('DROP INDEX IF EXISTS idx_ssh_conn_owner');
|
|
248
|
+
db.exec('ALTER TABLE ssh_connections DROP COLUMN owner_user_id');
|
|
249
|
+
|
|
250
|
+
if (hasColumn(db, 'chat_sessions', 'sender_id')) db.exec('ALTER TABLE chat_sessions DROP COLUMN sender_id');
|
|
251
|
+
if (hasColumn(db, 'chat_sessions', 'sender_name')) db.exec('ALTER TABLE chat_sessions DROP COLUMN sender_name');
|
|
252
|
+
|
|
253
|
+
rebuildGitIdentities(db);
|
|
254
|
+
|
|
255
|
+
if (tableExists(db, 'channel_links') && hasColumn(db, 'channel_links', 'status')) {
|
|
256
|
+
// Only a member's chat could still be waiting for approval.
|
|
257
|
+
db.exec(`DELETE FROM channel_links WHERE status != 'approved'`);
|
|
258
|
+
db.exec('ALTER TABLE channel_links DROP COLUMN status');
|
|
266
259
|
}
|
|
267
260
|
|
|
268
261
|
debug.log('migration', '✅ Single owner in place');
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description =
|
|
5
|
+
'Add storage bookkeeping: per-session size index, engine transcript aliases, cleanup history, slimmed chats';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What Settings → Storage needs to know without re-reading the message table.
|
|
9
|
+
*
|
|
10
|
+
* `storage_session_index` — one row per chat: the bytes its messages take and the
|
|
11
|
+
* engine session ids they reference. Measuring that is a read of every row of a
|
|
12
|
+
* table that reaches gigabytes, so it is done once per chat and redone only when
|
|
13
|
+
* the chat's `message_count` or `last_message_at` moved. Empty here on purpose:
|
|
14
|
+
* filling it in a migration would hold startup for as long as the scan takes.
|
|
15
|
+
* The storage scanner builds it in the background, a chat at a time.
|
|
16
|
+
*
|
|
17
|
+
* `engine_transcript_aliases` — a deduplicated engine transcript. Claude forks
|
|
18
|
+
* every turn into a new file that repeats the whole conversation; once a later
|
|
19
|
+
* fork holds every entry of an earlier one, the earlier file is redundant. It is
|
|
20
|
+
* removed and remembered here as "resume `target_session_id` cut at `resume_at`",
|
|
21
|
+
* which is the same conversation state.
|
|
22
|
+
*
|
|
23
|
+
* `storage_cleanup_runs` — what each manual or automatic cleanup removed.
|
|
24
|
+
*
|
|
25
|
+
* `chat_sessions.slimmed_at` — the chat was slimmed: its heavy payloads, file
|
|
26
|
+
* checkpoints and engine transcripts are gone, its conversation is kept.
|
|
27
|
+
*/
|
|
28
|
+
export const up = (db: DatabaseConnection): void => {
|
|
29
|
+
debug.log('migration', 'Creating storage tables...');
|
|
30
|
+
|
|
31
|
+
db.exec(`
|
|
32
|
+
CREATE TABLE IF NOT EXISTS storage_session_index (
|
|
33
|
+
session_id TEXT PRIMARY KEY REFERENCES chat_sessions(id) ON DELETE CASCADE,
|
|
34
|
+
bytes INTEGER NOT NULL DEFAULT 0,
|
|
35
|
+
engine_refs TEXT NOT NULL DEFAULT '[]',
|
|
36
|
+
message_count INTEGER NOT NULL DEFAULT 0,
|
|
37
|
+
last_message_at TEXT,
|
|
38
|
+
measured_at TEXT NOT NULL
|
|
39
|
+
) WITHOUT ROWID
|
|
40
|
+
`);
|
|
41
|
+
|
|
42
|
+
db.exec(`
|
|
43
|
+
CREATE TABLE IF NOT EXISTS engine_transcript_aliases (
|
|
44
|
+
engine TEXT NOT NULL,
|
|
45
|
+
session_id TEXT NOT NULL,
|
|
46
|
+
target_session_id TEXT NOT NULL,
|
|
47
|
+
resume_at TEXT NOT NULL,
|
|
48
|
+
created_at TEXT NOT NULL,
|
|
49
|
+
PRIMARY KEY (engine, session_id)
|
|
50
|
+
) WITHOUT ROWID
|
|
51
|
+
`);
|
|
52
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_engine_transcript_aliases_target ON engine_transcript_aliases (engine, target_session_id)`);
|
|
53
|
+
|
|
54
|
+
db.exec(`
|
|
55
|
+
CREATE TABLE IF NOT EXISTS storage_cleanup_runs (
|
|
56
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
57
|
+
action TEXT NOT NULL,
|
|
58
|
+
trigger TEXT NOT NULL,
|
|
59
|
+
started_at TEXT NOT NULL,
|
|
60
|
+
finished_at TEXT,
|
|
61
|
+
freed_bytes INTEGER NOT NULL DEFAULT 0,
|
|
62
|
+
items INTEGER NOT NULL DEFAULT 0,
|
|
63
|
+
error TEXT
|
|
64
|
+
)
|
|
65
|
+
`);
|
|
66
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_storage_cleanup_runs_started ON storage_cleanup_runs (started_at)`);
|
|
67
|
+
|
|
68
|
+
const columns = db.prepare(`PRAGMA table_info(chat_sessions)`).all() as { name: string }[];
|
|
69
|
+
if (!columns.some(column => column.name === 'slimmed_at')) {
|
|
70
|
+
db.exec(`ALTER TABLE chat_sessions ADD COLUMN slimmed_at TEXT`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
debug.log('migration', 'Storage tables ready');
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const down = (db: DatabaseConnection): void => {
|
|
77
|
+
db.exec(`DROP INDEX IF EXISTS idx_storage_cleanup_runs_started`);
|
|
78
|
+
db.exec(`DROP TABLE IF EXISTS storage_cleanup_runs`);
|
|
79
|
+
db.exec(`DROP INDEX IF EXISTS idx_engine_transcript_aliases_target`);
|
|
80
|
+
db.exec(`DROP TABLE IF EXISTS engine_transcript_aliases`);
|
|
81
|
+
db.exec(`DROP TABLE IF EXISTS storage_session_index`);
|
|
82
|
+
db.exec(`ALTER TABLE chat_sessions DROP COLUMN slimmed_at`);
|
|
83
|
+
};
|
|
@@ -88,6 +88,7 @@ import * as migration086 from './086_single_owner';
|
|
|
88
88
|
import * as migration087 from './087_create_blob_line_stats';
|
|
89
89
|
import * as migration088 from './088_create_messages_fts_map';
|
|
90
90
|
import * as migration089 from './089_add_memory_layout_tiles';
|
|
91
|
+
import * as migration090 from './090_create_storage_tables';
|
|
91
92
|
|
|
92
93
|
// Export all migrations in order
|
|
93
94
|
export const migrations = [
|
|
@@ -425,7 +426,8 @@ export const migrations = [
|
|
|
425
426
|
id: '056',
|
|
426
427
|
description: migration056.description,
|
|
427
428
|
up: migration056.up,
|
|
428
|
-
down: migration056.down
|
|
429
|
+
down: migration056.down,
|
|
430
|
+
foreignKeysOff: migration056.foreignKeysOff
|
|
429
431
|
},
|
|
430
432
|
{
|
|
431
433
|
id: '057',
|
|
@@ -551,7 +553,8 @@ export const migrations = [
|
|
|
551
553
|
id: '077',
|
|
552
554
|
description: migration077.description,
|
|
553
555
|
up: migration077.up,
|
|
554
|
-
down: migration077.down
|
|
556
|
+
down: migration077.down,
|
|
557
|
+
foreignKeysOff: migration077.foreignKeysOff
|
|
555
558
|
},
|
|
556
559
|
{
|
|
557
560
|
id: '078',
|
|
@@ -624,6 +627,12 @@ export const migrations = [
|
|
|
624
627
|
description: migration089.description,
|
|
625
628
|
up: migration089.up,
|
|
626
629
|
down: migration089.down
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
id: '090',
|
|
633
|
+
description: migration090.description,
|
|
634
|
+
up: migration090.up,
|
|
635
|
+
down: migration090.down
|
|
627
636
|
}
|
|
628
637
|
];
|
|
629
638
|
|
|
@@ -154,6 +154,16 @@ export const integrationAccountQueries = {
|
|
|
154
154
|
);
|
|
155
155
|
},
|
|
156
156
|
|
|
157
|
+
/** Record how the account's credential was obtained — a reconnect can change it. */
|
|
158
|
+
setAuthMethod(id: string, authMethod: IntegrationAuthMethod): void {
|
|
159
|
+
const db = getDatabase();
|
|
160
|
+
db.prepare(`UPDATE integration_accounts SET auth_method = ?, updated_at = ? WHERE id = ?`).run(
|
|
161
|
+
authMethod,
|
|
162
|
+
new Date().toISOString(),
|
|
163
|
+
id
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
|
|
157
167
|
/**
|
|
158
168
|
* Rename an account.
|
|
159
169
|
*
|
|
@@ -336,6 +336,17 @@ export const memoryQueueQueries = {
|
|
|
336
336
|
return Number(result.changes ?? 0);
|
|
337
337
|
},
|
|
338
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Follow a project to its new folder. Only rows for its main tree change: a
|
|
341
|
+
* turn that ran in a worktree carries the worktree's own path, which a move
|
|
342
|
+
* of the project folder leaves where it is.
|
|
343
|
+
*/
|
|
344
|
+
repointProject(projectId: string, oldPath: string, newPath: string): void {
|
|
345
|
+
getDatabase()
|
|
346
|
+
.prepare(`UPDATE memory_extraction_queue SET project_path = ? WHERE project_id = ? AND project_path = ?`)
|
|
347
|
+
.run(newPath, projectId, oldPath);
|
|
348
|
+
},
|
|
349
|
+
|
|
339
350
|
/** Drop everything queued, for "clear all data" and for tests. */
|
|
340
351
|
clear(): void {
|
|
341
352
|
getDatabase().prepare(`DELETE FROM memory_extraction_queue`).run();
|
|
@@ -73,6 +73,12 @@ export const projectQueries = {
|
|
|
73
73
|
`).run(now, id);
|
|
74
74
|
},
|
|
75
75
|
|
|
76
|
+
/** Point a project at another folder. Its name is always its folder's. */
|
|
77
|
+
relocate(id: string, path: string, name: string): void {
|
|
78
|
+
const db = getDatabase();
|
|
79
|
+
db.prepare(`UPDATE projects SET path = ?, name = ? WHERE id = ?`).run(path, name, id);
|
|
80
|
+
},
|
|
81
|
+
|
|
76
82
|
/** The project-wide default profile, or null. */
|
|
77
83
|
getDefaultProfileId(id: string): number | null {
|
|
78
84
|
const db = getDatabase();
|
|
@@ -157,6 +157,9 @@ export const sessionQueries = {
|
|
|
157
157
|
const sets: string[] = [
|
|
158
158
|
'message_count = COALESCE(message_count, 0) + 1',
|
|
159
159
|
'last_message_at = ?',
|
|
160
|
+
// A slimmed chat that is picked up again is a live chat: its new engine
|
|
161
|
+
// transcripts must be protected like any other (see storage/chats.ts).
|
|
162
|
+
'slimmed_at = NULL',
|
|
160
163
|
];
|
|
161
164
|
const params: (string | number | null)[] = [opts.timestamp];
|
|
162
165
|
|