@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,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine transcripts through their whole life: referenced by chats, found unused,
|
|
3
|
+
* deduplicated into an alias, released when their chat is deleted or slimmed.
|
|
4
|
+
*
|
|
5
|
+
* Runs against the test data dir (`~/.clopen-test`), with Claude transcripts
|
|
6
|
+
* written into its isolated engine home.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { afterAll, beforeAll, describe, expect, it } from 'bun:test';
|
|
10
|
+
import { existsSync, mkdirSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { closeDatabase, initializeDatabase } from '$backend/database';
|
|
13
|
+
import { messageQueries, projectQueries, sessionQueries } from '$backend/database/queries';
|
|
14
|
+
import type { UnifiedMessage } from '$shared/types/unified';
|
|
15
|
+
import { slimSession } from './chats';
|
|
16
|
+
import { purgeSessions, releaseTranscripts } from './purge';
|
|
17
|
+
import { collectEngineRefs, measureSession, refreshSessionIndex } from './session-index';
|
|
18
|
+
import {
|
|
19
|
+
applyDedupe, listAllTranscripts, removeOrphans, resolveTranscriptAlias, selectOrphans, selectRedundant, transcriptExists,
|
|
20
|
+
type TranscriptUsage
|
|
21
|
+
} from './transcripts';
|
|
22
|
+
import { claudeProjectsRoot } from './transcripts/claude';
|
|
23
|
+
|
|
24
|
+
const projectDir = join(claudeProjectsRoot(), 'storage-flow-test');
|
|
25
|
+
const id = () => crypto.randomUUID();
|
|
26
|
+
const A1 = id();
|
|
27
|
+
const A2 = id();
|
|
28
|
+
const B1 = id();
|
|
29
|
+
const ORPHAN = id();
|
|
30
|
+
const FRESH = id();
|
|
31
|
+
const DAY_AGO = (Date.now() - 24 * 60 * 60_000) / 1000;
|
|
32
|
+
|
|
33
|
+
let projectId: string;
|
|
34
|
+
let chatA: string;
|
|
35
|
+
let chatB: string;
|
|
36
|
+
|
|
37
|
+
const engine = { type: 'claude-code', provider: '', model: { id: '', name: '' }, account: { id: 0, name: '' } };
|
|
38
|
+
function assistant(sessionId: string, text = 'ok'): UnifiedMessage {
|
|
39
|
+
return {
|
|
40
|
+
type: 'assistant', createdAt: '', messageId: '', sessionId, stopReason: null, usage: null,
|
|
41
|
+
parent: { messageId: null, sessionId: null, toolUseId: null }, engine,
|
|
42
|
+
content: [{ type: 'text', text }]
|
|
43
|
+
} as unknown as UnifiedMessage;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function writeTranscript(sessionId: string, uuids: string[], extra = ''): void {
|
|
47
|
+
const lines = uuids.map((uuid, i) => JSON.stringify({ type: 'user', uuid, parentUuid: i === 0 ? null : uuids[i - 1], sessionId, text: extra }));
|
|
48
|
+
const file = join(projectDir, `${sessionId}.jsonl`);
|
|
49
|
+
writeFileSync(file, lines.join('\n') + '\n');
|
|
50
|
+
utimesSync(file, DAY_AGO, DAY_AGO);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function usage(): Promise<TranscriptUsage> {
|
|
54
|
+
await refreshSessionIndex();
|
|
55
|
+
const { byEngine, owners } = collectEngineRefs();
|
|
56
|
+
return { refs: byEngine, owners, active: new Set() };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
beforeAll(async () => {
|
|
60
|
+
await initializeDatabase();
|
|
61
|
+
const now = new Date().toISOString();
|
|
62
|
+
projectId = projectQueries.create({ name: 'storage-flow', path: `/tmp/storage-flow-${id()}`, created_at: now, last_opened_at: now } as never).id;
|
|
63
|
+
chatA = sessionQueries.create({ project_id: projectId, engine: 'claude-code', started_at: now } as never).id;
|
|
64
|
+
chatB = sessionQueries.create({ project_id: projectId, engine: 'claude-code', started_at: now } as never).id;
|
|
65
|
+
for (const [chat, sessionId] of [[chatA, A1], [chatA, A2], [chatB, B1]] as const) {
|
|
66
|
+
const row = messageQueries.create({ session_id: chat, message: assistant(sessionId, 'y'.repeat(6000)) });
|
|
67
|
+
sessionQueries.updateHead(chat, row.id);
|
|
68
|
+
sessionQueries.updateOnMessage(chat, { messageType: 'assistant', timestamp: new Date().toISOString() });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
mkdirSync(projectDir, { recursive: true });
|
|
72
|
+
writeTranscript(A1, ['a', 'b']);
|
|
73
|
+
// A2 is the next fork: every entry of A1, and it points at A1's side files.
|
|
74
|
+
writeTranscript(A2, ['a', 'b', 'c', 'd'], `${projectDir}/${A1}/tool-results/out.txt`);
|
|
75
|
+
mkdirSync(join(projectDir, A1, 'tool-results'), { recursive: true });
|
|
76
|
+
writeFileSync(join(projectDir, A1, 'tool-results', 'out.txt'), 'output');
|
|
77
|
+
writeTranscript(B1, ['e']);
|
|
78
|
+
writeTranscript(ORPHAN, ['o']);
|
|
79
|
+
writeFileSync(join(projectDir, `${FRESH}.jsonl`), '{"uuid":"f","parentUuid":null}\n');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
afterAll(() => {
|
|
83
|
+
rmSync(projectDir, { recursive: true, force: true });
|
|
84
|
+
sessionQueries.deleteAllByProjectId(projectId);
|
|
85
|
+
projectQueries.deleteProject(projectId);
|
|
86
|
+
closeDatabase();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('storage transcript lifecycle', () => {
|
|
90
|
+
it('reads the engine sessions each chat refers to', () => {
|
|
91
|
+
expect(measureSession(chatA).refs.map(ref => ref.id).sort()).toEqual([A1, A2].sort());
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('finds unused transcripts, but not ones touched within the grace period', async () => {
|
|
95
|
+
const orphans = selectOrphans(await listAllTranscripts(), await usage()).map(entry => entry.id);
|
|
96
|
+
expect(orphans).toContain(ORPHAN);
|
|
97
|
+
expect(orphans).not.toContain(FRESH);
|
|
98
|
+
expect(orphans).not.toContain(A1);
|
|
99
|
+
expect(orphans).not.toContain(B1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('replaces a contained fork by an alias and keeps the side files the later fork points at', async () => {
|
|
103
|
+
const u = await usage();
|
|
104
|
+
const redundant = await selectRedundant(await listAllTranscripts(), u);
|
|
105
|
+
expect(redundant.map(item => [item.entry.id, item.target.id, item.resumeAt])).toEqual([[A1, A2, 'b']]);
|
|
106
|
+
|
|
107
|
+
await applyDedupe(redundant);
|
|
108
|
+
expect(existsSync(join(projectDir, `${A1}.jsonl`))).toBe(false);
|
|
109
|
+
expect(existsSync(join(projectDir, A1, 'tool-results', 'out.txt'))).toBe(true);
|
|
110
|
+
expect(resolveTranscriptAlias('claude-code', A1)).toEqual({ targetSessionId: A2, resumeAt: 'b' });
|
|
111
|
+
expect(await transcriptExists('claude-code', A1, '/')).toBe(false);
|
|
112
|
+
expect(await transcriptExists('claude-code', A2, '/')).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('removes unused transcripts', async () => {
|
|
116
|
+
const u = await usage();
|
|
117
|
+
const result = await removeOrphans(selectOrphans(await listAllTranscripts(), u), u);
|
|
118
|
+
expect(result.errors).toEqual([]);
|
|
119
|
+
expect(existsSync(join(projectDir, `${ORPHAN}.jsonl`))).toBe(false);
|
|
120
|
+
expect(existsSync(join(projectDir, `${FRESH}.jsonl`))).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('releases a slimmed chat’s transcripts', async () => {
|
|
124
|
+
await slimSession(chatB);
|
|
125
|
+
expect(sessionQueries.getById(chatB)?.slimmed_at).toBeTruthy();
|
|
126
|
+
expect(existsSync(join(projectDir, `${B1}.jsonl`))).toBe(false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('deleting a chat removes its transcripts, side files and aliases', async () => {
|
|
130
|
+
const refs = measureSession(chatA).refs;
|
|
131
|
+
await purgeSessions([chatA]);
|
|
132
|
+
await releaseTranscripts(refs);
|
|
133
|
+
expect(existsSync(join(projectDir, `${A2}.jsonl`))).toBe(false);
|
|
134
|
+
expect(existsSync(join(projectDir, A1))).toBe(false);
|
|
135
|
+
expect(resolveTranscriptAlias('claude-code', A1)).toBeNull();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deduplicated transcripts, remembered as "resume this other one, cut here".
|
|
3
|
+
*
|
|
4
|
+
* A row says: engine session `session_id` no longer has a file of its own; the
|
|
5
|
+
* same conversation state is `target_session_id` resumed at entry `resume_at`.
|
|
6
|
+
* Chains are flattened as they form — when a target is itself deduplicated, the
|
|
7
|
+
* rows pointing at it are re-pointed at the new target in the same statement —
|
|
8
|
+
* so resolution is normally one lookup.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { getDatabase } from '$backend/database';
|
|
12
|
+
import type { EngineType } from '$shared/types/unified';
|
|
13
|
+
|
|
14
|
+
export interface TranscriptAlias {
|
|
15
|
+
targetSessionId: string;
|
|
16
|
+
resumeAt: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Where `sessionId` lives now, or null when it was never deduplicated. */
|
|
20
|
+
export function resolveTranscriptAlias(engine: EngineType, sessionId: string): TranscriptAlias | null {
|
|
21
|
+
const db = getDatabase();
|
|
22
|
+
const lookup = db.prepare(
|
|
23
|
+
'SELECT target_session_id, resume_at FROM engine_transcript_aliases WHERE engine = ? AND session_id = ?'
|
|
24
|
+
);
|
|
25
|
+
let row = lookup.get(engine, sessionId) as { target_session_id: string; resume_at: string } | null;
|
|
26
|
+
if (!row) return null;
|
|
27
|
+
const resumeAt = row.resume_at;
|
|
28
|
+
let target = row.target_session_id;
|
|
29
|
+
// Flattened on write; followed here only in case a write was interrupted.
|
|
30
|
+
for (let hops = 0; hops < 32; hops++) {
|
|
31
|
+
row = lookup.get(engine, target) as { target_session_id: string; resume_at: string } | null;
|
|
32
|
+
if (!row) break;
|
|
33
|
+
target = row.target_session_id;
|
|
34
|
+
}
|
|
35
|
+
return { targetSessionId: target, resumeAt };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function recordTranscriptAlias(engine: EngineType, sessionId: string, targetSessionId: string, resumeAt: string): void {
|
|
39
|
+
const db = getDatabase();
|
|
40
|
+
const write = () => {
|
|
41
|
+
db.prepare(`
|
|
42
|
+
INSERT INTO engine_transcript_aliases (engine, session_id, target_session_id, resume_at, created_at)
|
|
43
|
+
VALUES (?, ?, ?, ?, ?)
|
|
44
|
+
ON CONFLICT(engine, session_id) DO UPDATE SET
|
|
45
|
+
target_session_id = excluded.target_session_id,
|
|
46
|
+
resume_at = excluded.resume_at
|
|
47
|
+
`).run(engine, sessionId, targetSessionId, resumeAt, new Date().toISOString());
|
|
48
|
+
db.prepare('UPDATE engine_transcript_aliases SET target_session_id = ? WHERE engine = ? AND target_session_id = ?')
|
|
49
|
+
.run(targetSessionId, engine, sessionId);
|
|
50
|
+
};
|
|
51
|
+
if (db.transaction) db.transaction(write)();
|
|
52
|
+
else write();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Every session id some alias resumes into. Those transcripts are in use. */
|
|
56
|
+
export function transcriptAliasTargets(engine: EngineType): Set<string> {
|
|
57
|
+
const rows = getDatabase().prepare('SELECT DISTINCT target_session_id FROM engine_transcript_aliases WHERE engine = ?')
|
|
58
|
+
.all(engine) as { target_session_id: string }[];
|
|
59
|
+
return new Set(rows.map(row => row.target_session_id));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Forget aliases no chat refers to any more. Returns how many went. */
|
|
63
|
+
export function pruneTranscriptAliases(engine: EngineType, referenced: Set<string>): number {
|
|
64
|
+
const db = getDatabase();
|
|
65
|
+
const rows = db.prepare('SELECT session_id FROM engine_transcript_aliases WHERE engine = ?')
|
|
66
|
+
.all(engine) as { session_id: string }[];
|
|
67
|
+
const stale = rows.map(row => row.session_id).filter(id => !referenced.has(id));
|
|
68
|
+
const remove = db.prepare('DELETE FROM engine_transcript_aliases WHERE engine = ? AND session_id = ?');
|
|
69
|
+
const prune = () => {
|
|
70
|
+
for (const id of stale) remove.run(engine, id);
|
|
71
|
+
};
|
|
72
|
+
if (db.transaction) db.transaction(prune)();
|
|
73
|
+
else prune();
|
|
74
|
+
return stale.length;
|
|
75
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Claude fork is redundant only when a later one holds every entry of it;
|
|
3
|
+
* branches that diverged are both kept.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { afterAll, describe, expect, it } from 'bun:test';
|
|
7
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { findContained, groupByOwner, readChain, type ChainSummary } from './claude-dedupe';
|
|
11
|
+
import type { TranscriptEntry } from './types';
|
|
12
|
+
|
|
13
|
+
const dir = mkdtempSync(join(tmpdir(), 'clopen-dedupe-'));
|
|
14
|
+
afterAll(() => rmSync(dir, { recursive: true, force: true }));
|
|
15
|
+
|
|
16
|
+
function entry(id: string, mtimeMs = 0): TranscriptEntry {
|
|
17
|
+
return { engine: 'claude-code', id, paths: [join(dir, `${id}.jsonl`)], bytes: 1, mtimeMs, projectKey: 'p', projectPath: null };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function chain(...uuids: string[]): ChainSummary {
|
|
21
|
+
return { uuids: new Set(uuids), tip: uuids.at(-1) ?? null };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('readChain', () => {
|
|
25
|
+
it('collects chain entries and the last one as the tip, skipping metadata and sidechains', async () => {
|
|
26
|
+
const file = join(dir, 'chain.jsonl');
|
|
27
|
+
writeFileSync(file, [
|
|
28
|
+
JSON.stringify({ type: 'ai-title', aiTitle: 'x', sessionId: 's' }),
|
|
29
|
+
JSON.stringify({ type: 'user', uuid: 'a', parentUuid: null }),
|
|
30
|
+
JSON.stringify({ type: 'assistant', uuid: 'b', parentUuid: 'a' }),
|
|
31
|
+
JSON.stringify({ type: 'assistant', uuid: 'side', parentUuid: 'b', isSidechain: true }),
|
|
32
|
+
JSON.stringify({ type: 'attachment', uuid: 'c', parentUuid: 'b' }),
|
|
33
|
+
JSON.stringify({ type: 'cost-state', sessionId: 's' }),
|
|
34
|
+
'{"type":"user","uuid":"torn","parentUu'
|
|
35
|
+
].join('\n'));
|
|
36
|
+
const summary = await readChain(file);
|
|
37
|
+
expect(summary).not.toBeNull();
|
|
38
|
+
expect([...summary!.uuids]).toEqual(['a', 'b', 'c']);
|
|
39
|
+
expect(summary!.tip).toBe('c');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('returns null for a file that cannot be read', async () => {
|
|
43
|
+
expect(await readChain(join(dir, 'missing.jsonl'))).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('findContained', () => {
|
|
48
|
+
it('aliases each earlier fork to the fork that contains it, cut at its own tip', () => {
|
|
49
|
+
const result = findContained([
|
|
50
|
+
{ entry: entry('t1'), chain: chain('a', 'b') },
|
|
51
|
+
{ entry: entry('t2'), chain: chain('a', 'b', 'c', 'd') },
|
|
52
|
+
{ entry: entry('t3'), chain: chain('a', 'b', 'c', 'd', 'e', 'f') }
|
|
53
|
+
]);
|
|
54
|
+
expect(result.map(r => [r.entry.id, r.target.id, r.resumeAt]).sort()).toEqual([
|
|
55
|
+
['t1', 't3', 'b'],
|
|
56
|
+
['t2', 't3', 'd']
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('keeps both ends of a branch', () => {
|
|
61
|
+
const result = findContained([
|
|
62
|
+
{ entry: entry('base'), chain: chain('a', 'b') },
|
|
63
|
+
{ entry: entry('left'), chain: chain('a', 'b', 'l1') },
|
|
64
|
+
{ entry: entry('right'), chain: chain('a', 'b', 'r1', 'r2') }
|
|
65
|
+
]);
|
|
66
|
+
expect(result.map(r => r.entry.id)).toEqual(['base']);
|
|
67
|
+
expect(result[0].target.id).toBe('right');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('keeps the newer of two identical files', () => {
|
|
71
|
+
const result = findContained([
|
|
72
|
+
{ entry: entry('old', 1), chain: chain('a', 'b') },
|
|
73
|
+
{ entry: entry('new', 2), chain: chain('a', 'b') }
|
|
74
|
+
]);
|
|
75
|
+
expect(result.map(r => [r.entry.id, r.target.id])).toEqual([['old', 'new']]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('never aliases a file one entry short of containment', () => {
|
|
79
|
+
const result = findContained([
|
|
80
|
+
{ entry: entry('x'), chain: chain('a', 'b', 'z') },
|
|
81
|
+
{ entry: entry('y'), chain: chain('a', 'b', 'c', 'd') }
|
|
82
|
+
]);
|
|
83
|
+
expect(result).toEqual([]);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('groupByOwner', () => {
|
|
88
|
+
it('groups transcripts of chats that share an engine session, and drops unowned ones', () => {
|
|
89
|
+
const owners = new Map<string, Set<string>>([
|
|
90
|
+
['t1', new Set(['chatA'])],
|
|
91
|
+
['t2', new Set(['chatA', 'chatB'])],
|
|
92
|
+
['t3', new Set(['chatB'])],
|
|
93
|
+
['t4', new Set(['chatC'])],
|
|
94
|
+
['t5', new Set(['chatC'])]
|
|
95
|
+
]);
|
|
96
|
+
const groups = groupByOwner(['t1', 't2', 't3', 't4', 't5', 'orphan'].map(id => entry(id)), owners)
|
|
97
|
+
.map(group => group.map(e => e.id).sort())
|
|
98
|
+
.sort((a, b) => a[0].localeCompare(b[0]));
|
|
99
|
+
expect(groups).toEqual([['t1', 't2', 't3'], ['t4', 't5']]);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude fork deduplication.
|
|
3
|
+
*
|
|
4
|
+
* Clopen resumes Claude with `forkSession: true` on every turn (lessons-learned
|
|
5
|
+
* §10.10: each turn needs its own immutable session id so a branch can be cut at
|
|
6
|
+
* any message). The SDK implements a fork by copying the whole conversation into
|
|
7
|
+
* a new file under the new id, KEEPING every entry's uuid. A chat of N turns
|
|
8
|
+
* therefore leaves N files whose sizes add up to roughly N²/2 turns of content —
|
|
9
|
+
* one measured chat held 265 files and 2.6 GB for a conversation whose newest
|
|
10
|
+
* file is 25 MB.
|
|
11
|
+
*
|
|
12
|
+
* Because uuids survive the copy, an earlier fork F is entirely contained in a
|
|
13
|
+
* later fork G of the same conversation, and "resume F" is the same state as
|
|
14
|
+
* "resume G, cut at F's last entry" (`resumeSessionAt`). So F's file can go and
|
|
15
|
+
* be remembered as that alias. Containment is checked on the actual entries,
|
|
16
|
+
* never inferred from names, order or size: a file is deduplicated only when
|
|
17
|
+
* every chain entry it holds is present in the target.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { readFileChunks, yieldToEventLoop } from '../fs-size';
|
|
21
|
+
import type { TranscriptEntry } from './types';
|
|
22
|
+
|
|
23
|
+
export interface ChainSummary {
|
|
24
|
+
uuids: Set<string>;
|
|
25
|
+
/** uuid of the last chain entry — what `resumeSessionAt` cuts at. */
|
|
26
|
+
tip: string | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The chain entries of a transcript: every line that carries a top-level `uuid`
|
|
31
|
+
* and sits in the parent chain (`parentUuid` present, even as null). Metadata
|
|
32
|
+
* lines (titles, cost state, queue operations) have neither and are skipped.
|
|
33
|
+
*/
|
|
34
|
+
export async function readChain(file: string): Promise<ChainSummary | null> {
|
|
35
|
+
const uuids = new Set<string>();
|
|
36
|
+
let tip: string | null = null;
|
|
37
|
+
const decoder = new TextDecoder();
|
|
38
|
+
let buffer = '';
|
|
39
|
+
let lines = 0;
|
|
40
|
+
|
|
41
|
+
const consume = (line: string) => {
|
|
42
|
+
if (!line) return;
|
|
43
|
+
// Cheap pre-filter before parsing: a chain line always names its parent.
|
|
44
|
+
if (!line.includes('"parentUuid"')) return;
|
|
45
|
+
try {
|
|
46
|
+
const entry = JSON.parse(line) as { uuid?: unknown; parentUuid?: unknown; isSidechain?: unknown };
|
|
47
|
+
if (typeof entry.uuid !== 'string' || !('parentUuid' in entry)) return;
|
|
48
|
+
if (entry.isSidechain === true) return;
|
|
49
|
+
uuids.add(entry.uuid);
|
|
50
|
+
tip = entry.uuid;
|
|
51
|
+
} catch { /* a torn last line from a crash — ignored */ }
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
for await (const chunk of readFileChunks(file)) {
|
|
56
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
57
|
+
let newline = buffer.indexOf('\n');
|
|
58
|
+
while (newline !== -1) {
|
|
59
|
+
consume(buffer.slice(0, newline));
|
|
60
|
+
buffer = buffer.slice(newline + 1);
|
|
61
|
+
newline = buffer.indexOf('\n');
|
|
62
|
+
if (++lines % 500 === 0) await yieldToEventLoop();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
consume(buffer);
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return { uuids, tip };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface RedundantTranscript {
|
|
73
|
+
entry: TranscriptEntry;
|
|
74
|
+
target: TranscriptEntry;
|
|
75
|
+
resumeAt: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function isSubset(small: Set<string>, large: Set<string>): boolean {
|
|
79
|
+
if (small.size > large.size) return false;
|
|
80
|
+
for (const value of small) if (!large.has(value)) return false;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Within one group of transcripts of the same conversation, which are fully
|
|
86
|
+
* contained in another member. Survivors are the ones nothing contains; when two
|
|
87
|
+
* files hold exactly the same entries, the newer one survives.
|
|
88
|
+
*/
|
|
89
|
+
export function findContained(
|
|
90
|
+
group: { entry: TranscriptEntry; chain: ChainSummary }[]
|
|
91
|
+
): RedundantTranscript[] {
|
|
92
|
+
// Largest first, so each file is matched against the biggest container and
|
|
93
|
+
// chains of containment collapse onto one survivor.
|
|
94
|
+
const ordered = [...group]
|
|
95
|
+
.filter(member => member.chain.tip !== null && member.chain.uuids.size > 0)
|
|
96
|
+
.sort((a, b) =>
|
|
97
|
+
b.chain.uuids.size - a.chain.uuids.size ||
|
|
98
|
+
b.entry.mtimeMs - a.entry.mtimeMs ||
|
|
99
|
+
a.entry.id.localeCompare(b.entry.id)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const redundant: RedundantTranscript[] = [];
|
|
103
|
+
const survivors: typeof ordered = [];
|
|
104
|
+
for (const member of ordered) {
|
|
105
|
+
const container = survivors.find(survivor => isSubset(member.chain.uuids, survivor.chain.uuids));
|
|
106
|
+
if (container) {
|
|
107
|
+
redundant.push({ entry: member.entry, target: container.entry, resumeAt: member.chain.tip! });
|
|
108
|
+
} else {
|
|
109
|
+
survivors.push(member);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return redundant;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Group transcripts by the chat that refers to them. Forks of one conversation
|
|
117
|
+
* are referred to by the same chat (or by chats forked from it, which share
|
|
118
|
+
* their earlier ids), so a group is a connected set over shared owners.
|
|
119
|
+
*/
|
|
120
|
+
export function groupByOwner(
|
|
121
|
+
entries: TranscriptEntry[],
|
|
122
|
+
owners: Map<string, Set<string>>
|
|
123
|
+
): TranscriptEntry[][] {
|
|
124
|
+
const parent = new Map<string, string>();
|
|
125
|
+
const find = (x: string): string => {
|
|
126
|
+
let root = x;
|
|
127
|
+
while (parent.get(root) !== root) root = parent.get(root)!;
|
|
128
|
+
parent.set(x, root);
|
|
129
|
+
return root;
|
|
130
|
+
};
|
|
131
|
+
const union = (a: string, b: string) => {
|
|
132
|
+
const ra = find(a);
|
|
133
|
+
const rb = find(b);
|
|
134
|
+
if (ra !== rb) parent.set(ra, rb);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const owned = entries.filter(entry => owners.has(entry.id));
|
|
138
|
+
for (const entry of owned) {
|
|
139
|
+
const chats = [...owners.get(entry.id)!];
|
|
140
|
+
for (const chat of chats) if (!parent.has(chat)) parent.set(chat, chat);
|
|
141
|
+
for (let i = 1; i < chats.length; i++) union(chats[0], chats[i]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const groups = new Map<string, TranscriptEntry[]>();
|
|
145
|
+
for (const entry of owned) {
|
|
146
|
+
const key = `${entry.projectKey}\u0000${find([...owners.get(entry.id)!][0])}`;
|
|
147
|
+
let list = groups.get(key);
|
|
148
|
+
if (!list) groups.set(key, list = []);
|
|
149
|
+
list.push(entry);
|
|
150
|
+
}
|
|
151
|
+
return [...groups.values()].filter(list => list.length > 1);
|
|
152
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code transcripts: `{CLAUDE_CONFIG_DIR}/projects/<encoded cwd>/<id>.jsonl`.
|
|
3
|
+
*
|
|
4
|
+
* Beside a transcript may sit `<id>/` with the session's tool results and
|
|
5
|
+
* subagent transcripts. Every later fork of the conversation keeps pointing at
|
|
6
|
+
* those files by path, so a side folder outlives its own transcript and goes
|
|
7
|
+
* only when no transcript left in the project folder mentions the id.
|
|
8
|
+
*
|
|
9
|
+
* `memory/` and anything else that is not a session id is the engine's own
|
|
10
|
+
* per-project state and is never listed.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from 'node:fs/promises';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { getEngineUserConfigDir } from '$backend/utils/paths';
|
|
16
|
+
import { measurePath, removePath } from '../fs-size';
|
|
17
|
+
import { findReferencedIds } from './references';
|
|
18
|
+
import { UUID_PATTERN, type TranscriptEntry, type TranscriptRemoval, type TranscriptStore } from './types';
|
|
19
|
+
|
|
20
|
+
export function claudeProjectsRoot(): string {
|
|
21
|
+
return join(getEngineUserConfigDir('claude'), 'projects');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function listDir(dir: string): Promise<import('node:fs').Dirent[]> {
|
|
25
|
+
try {
|
|
26
|
+
return await fs.readdir(dir, { withFileTypes: true });
|
|
27
|
+
} catch {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Transcript files currently in a project folder. */
|
|
33
|
+
async function transcriptFiles(projectDir: string): Promise<string[]> {
|
|
34
|
+
return (await listDir(projectDir))
|
|
35
|
+
.filter(entry => entry.isFile() && entry.name.endsWith('.jsonl'))
|
|
36
|
+
.map(entry => join(projectDir, entry.name));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const claudeTranscripts: TranscriptStore = {
|
|
40
|
+
engine: 'claude-code',
|
|
41
|
+
|
|
42
|
+
roots: () => [claudeProjectsRoot()],
|
|
43
|
+
|
|
44
|
+
async list(signal) {
|
|
45
|
+
const root = claudeProjectsRoot();
|
|
46
|
+
const entries: TranscriptEntry[] = [];
|
|
47
|
+
for (const project of await listDir(root)) {
|
|
48
|
+
if (signal?.aborted) break;
|
|
49
|
+
if (!project.isDirectory()) continue;
|
|
50
|
+
const projectDir = join(root, project.name);
|
|
51
|
+
const children = await listDir(projectDir);
|
|
52
|
+
const transcriptIds = new Set(
|
|
53
|
+
children.filter(c => c.isFile() && c.name.endsWith('.jsonl')).map(c => c.name.slice(0, -6))
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
for (const child of children) {
|
|
57
|
+
if (child.isFile() && child.name.endsWith('.jsonl')) {
|
|
58
|
+
const id = child.name.slice(0, -6);
|
|
59
|
+
if (!UUID_PATTERN.test(id)) continue;
|
|
60
|
+
const file = join(projectDir, child.name);
|
|
61
|
+
const stat = await fs.stat(file).catch(() => null);
|
|
62
|
+
if (!stat) continue;
|
|
63
|
+
const sidecarPath = join(projectDir, id);
|
|
64
|
+
const sidecar = children.some(c => c.isDirectory() && c.name === id)
|
|
65
|
+
? { path: sidecarPath, bytes: (await measurePath(sidecarPath)).bytes }
|
|
66
|
+
: null;
|
|
67
|
+
entries.push({
|
|
68
|
+
engine: 'claude-code',
|
|
69
|
+
id,
|
|
70
|
+
paths: [file],
|
|
71
|
+
bytes: stat.size,
|
|
72
|
+
mtimeMs: stat.mtimeMs,
|
|
73
|
+
projectKey: project.name,
|
|
74
|
+
projectPath: null,
|
|
75
|
+
sidecar
|
|
76
|
+
});
|
|
77
|
+
} else if (child.isDirectory() && UUID_PATTERN.test(child.name) && !transcriptIds.has(child.name)) {
|
|
78
|
+
const dir = join(projectDir, child.name);
|
|
79
|
+
const stat = await fs.stat(dir).catch(() => null);
|
|
80
|
+
entries.push({
|
|
81
|
+
engine: 'claude-code',
|
|
82
|
+
id: child.name,
|
|
83
|
+
paths: [dir],
|
|
84
|
+
bytes: (await measurePath(dir)).bytes,
|
|
85
|
+
mtimeMs: stat?.mtimeMs ?? 0,
|
|
86
|
+
projectKey: project.name,
|
|
87
|
+
projectPath: null,
|
|
88
|
+
sidecarOnly: true
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return entries;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
async exists(id) {
|
|
97
|
+
const root = claudeProjectsRoot();
|
|
98
|
+
for (const project of await listDir(root)) {
|
|
99
|
+
if (!project.isDirectory()) continue;
|
|
100
|
+
try {
|
|
101
|
+
await fs.access(join(root, project.name, `${id}.jsonl`));
|
|
102
|
+
return true;
|
|
103
|
+
} catch { /* not in this folder */ }
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
async remove(entries) {
|
|
109
|
+
const result: TranscriptRemoval = { freedBytes: 0, removed: 0, errors: [] };
|
|
110
|
+
const byProject = new Map<string, TranscriptEntry[]>();
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
if (!entry.projectKey) continue;
|
|
113
|
+
let list = byProject.get(entry.projectKey);
|
|
114
|
+
if (!list) byProject.set(entry.projectKey, list = []);
|
|
115
|
+
list.push(entry);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for (const [projectKey, list] of byProject) {
|
|
119
|
+
const projectDir = join(claudeProjectsRoot(), projectKey);
|
|
120
|
+
const sidecars = new Map<string, string>();
|
|
121
|
+
|
|
122
|
+
for (const entry of list) {
|
|
123
|
+
if (entry.sidecarOnly) {
|
|
124
|
+
sidecars.set(entry.id, entry.paths[0]);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
result.freedBytes += await removePath(entry.paths[0]);
|
|
129
|
+
result.removed++;
|
|
130
|
+
if (entry.sidecar) sidecars.set(entry.id, entry.sidecar.path);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
result.errors.push(`${entry.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (sidecars.size === 0) continue;
|
|
137
|
+
const stillReferenced = await findReferencedIds(await transcriptFiles(projectDir), sidecars.keys());
|
|
138
|
+
for (const [id, dir] of sidecars) {
|
|
139
|
+
if (stillReferenced.has(id)) continue;
|
|
140
|
+
try {
|
|
141
|
+
result.freedBytes += await removePath(dir);
|
|
142
|
+
if (list.some(entry => entry.sidecarOnly && entry.id === id)) result.removed++;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
result.errors.push(`${id}/: ${error instanceof Error ? error.message : String(error)}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// A project folder left with nothing but engine state Claude recreates
|
|
149
|
+
// on demand is removed too, so a deleted project leaves no folder behind.
|
|
150
|
+
const remaining = await listDir(projectDir);
|
|
151
|
+
if (remaining.length === 0) await fs.rmdir(projectDir).catch(() => {});
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
};
|