@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,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight fuzzy subsequence matching for the Command Palette and the
|
|
3
|
+
* chat composer's `@` picker.
|
|
4
|
+
*
|
|
5
|
+
* Pure, local, and synchronous — no engine round-trip — so Quick Search stays
|
|
6
|
+
* instant. Scoring rewards exact/prefix hits, consecutive runs, and matches at
|
|
7
|
+
* word boundaries so the most relevant result floats to the top as you type.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Characters that mark the start of a "word" for boundary bonuses. */
|
|
11
|
+
const WORD_BOUNDARY = /[\s\-_/.:@]/;
|
|
12
|
+
|
|
13
|
+
export interface FuzzyMatch {
|
|
14
|
+
/** Higher is a better match. */
|
|
15
|
+
score: number;
|
|
16
|
+
/** Indices in the target string that matched, for optional highlighting. */
|
|
17
|
+
positions: number[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Match `query` as a subsequence of `text` (case-insensitive). Returns `null`
|
|
22
|
+
* when not every query character can be found in order. An empty query matches
|
|
23
|
+
* anything with a neutral score of 0.
|
|
24
|
+
*/
|
|
25
|
+
export function fuzzyMatch(query: string, text: string): FuzzyMatch | null {
|
|
26
|
+
const q = query.trim().toLowerCase();
|
|
27
|
+
if (!q) return { score: 0, positions: [] };
|
|
28
|
+
const t = text.toLowerCase();
|
|
29
|
+
|
|
30
|
+
// Exact-substring is the strongest signal — take it directly.
|
|
31
|
+
const exactIdx = t.indexOf(q);
|
|
32
|
+
if (exactIdx !== -1) {
|
|
33
|
+
const boundaryBonus = exactIdx === 0 || WORD_BOUNDARY.test(t[exactIdx - 1]) ? 20 : 0;
|
|
34
|
+
const positions = Array.from({ length: q.length }, (_, i) => exactIdx + i);
|
|
35
|
+
return { score: 100 + boundaryBonus - exactIdx * 0.1, positions };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const positions: number[] = [];
|
|
39
|
+
let score = 0;
|
|
40
|
+
let ti = 0;
|
|
41
|
+
let prevMatch = -2;
|
|
42
|
+
for (let qi = 0; qi < q.length; qi++) {
|
|
43
|
+
const ch = q[qi];
|
|
44
|
+
let found = -1;
|
|
45
|
+
for (; ti < t.length; ti++) {
|
|
46
|
+
if (t[ti] === ch) {
|
|
47
|
+
found = ti;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (found === -1) return null; // query char missing → not a subsequence
|
|
52
|
+
let charScore = 1;
|
|
53
|
+
if (found === prevMatch + 1) charScore += 3; // consecutive run
|
|
54
|
+
if (found === 0 || WORD_BOUNDARY.test(t[found - 1])) charScore += 5; // word start
|
|
55
|
+
score += charScore;
|
|
56
|
+
positions.push(found);
|
|
57
|
+
prevMatch = found;
|
|
58
|
+
ti = found + 1;
|
|
59
|
+
}
|
|
60
|
+
// Slightly prefer denser matches (query fills more of the target).
|
|
61
|
+
score += Math.max(0, 10 - (t.length - q.length) * 0.05);
|
|
62
|
+
return { score, positions };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Best fuzzy score across several candidate strings (e.g. label, description,
|
|
67
|
+
* keywords). Returns 0 when none of them match, so callers can treat `> 0` as
|
|
68
|
+
* "matched".
|
|
69
|
+
*/
|
|
70
|
+
export function bestFuzzyScore(query: string, texts: (string | undefined | null)[]): number {
|
|
71
|
+
if (!query.trim()) return 0;
|
|
72
|
+
let best = 0;
|
|
73
|
+
for (const text of texts) {
|
|
74
|
+
if (!text) continue;
|
|
75
|
+
const m = fuzzyMatch(query, text);
|
|
76
|
+
if (m && m.score > best) best = m.score;
|
|
77
|
+
}
|
|
78
|
+
return best;
|
|
79
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { afterAll, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { computeLauncherFingerprint, launcherClosure, launcherPackageImports } from './launcher-fingerprint';
|
|
7
|
+
|
|
8
|
+
// Shaped like a global install, whose own path runs through a node_modules folder.
|
|
9
|
+
const base = mkdtempSync(join(tmpdir(), 'clopen-launcher-'));
|
|
10
|
+
const root = join(base, 'node_modules', '@myrialabs', 'clopen');
|
|
11
|
+
mkdirSync(root, { recursive: true });
|
|
12
|
+
afterAll(() => rmSync(base, { recursive: true, force: true }));
|
|
13
|
+
|
|
14
|
+
function put(file: string, content: string) {
|
|
15
|
+
mkdirSync(dirname(join(root, file)), { recursive: true });
|
|
16
|
+
writeFileSync(join(root, file), content);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
put('bin/clopen.ts', [
|
|
20
|
+
'#!/usr/bin/env bun',
|
|
21
|
+
"import { join } from 'path';",
|
|
22
|
+
"import { supervise } from '../shared/supervisor';",
|
|
23
|
+
"import dep from 'some-dependency';",
|
|
24
|
+
'async function helper() {',
|
|
25
|
+
" const { run } = await import('../backend/helper');",
|
|
26
|
+
' return run;',
|
|
27
|
+
'}',
|
|
28
|
+
'supervise(join, dep, helper);'
|
|
29
|
+
].join('\n'));
|
|
30
|
+
put('shared/supervisor.ts', "import { tree } from './tree';\nexport const supervise = tree;");
|
|
31
|
+
put('shared/tree.ts', 'export const tree = () => {};');
|
|
32
|
+
put('backend/helper.ts', 'export const run = () => {};');
|
|
33
|
+
put('node_modules/some-dependency/index.js', 'module.exports = 1;');
|
|
34
|
+
put('node_modules/some-dependency/package.json', '{"name":"some-dependency","main":"index.js"}');
|
|
35
|
+
|
|
36
|
+
describe('launcherClosure', () => {
|
|
37
|
+
test('follows static project imports only, even inside an installed package', () => {
|
|
38
|
+
expect(launcherClosure(root)).toEqual(['bin/clopen.ts', 'shared/supervisor.ts', 'shared/tree.ts']);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('reports the packages it imports, which the fingerprint cannot see', () => {
|
|
42
|
+
expect(launcherPackageImports(root)).toEqual(['some-dependency']);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('in this repository the launcher imports no packages', () => {
|
|
46
|
+
expect(launcherPackageImports(join(import.meta.dir, '../..'))).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("in this repository it is the launcher and its supervisor, not the git helper", () => {
|
|
50
|
+
const closure = launcherClosure(join(import.meta.dir, '../..'));
|
|
51
|
+
expect(closure).toContain('bin/clopen.ts');
|
|
52
|
+
expect(closure).toContain('shared/utils/process-supervisor.ts');
|
|
53
|
+
expect(closure).not.toContain('backend/git/identity/cli.ts');
|
|
54
|
+
// The server's half of supervision lives apart, so server-only changes
|
|
55
|
+
// do not read as launcher changes.
|
|
56
|
+
expect(closure).not.toContain('shared/utils/supervised-child.ts');
|
|
57
|
+
expect(closure).toContain('shared/utils/supervisor-protocol.ts');
|
|
58
|
+
expect(closure.every(file => !file.startsWith('backend/'))).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('computeLauncherFingerprint', () => {
|
|
63
|
+
test('changes when a file the launcher loads changes, and not otherwise', () => {
|
|
64
|
+
const before = computeLauncherFingerprint(root);
|
|
65
|
+
expect(computeLauncherFingerprint(root)).toBe(before);
|
|
66
|
+
|
|
67
|
+
put('backend/helper.ts', 'export const run = () => 2;');
|
|
68
|
+
expect(computeLauncherFingerprint(root)).toBe(before);
|
|
69
|
+
|
|
70
|
+
put('shared/tree.ts', 'export const tree = () => 1;');
|
|
71
|
+
expect(computeLauncherFingerprint(root)).not.toBe(before);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fingerprint of the code the `clopen` launcher keeps running.
|
|
3
|
+
*
|
|
4
|
+
* The launcher (bin/clopen.ts) is the process in the user's terminal: it
|
|
5
|
+
* holds the supervisor, forwards Ctrl+C and owns the terminal. Restarting the
|
|
6
|
+
* server from the UI swaps everything below it, but the launcher itself keeps
|
|
7
|
+
* running the code it started with. So an update that changes the launcher
|
|
8
|
+
* still needs the user to restart `clopen` by hand — and this is how Clopen
|
|
9
|
+
* tells: the launcher's fingerprint when it started, against the fingerprint
|
|
10
|
+
* of what is on disk now (or of the version about to be installed).
|
|
11
|
+
*
|
|
12
|
+
* The files are found, not listed: the static imports of bin/clopen.ts are
|
|
13
|
+
* followed through every project file they reach, so a new import is covered
|
|
14
|
+
* without anyone remembering to add it. Dynamic imports are left out on
|
|
15
|
+
* purpose — they load per command (`clopen update`, the git helper) in a
|
|
16
|
+
* process that starts fresh each time, not in the long-running launcher.
|
|
17
|
+
*
|
|
18
|
+
* The launcher may only import builtins and project files: a dependency from
|
|
19
|
+
* node_modules would change on update without changing the fingerprint, so
|
|
20
|
+
* Restart now would be offered while part of the launcher was out of date.
|
|
21
|
+
* launcherPackageImports() exists to keep that list empty.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { createHash } from 'node:crypto';
|
|
25
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
26
|
+
import { dirname, isAbsolute, join, relative, sep } from 'node:path';
|
|
27
|
+
|
|
28
|
+
/** Carries the running launcher's fingerprint to the server it starts. */
|
|
29
|
+
export const LAUNCHER_FINGERPRINT_ENV = 'CLOPEN_LAUNCHER_FINGERPRINT';
|
|
30
|
+
|
|
31
|
+
/** The launcher entry, relative to the package root. */
|
|
32
|
+
export const LAUNCHER_ENTRY = 'bin/clopen.ts';
|
|
33
|
+
|
|
34
|
+
const transpiler = new Bun.Transpiler({ loader: 'ts' });
|
|
35
|
+
|
|
36
|
+
function staticImports(source: string): string[] {
|
|
37
|
+
// The shebang is not TypeScript; the transpiler rejects it.
|
|
38
|
+
const code = source.startsWith('#!') ? source.slice(source.indexOf('\n') + 1) : source;
|
|
39
|
+
return transpiler.scanImports(code).filter(entry => entry.kind === 'import-statement').map(entry => entry.path);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface LauncherGraph {
|
|
43
|
+
/** Project files, relative to the package root, sorted. */
|
|
44
|
+
files: string[];
|
|
45
|
+
/** Imports that resolve to a package rather than a project file or a builtin. */
|
|
46
|
+
packages: string[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function walkLauncher(packageRoot: string): LauncherGraph {
|
|
50
|
+
// Resolution hands back real paths (macOS: /var is /private/var), so the
|
|
51
|
+
// root has to be one too for the relative paths below to mean anything.
|
|
52
|
+
const root = realpathSync(packageRoot);
|
|
53
|
+
const seen = new Set<string>();
|
|
54
|
+
const packages = new Set<string>();
|
|
55
|
+
const pending = [join(root, LAUNCHER_ENTRY)];
|
|
56
|
+
|
|
57
|
+
while (pending.length > 0) {
|
|
58
|
+
const file = pending.pop()!;
|
|
59
|
+
if (seen.has(file)) continue;
|
|
60
|
+
seen.add(file);
|
|
61
|
+
for (const specifier of staticImports(readFileSync(file, 'utf-8'))) {
|
|
62
|
+
let resolved: string;
|
|
63
|
+
try {
|
|
64
|
+
resolved = Bun.resolveSync(specifier, dirname(file));
|
|
65
|
+
} catch {
|
|
66
|
+
packages.add(specifier);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Builtins resolve to their bare name.
|
|
70
|
+
if (!isAbsolute(resolved)) continue;
|
|
71
|
+
// Judged relative to the root: an installed Clopen itself lives inside a
|
|
72
|
+
// node_modules folder, so the absolute path always contains one.
|
|
73
|
+
const path = relative(root, resolved);
|
|
74
|
+
if (path.startsWith('..') || path.split(sep).includes('node_modules')) {
|
|
75
|
+
packages.add(specifier);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
pending.push(resolved);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
files: [...seen].map(file => relative(root, file).split(sep).join('/')).sort(),
|
|
84
|
+
packages: [...packages].sort()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Every project file the launcher loads up front, relative to `packageRoot`, sorted. */
|
|
89
|
+
export function launcherClosure(packageRoot: string): string[] {
|
|
90
|
+
return walkLauncher(packageRoot).files;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Packages the launcher imports. The fingerprint only covers project files, so
|
|
95
|
+
* a package here would change without the fingerprint noticing; it has to stay
|
|
96
|
+
* empty (the test and the publish stamp both fail otherwise).
|
|
97
|
+
*/
|
|
98
|
+
export function launcherPackageImports(packageRoot: string): string[] {
|
|
99
|
+
return walkLauncher(packageRoot).packages;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function computeLauncherFingerprint(packageRoot: string): string {
|
|
103
|
+
const hash = createHash('sha256');
|
|
104
|
+
for (const file of launcherClosure(packageRoot)) {
|
|
105
|
+
hash.update(file).update('\0').update(readFileSync(join(packageRoot, file))).update('\0');
|
|
106
|
+
}
|
|
107
|
+
return hash.digest('hex').slice(0, 16);
|
|
108
|
+
}
|
package/shared/utils/logger.ts
CHANGED
|
@@ -30,6 +30,7 @@ export type LogLabel =
|
|
|
30
30
|
| 'mcp'
|
|
31
31
|
| 'integrations'
|
|
32
32
|
| 'work'
|
|
33
|
+
| 'git-hosts'
|
|
33
34
|
| 'deployments'
|
|
34
35
|
| 'skills'
|
|
35
36
|
| 'artifacts'
|
|
@@ -67,6 +68,7 @@ export type LogLabel =
|
|
|
67
68
|
// System
|
|
68
69
|
| 'server'
|
|
69
70
|
| 'database'
|
|
71
|
+
| 'storage'
|
|
70
72
|
| 'migration'
|
|
71
73
|
| 'seeder'
|
|
72
74
|
| 'path';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { foregroundFor } from './page-colors';
|
|
3
|
+
|
|
4
|
+
describe('foregroundFor', () => {
|
|
5
|
+
test('dark ink on a light page, light ink on a dark one', () => {
|
|
6
|
+
expect(foregroundFor('#ffffff')).toBe('#111113');
|
|
7
|
+
expect(foregroundFor('#fff')).toBe('#111113');
|
|
8
|
+
expect(foregroundFor('#202124')).toBe('#fff');
|
|
9
|
+
expect(foregroundFor('rgb(232, 113, 38)')).toBe('#fff');
|
|
10
|
+
expect(foregroundFor('rgba(250, 250, 250, 0.9)')).toBe('#111113');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('a page with no colours yet is treated as the default white canvas', () => {
|
|
14
|
+
expect(foregroundFor(null)).toBe('#111113');
|
|
15
|
+
expect(foregroundFor('not a colour')).toBe('#111113');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ink for system UI painted in a page's colours: the status bar text and the
|
|
3
|
+
* home indicator go dark on a light page and light on a dark one, as iOS and
|
|
4
|
+
* Android draw them.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Parse `#rgb`, `#rrggbb` or `rgb()/rgba()` into channels, or null. */
|
|
8
|
+
function channels(colour: string): [number, number, number] | null {
|
|
9
|
+
const hex = /^#([\da-f]{3}|[\da-f]{6})$/i.exec(colour.trim());
|
|
10
|
+
if (hex) {
|
|
11
|
+
const digits = hex[1].length === 3 ? hex[1].replace(/./g, (d) => d + d) : hex[1];
|
|
12
|
+
return [0, 2, 4].map((i) => parseInt(digits.slice(i, i + 2), 16)) as [number, number, number];
|
|
13
|
+
}
|
|
14
|
+
const rgb = /rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(colour);
|
|
15
|
+
return rgb ? [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])] : null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function foregroundFor(colour: string | null | undefined): string {
|
|
19
|
+
const rgb = colour ? channels(colour) : null;
|
|
20
|
+
if (!rgb) return '#111113';
|
|
21
|
+
const [r, g, b] = rgb;
|
|
22
|
+
const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
23
|
+
return luminance > 0.6 ? '#111113' : '#fff';
|
|
24
|
+
}
|
|
@@ -11,6 +11,7 @@ import { tmpdir } from 'node:os';
|
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
|
|
13
13
|
import { elapsedSeconds, supervise } from './process-supervisor';
|
|
14
|
+
import { RESTART_EXIT_CODE } from './supervisor-protocol';
|
|
14
15
|
|
|
15
16
|
const posix = process.platform !== 'win32';
|
|
16
17
|
const dir = mkdtempSync(join(tmpdir(), 'clopen-supervisor-'));
|
|
@@ -148,7 +149,7 @@ describe.if(posix)('supervise', () => {
|
|
|
148
149
|
const child = join(dir, 'watching-child.ts');
|
|
149
150
|
writeFileSync(
|
|
150
151
|
child,
|
|
151
|
-
`import { watchSupervisor } from ${JSON.stringify(join(import.meta.dir, '
|
|
152
|
+
`import { watchSupervisor } from ${JSON.stringify(join(import.meta.dir, 'supervised-child.ts'))};
|
|
152
153
|
watchSupervisor(() => { require('node:fs').writeFileSync(${JSON.stringify(marker)}, 'gone'); process.exit(0); }, 100);
|
|
153
154
|
console.log('watching'); setInterval(() => {}, 1000);`
|
|
154
155
|
);
|
|
@@ -166,6 +167,22 @@ describe.if(posix)('supervise', () => {
|
|
|
166
167
|
expect(readFileSync(marker, 'utf8')).toBe('gone');
|
|
167
168
|
});
|
|
168
169
|
|
|
170
|
+
test('a child that asks for a restart comes back at once, undiagnosed and off the crash budget', async () => {
|
|
171
|
+
const counter = join(dir, 'restart-count');
|
|
172
|
+
writeFileSync(counter, '');
|
|
173
|
+
const logs: string[] = [];
|
|
174
|
+
const reportFile = join(dir, 'restart-report.log');
|
|
175
|
+
// Asks for a restart three times, then stays up: more than maxRestarts
|
|
176
|
+
// allows for crashes, and with a restart delay far longer than the test.
|
|
177
|
+
const script = `echo x >> ${counter}; [ $(wc -l < ${counter}) -le 3 ] && exit ${RESTART_EXIT_CODE}; sleep 30`;
|
|
178
|
+
const s = supervise({ name: 'server', cmd: ['sh', '-c', script], log: (line) => logs.push(line), reportFile, restartDelayMs: 60_000, maxRestarts: 1 });
|
|
179
|
+
|
|
180
|
+
await waitFor(() => readFileSync(counter, 'utf8').split('\n').filter(Boolean).length === 4);
|
|
181
|
+
expect(logs.filter((line) => line.includes('restarting on request'))).toHaveLength(3);
|
|
182
|
+
expect(existsSync(reportFile)).toBe(false);
|
|
183
|
+
await s.stop();
|
|
184
|
+
});
|
|
185
|
+
|
|
169
186
|
test('gives up on a child that keeps dying', async () => {
|
|
170
187
|
const s = supervise({ name: 't', cmd: ['sh', '-c', 'exit 3'], log: () => {}, restartDelayMs: 10, maxRestarts: 2 });
|
|
171
188
|
expect(await s.done).toBe(3);
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
* started from a terminal. Run without one — `nohup`, a service, a container
|
|
26
26
|
* — it is ignored and the server keeps running. Writes to a terminal that is
|
|
27
27
|
* gone are dropped instead of crashing.
|
|
28
|
+
* - **Restarted on request, too.** A child that exits with RESTART_EXIT_CODE
|
|
29
|
+
* asked to be replaced — the server does this after an update so the new
|
|
30
|
+
* code takes over without anyone touching the terminal. It comes back at
|
|
31
|
+
* once, is not diagnosed, and does not count towards the crash budget.
|
|
28
32
|
* - **Diagnosed.** Each unrequested exit is logged with its code or signal and
|
|
29
33
|
* the processes started shortly before it (pid, ppid, pgid, command), to the
|
|
30
34
|
* console and to `reportFile`, so the next occurrence leaves a trail. The OS
|
|
@@ -35,6 +39,7 @@
|
|
|
35
39
|
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
36
40
|
import { dirname } from 'node:path';
|
|
37
41
|
import { collectDescendants, parentForwardsSignals, signalAll, waitForExit } from './process-tree';
|
|
42
|
+
import { RESTART_EXIT_CODE, SUPERVISOR_PID_ENV } from './supervisor-protocol';
|
|
38
43
|
|
|
39
44
|
type Subprocess = ReturnType<typeof Bun.spawn>;
|
|
40
45
|
|
|
@@ -69,28 +74,6 @@ export interface Supervisor {
|
|
|
69
74
|
|
|
70
75
|
const IS_WINDOWS = process.platform === 'win32';
|
|
71
76
|
|
|
72
|
-
/** Tells a supervised child which process supervises it. */
|
|
73
|
-
export const SUPERVISOR_PID_ENV = 'CLOPEN_SUPERVISOR_PID';
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* In a supervised child: run `onGone` once the supervisor that started it is
|
|
77
|
-
* gone (its parent pid changes), so the child does not outlive an ungraceful
|
|
78
|
-
* end of its supervisor. The variable is removed from the environment at once:
|
|
79
|
-
* everything the child starts inherits it — terminal shells included — and a
|
|
80
|
-
* dev server started from one would otherwise watch the wrong supervisor.
|
|
81
|
-
*/
|
|
82
|
-
export function watchSupervisor(onGone: () => void, pollMs = 1000): void {
|
|
83
|
-
const supervisorPid = Number(process.env[SUPERVISOR_PID_ENV]);
|
|
84
|
-
delete process.env[SUPERVISOR_PID_ENV];
|
|
85
|
-
if (!(supervisorPid > 0) || process.ppid !== supervisorPid) return;
|
|
86
|
-
const timer = setInterval(() => {
|
|
87
|
-
if (process.ppid === supervisorPid) return;
|
|
88
|
-
clearInterval(timer);
|
|
89
|
-
onGone();
|
|
90
|
-
}, pollMs);
|
|
91
|
-
timer.unref?.();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
77
|
/** Run `options.cmd` under supervision until it is stopped. */
|
|
95
78
|
export function supervise(options: SupervisedProcessOptions): Supervisor {
|
|
96
79
|
const log = options.log ?? ((line: string) => console.error(line));
|
|
@@ -109,7 +92,7 @@ export function supervise(options: SupervisedProcessOptions): Supervisor {
|
|
|
109
92
|
child = Bun.spawn(options.cmd, {
|
|
110
93
|
cwd: options.cwd,
|
|
111
94
|
// The child stops itself if this supervisor disappears without stopping
|
|
112
|
-
// it (see
|
|
95
|
+
// it (see supervised-child.ts) — killed outright, a terminal runner's own
|
|
113
96
|
// SIGKILL — instead of running on, unowned, holding its port.
|
|
114
97
|
env: { ...(options.env ?? process.env), [SUPERVISOR_PID_ENV]: String(process.pid) } as Record<string, string>,
|
|
115
98
|
stdin: 'ignore',
|
|
@@ -137,6 +120,12 @@ export function supervise(options: SupervisedProcessOptions): Supervisor {
|
|
|
137
120
|
return;
|
|
138
121
|
}
|
|
139
122
|
|
|
123
|
+
if (code === RESTART_EXIT_CODE && !signal) {
|
|
124
|
+
log(`[${options.name}] restarting on request…`);
|
|
125
|
+
spawnChild();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
140
129
|
const now = Date.now();
|
|
141
130
|
while (restarts.length > 0 && now - restarts[0] > restartWindowMs) restarts.shift();
|
|
142
131
|
const description = signal ? `signal ${signal}` : `code ${code}`;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { afterAll, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { clearRestartIntent, readRestartIntent, writeRestartIntent } from './restart-intent';
|
|
7
|
+
|
|
8
|
+
const dir = mkdtempSync(join(tmpdir(), 'clopen-restart-intent-'));
|
|
9
|
+
const file = join(dir, 'restart-intent.json');
|
|
10
|
+
afterAll(() => rmSync(dir, { recursive: true, force: true }));
|
|
11
|
+
|
|
12
|
+
describe('restart intent', () => {
|
|
13
|
+
test('is read by the child of the supervisor it names, until the server is listening', () => {
|
|
14
|
+
writeRestartIntent(dir, 9142, 4242);
|
|
15
|
+
expect(readRestartIntent(dir, 4242)?.port).toBe(9142);
|
|
16
|
+
// A successor that failed to start is retried, and must find it again.
|
|
17
|
+
expect(readRestartIntent(dir, 4242)?.port).toBe(9142);
|
|
18
|
+
clearRestartIntent(dir, 4242);
|
|
19
|
+
expect(readRestartIntent(dir, 4242)).toBeNull();
|
|
20
|
+
expect(existsSync(file)).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('is not cleared by a server another supervisor started', () => {
|
|
24
|
+
writeRestartIntent(dir, 9142, 4242);
|
|
25
|
+
// A second instance on the same data directory finishing its own start.
|
|
26
|
+
clearRestartIntent(dir, 5555);
|
|
27
|
+
expect(readRestartIntent(dir, 4242)?.port).toBe(9142);
|
|
28
|
+
clearRestartIntent(dir, 4242);
|
|
29
|
+
expect(existsSync(file)).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('is ignored, and kept, by a process another supervisor started', () => {
|
|
33
|
+
writeRestartIntent(dir, 9142, 4242);
|
|
34
|
+
// `clopen --port 9300` right after, or a second instance on this data dir.
|
|
35
|
+
expect(readRestartIntent(dir, 5555)).toBeNull();
|
|
36
|
+
expect(readRestartIntent(dir, 0)).toBeNull();
|
|
37
|
+
expect(existsSync(file)).toBe(true);
|
|
38
|
+
expect(readRestartIntent(dir, 4242)?.port).toBe(9142);
|
|
39
|
+
clearRestartIntent(dir, 4242);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('a stale intent is ignored and removed', () => {
|
|
43
|
+
writeRestartIntent(dir, 9141, 4242);
|
|
44
|
+
expect(readRestartIntent(dir, 4242, Date.now() + 120_000)).toBeNull();
|
|
45
|
+
expect(existsSync(file)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('a corrupt or old-format intent is ignored and removed', () => {
|
|
49
|
+
writeFileSync(file, '{nope');
|
|
50
|
+
expect(readRestartIntent(dir, 4242)).toBeNull();
|
|
51
|
+
expect(existsSync(file)).toBe(false);
|
|
52
|
+
|
|
53
|
+
writeFileSync(file, JSON.stringify({ port: 9141, at: Date.now() }));
|
|
54
|
+
expect(readRestartIntent(dir, 4242)).toBeNull();
|
|
55
|
+
expect(existsSync(file)).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The note a server leaves for its successor when it restarts on purpose.
|
|
3
|
+
*
|
|
4
|
+
* scripts/start.ts normally takes the first free port from CLOPEN_PORT up.
|
|
5
|
+
* On a restart that is wrong twice over: the old process may still be letting
|
|
6
|
+
* go of its port, and the server may have been on a fallback port (9142
|
|
7
|
+
* because 9141 was taken) that the browser tab is connected to. Either way
|
|
8
|
+
* the successor would come up somewhere the tab is not looking. The intent
|
|
9
|
+
* says which port to come back on; start.ts waits for it instead of moving.
|
|
10
|
+
*
|
|
11
|
+
* It names the supervisor that will start the successor, and only that
|
|
12
|
+
* supervisor's child honours it. Anything else starting in the same data
|
|
13
|
+
* directory — a `clopen --port 9300` typed right after, a second instance —
|
|
14
|
+
* must not be pulled onto another server's port.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
|
|
20
|
+
export interface RestartIntent {
|
|
21
|
+
port: number;
|
|
22
|
+
/** The supervisor whose next child this is for. */
|
|
23
|
+
supervisorPid: number;
|
|
24
|
+
/** When it was written (ms epoch) — a stale note from a crash is ignored. */
|
|
25
|
+
at: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const FILE = 'restart-intent.json';
|
|
29
|
+
const MAX_AGE_MS = 60_000;
|
|
30
|
+
|
|
31
|
+
export function writeRestartIntent(dataDir: string, port: number, supervisorPid: number): void {
|
|
32
|
+
mkdirSync(dataDir, { recursive: true });
|
|
33
|
+
writeFileSync(join(dataDir, FILE), JSON.stringify({ port, supervisorPid, at: Date.now() } satisfies RestartIntent));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The intent left for this process — started by `supervisorPid` — or null when
|
|
38
|
+
* there is none, it is too old, or it is for someone else. A stale or broken
|
|
39
|
+
* intent is removed; a valid one stays until the server is listening again
|
|
40
|
+
* (clearRestartIntent), so a successor that fails to start and is retried by
|
|
41
|
+
* the supervisor still comes back on the same port.
|
|
42
|
+
*/
|
|
43
|
+
export function readRestartIntent(dataDir: string, supervisorPid: number, now = Date.now()): RestartIntent | null {
|
|
44
|
+
const path = join(dataDir, FILE);
|
|
45
|
+
if (!existsSync(path)) return null;
|
|
46
|
+
let intent: Partial<RestartIntent>;
|
|
47
|
+
try {
|
|
48
|
+
intent = JSON.parse(readFileSync(path, 'utf-8')) as Partial<RestartIntent>;
|
|
49
|
+
} catch {
|
|
50
|
+
rmSync(path, { force: true });
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (typeof intent.port !== 'number' || typeof intent.at !== 'number' || typeof intent.supervisorPid !== 'number') {
|
|
54
|
+
rmSync(path, { force: true });
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (now - intent.at > MAX_AGE_MS) {
|
|
58
|
+
rmSync(path, { force: true });
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (!(supervisorPid > 0) || intent.supervisorPid !== supervisorPid) return null;
|
|
62
|
+
return { port: intent.port, supervisorPid: intent.supervisorPid, at: intent.at };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Called once the server is listening: the restart the intent was for is over.
|
|
67
|
+
* Only an intent for this server's supervisor is removed — another instance on
|
|
68
|
+
* the same data directory may be in the middle of its own restart.
|
|
69
|
+
*/
|
|
70
|
+
export function clearRestartIntent(dataDir: string, supervisorPid: number): void {
|
|
71
|
+
const path = join(dataDir, FILE);
|
|
72
|
+
if (!existsSync(path)) return;
|
|
73
|
+
try {
|
|
74
|
+
const intent = JSON.parse(readFileSync(path, 'utf-8')) as Partial<RestartIntent>;
|
|
75
|
+
if (intent.supervisorPid !== supervisorPid) return;
|
|
76
|
+
} catch {
|
|
77
|
+
// Unreadable: nobody can use it.
|
|
78
|
+
}
|
|
79
|
+
rmSync(path, { force: true });
|
|
80
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { compareVersions, isNewerVersion, stripVersionPrefix } from './semver';
|
|
4
|
+
|
|
5
|
+
describe('compareVersions', () => {
|
|
6
|
+
test('orders numerically, not as text', () => {
|
|
7
|
+
expect(compareVersions('0.4.10', '0.4.9')).toBeGreaterThan(0);
|
|
8
|
+
expect(compareVersions('0.4.9', '0.10.0')).toBeLessThan(0);
|
|
9
|
+
expect(compareVersions('1.0.0', '0.99.99')).toBeGreaterThan(0);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('treats a v prefix and missing parts as equal', () => {
|
|
13
|
+
expect(compareVersions('v0.4.50', '0.4.50')).toBe(0);
|
|
14
|
+
expect(compareVersions('0.5', '0.5.0')).toBe(0);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('ignores pre-release and build suffixes', () => {
|
|
18
|
+
expect(compareVersions('0.4.50-beta.1', '0.4.50')).toBe(0);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('isNewerVersion', () => {
|
|
23
|
+
test('is true only for a strictly newer candidate', () => {
|
|
24
|
+
expect(isNewerVersion('0.4.49', '0.4.50')).toBe(true);
|
|
25
|
+
expect(isNewerVersion('0.4.50', '0.4.50')).toBe(false);
|
|
26
|
+
expect(isNewerVersion('0.4.50', '0.4.49')).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('stripVersionPrefix', () => {
|
|
31
|
+
expect(stripVersionPrefix('v0.4.50')).toBe('0.4.50');
|
|
32
|
+
expect(stripVersionPrefix('0.4.50')).toBe('0.4.50');
|
|
33
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Just enough semver for Clopen's own release numbers (`0.4.50`, `v0.4.50`).
|
|
3
|
+
*
|
|
4
|
+
* Clopen publishes plain `major.minor.patch` versions, so pre-release tags and
|
|
5
|
+
* build metadata are not ordered — anything after the patch number is ignored.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function parts(version: string): number[] {
|
|
9
|
+
return version
|
|
10
|
+
.replace(/^v/, '')
|
|
11
|
+
.split(/[-+]/)[0]
|
|
12
|
+
.split('.')
|
|
13
|
+
.slice(0, 3)
|
|
14
|
+
.map(part => Number.parseInt(part, 10) || 0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Negative when `a` is older than `b`, positive when newer, 0 when equal. */
|
|
18
|
+
export function compareVersions(a: string, b: string): number {
|
|
19
|
+
const left = parts(a);
|
|
20
|
+
const right = parts(b);
|
|
21
|
+
for (let i = 0; i < 3; i++) {
|
|
22
|
+
const diff = (left[i] ?? 0) - (right[i] ?? 0);
|
|
23
|
+
if (diff !== 0) return diff;
|
|
24
|
+
}
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isNewerVersion(current: string, candidate: string): boolean {
|
|
29
|
+
return compareVersions(candidate, current) > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** `v0.4.50` → `0.4.50`. */
|
|
33
|
+
export function stripVersionPrefix(version: string): string {
|
|
34
|
+
return version.replace(/^v/, '');
|
|
35
|
+
}
|