@myrialabs/clopen 0.0.1
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/.env.example +6 -0
- package/.github/workflows/release.yml +60 -0
- package/.github/workflows/test.yml +40 -0
- package/CONTRIBUTING.md +499 -0
- package/LICENSE +21 -0
- package/README.md +209 -0
- package/backend/index.ts +156 -0
- package/backend/lib/chat/helpers.ts +42 -0
- package/backend/lib/chat/index.ts +2 -0
- package/backend/lib/chat/stream-manager.ts +1126 -0
- package/backend/lib/database/README.md +77 -0
- package/backend/lib/database/index.ts +119 -0
- package/backend/lib/database/migrations/001_create_projects_table.ts +31 -0
- package/backend/lib/database/migrations/002_create_chat_sessions_table.ts +33 -0
- package/backend/lib/database/migrations/003_create_messages_table.ts +32 -0
- package/backend/lib/database/migrations/004_create_prompt_templates_table.ts +34 -0
- package/backend/lib/database/migrations/005_create_settings_table.ts +24 -0
- package/backend/lib/database/migrations/006_add_user_to_messages.ts +58 -0
- package/backend/lib/database/migrations/007_create_stream_states_table.ts +41 -0
- package/backend/lib/database/migrations/008_create_message_snapshots_table.ts +62 -0
- package/backend/lib/database/migrations/009_add_delta_snapshot_fields.ts +41 -0
- package/backend/lib/database/migrations/010_add_soft_delete_and_branch_support.ts +70 -0
- package/backend/lib/database/migrations/011_git_like_commit_graph.ts +156 -0
- package/backend/lib/database/migrations/012_add_file_change_statistics.ts +41 -0
- package/backend/lib/database/migrations/013_checkpoint_tree_state.ts +118 -0
- package/backend/lib/database/migrations/014_add_engine_to_sessions.ts +18 -0
- package/backend/lib/database/migrations/015_add_model_to_sessions.ts +18 -0
- package/backend/lib/database/migrations/016_create_user_projects_table.ts +34 -0
- package/backend/lib/database/migrations/017_add_current_session_to_user_projects.ts +32 -0
- package/backend/lib/database/migrations/018_create_claude_accounts_table.ts +24 -0
- package/backend/lib/database/migrations/019_add_claude_account_to_sessions.ts +18 -0
- package/backend/lib/database/migrations/020_add_snapshot_tree_hash.ts +32 -0
- package/backend/lib/database/migrations/021_drop_prompt_templates_table.ts +33 -0
- package/backend/lib/database/migrations/index.ts +154 -0
- package/backend/lib/database/queries/checkpoint-queries.ts +87 -0
- package/backend/lib/database/queries/engine-queries.ts +75 -0
- package/backend/lib/database/queries/index.ts +9 -0
- package/backend/lib/database/queries/message-queries.ts +472 -0
- package/backend/lib/database/queries/project-queries.ts +117 -0
- package/backend/lib/database/queries/session-queries.ts +271 -0
- package/backend/lib/database/queries/settings-queries.ts +34 -0
- package/backend/lib/database/queries/snapshot-queries.ts +326 -0
- package/backend/lib/database/queries/utils-queries.ts +59 -0
- package/backend/lib/database/seeders/index.ts +13 -0
- package/backend/lib/database/seeders/settings_seeder.ts +84 -0
- package/backend/lib/database/utils/connection.ts +174 -0
- package/backend/lib/database/utils/index.ts +4 -0
- package/backend/lib/database/utils/migration-runner.ts +118 -0
- package/backend/lib/database/utils/seeder-runner.ts +121 -0
- package/backend/lib/engine/adapters/claude/environment.ts +164 -0
- package/backend/lib/engine/adapters/claude/error-handler.ts +60 -0
- package/backend/lib/engine/adapters/claude/index.ts +1 -0
- package/backend/lib/engine/adapters/claude/path-utils.ts +38 -0
- package/backend/lib/engine/adapters/claude/stream.ts +177 -0
- package/backend/lib/engine/adapters/opencode/index.ts +2 -0
- package/backend/lib/engine/adapters/opencode/message-converter.ts +862 -0
- package/backend/lib/engine/adapters/opencode/server.ts +104 -0
- package/backend/lib/engine/adapters/opencode/stream.ts +755 -0
- package/backend/lib/engine/index.ts +196 -0
- package/backend/lib/engine/types.ts +58 -0
- package/backend/lib/files/file-operations.ts +478 -0
- package/backend/lib/files/file-reading.ts +308 -0
- package/backend/lib/files/file-watcher.ts +383 -0
- package/backend/lib/files/path-browsing.ts +382 -0
- package/backend/lib/git/git-executor.ts +88 -0
- package/backend/lib/git/git-parser.ts +411 -0
- package/backend/lib/git/git-service.ts +505 -0
- package/backend/lib/mcp/README.md +1144 -0
- package/backend/lib/mcp/config.ts +316 -0
- package/backend/lib/mcp/index.ts +35 -0
- package/backend/lib/mcp/project-context.ts +236 -0
- package/backend/lib/mcp/servers/browser-automation/actions.ts +156 -0
- package/backend/lib/mcp/servers/browser-automation/browser.ts +419 -0
- package/backend/lib/mcp/servers/browser-automation/index.ts +791 -0
- package/backend/lib/mcp/servers/browser-automation/inspection.ts +501 -0
- package/backend/lib/mcp/servers/helper.ts +143 -0
- package/backend/lib/mcp/servers/index.ts +45 -0
- package/backend/lib/mcp/servers/weather/get-temperature.ts +56 -0
- package/backend/lib/mcp/servers/weather/index.ts +31 -0
- package/backend/lib/mcp/stdio-server.ts +103 -0
- package/backend/lib/mcp/types.ts +65 -0
- package/backend/lib/preview/browser/browser-audio-capture.ts +86 -0
- package/backend/lib/preview/browser/browser-console-manager.ts +263 -0
- package/backend/lib/preview/browser/browser-dialog-handler.ts +222 -0
- package/backend/lib/preview/browser/browser-interaction-handler.ts +421 -0
- package/backend/lib/preview/browser/browser-mcp-control.ts +415 -0
- package/backend/lib/preview/browser/browser-native-ui-handler.ts +512 -0
- package/backend/lib/preview/browser/browser-navigation-tracker.ts +104 -0
- package/backend/lib/preview/browser/browser-pool.ts +357 -0
- package/backend/lib/preview/browser/browser-preview-service.ts +882 -0
- package/backend/lib/preview/browser/browser-tab-manager.ts +935 -0
- package/backend/lib/preview/browser/browser-video-capture.ts +695 -0
- package/backend/lib/preview/browser/scripts/audio-stream.ts +292 -0
- package/backend/lib/preview/browser/scripts/cursor-tracking.ts +85 -0
- package/backend/lib/preview/browser/scripts/video-stream.ts +438 -0
- package/backend/lib/preview/browser/types.ts +359 -0
- package/backend/lib/preview/index.ts +24 -0
- package/backend/lib/project/index.ts +2 -0
- package/backend/lib/project/status-manager.ts +182 -0
- package/backend/lib/shared/index.ts +2 -0
- package/backend/lib/shared/port-utils.ts +25 -0
- package/backend/lib/shared/process-manager.ts +281 -0
- package/backend/lib/snapshot/blob-store.ts +227 -0
- package/backend/lib/snapshot/gitignore.ts +307 -0
- package/backend/lib/snapshot/helpers.ts +397 -0
- package/backend/lib/snapshot/snapshot-service.ts +483 -0
- package/backend/lib/terminal/helpers.ts +14 -0
- package/backend/lib/terminal/index.ts +8 -0
- package/backend/lib/terminal/pty-manager.ts +4 -0
- package/backend/lib/terminal/pty-session-manager.ts +387 -0
- package/backend/lib/terminal/shell-utils.ts +313 -0
- package/backend/lib/terminal/stream-manager.ts +293 -0
- package/backend/lib/tunnel/global-tunnel-manager.ts +243 -0
- package/backend/lib/tunnel/project-tunnel-manager.ts +311 -0
- package/backend/lib/user/helpers.ts +87 -0
- package/backend/lib/utils/ws.ts +944 -0
- package/backend/lib/vite-dev.ts +353 -0
- package/backend/middleware/cors.ts +15 -0
- package/backend/middleware/error-handler.ts +49 -0
- package/backend/middleware/logger.ts +9 -0
- package/backend/types/api.ts +24 -0
- package/backend/ws/README.md +1505 -0
- package/backend/ws/chat/background.ts +198 -0
- package/backend/ws/chat/index.ts +21 -0
- package/backend/ws/chat/stream.ts +707 -0
- package/backend/ws/engine/claude/accounts.ts +401 -0
- package/backend/ws/engine/claude/index.ts +13 -0
- package/backend/ws/engine/claude/status.ts +43 -0
- package/backend/ws/engine/index.ts +14 -0
- package/backend/ws/engine/opencode/index.ts +11 -0
- package/backend/ws/engine/opencode/status.ts +30 -0
- package/backend/ws/engine/utils.ts +36 -0
- package/backend/ws/files/index.ts +30 -0
- package/backend/ws/files/read.ts +189 -0
- package/backend/ws/files/search.ts +453 -0
- package/backend/ws/files/watch.ts +124 -0
- package/backend/ws/files/write.ts +143 -0
- package/backend/ws/git/branch.ts +106 -0
- package/backend/ws/git/commit.ts +39 -0
- package/backend/ws/git/conflict.ts +68 -0
- package/backend/ws/git/diff.ts +69 -0
- package/backend/ws/git/index.ts +24 -0
- package/backend/ws/git/log.ts +41 -0
- package/backend/ws/git/remote.ts +214 -0
- package/backend/ws/git/staging.ts +84 -0
- package/backend/ws/git/status.ts +90 -0
- package/backend/ws/index.ts +69 -0
- package/backend/ws/mcp/index.ts +61 -0
- package/backend/ws/messages/crud.ts +74 -0
- package/backend/ws/messages/index.ts +14 -0
- package/backend/ws/preview/browser/cleanup.ts +129 -0
- package/backend/ws/preview/browser/console.ts +114 -0
- package/backend/ws/preview/browser/interact.ts +513 -0
- package/backend/ws/preview/browser/mcp.ts +129 -0
- package/backend/ws/preview/browser/native-ui.ts +235 -0
- package/backend/ws/preview/browser/stats.ts +55 -0
- package/backend/ws/preview/browser/tab-info.ts +126 -0
- package/backend/ws/preview/browser/tab.ts +166 -0
- package/backend/ws/preview/browser/webcodecs.ts +293 -0
- package/backend/ws/preview/index.ts +146 -0
- package/backend/ws/projects/crud.ts +113 -0
- package/backend/ws/projects/index.ts +25 -0
- package/backend/ws/projects/presence.ts +46 -0
- package/backend/ws/projects/status.ts +116 -0
- package/backend/ws/sessions/crud.ts +327 -0
- package/backend/ws/sessions/index.ts +33 -0
- package/backend/ws/settings/crud.ts +112 -0
- package/backend/ws/settings/index.ts +14 -0
- package/backend/ws/snapshot/index.ts +17 -0
- package/backend/ws/snapshot/restore.ts +173 -0
- package/backend/ws/snapshot/timeline.ts +141 -0
- package/backend/ws/system/index.ts +14 -0
- package/backend/ws/system/operations.ts +49 -0
- package/backend/ws/terminal/index.ts +40 -0
- package/backend/ws/terminal/persistence.ts +153 -0
- package/backend/ws/terminal/session.ts +382 -0
- package/backend/ws/terminal/stream.ts +79 -0
- package/backend/ws/tunnel/index.ts +14 -0
- package/backend/ws/tunnel/operations.ts +91 -0
- package/backend/ws/types.ts +20 -0
- package/backend/ws/user/crud.ts +156 -0
- package/backend/ws/user/index.ts +14 -0
- package/bin/clopen.ts +307 -0
- package/bun.lock +1352 -0
- package/frontend/App.svelte +34 -0
- package/frontend/app.css +313 -0
- package/frontend/lib/app-environment.ts +10 -0
- package/frontend/lib/components/chat/ChatInterface.svelte +407 -0
- package/frontend/lib/components/chat/formatters/ErrorMessage.svelte +57 -0
- package/frontend/lib/components/chat/formatters/MessageFormatter.svelte +224 -0
- package/frontend/lib/components/chat/formatters/TextMessage.svelte +395 -0
- package/frontend/lib/components/chat/formatters/Tools.svelte +70 -0
- package/frontend/lib/components/chat/formatters/index.ts +3 -0
- package/frontend/lib/components/chat/input/ChatInput.svelte +421 -0
- package/frontend/lib/components/chat/input/components/ChatInputActions.svelte +78 -0
- package/frontend/lib/components/chat/input/components/DragDropOverlay.svelte +30 -0
- package/frontend/lib/components/chat/input/components/EditModeIndicator.svelte +33 -0
- package/frontend/lib/components/chat/input/components/EngineModelPicker.svelte +619 -0
- package/frontend/lib/components/chat/input/components/FileAttachmentPreview.svelte +48 -0
- package/frontend/lib/components/chat/input/components/LoadingIndicator.svelte +31 -0
- package/frontend/lib/components/chat/input/composables/use-animations.svelte.ts +201 -0
- package/frontend/lib/components/chat/input/composables/use-chat-actions.svelte.ts +148 -0
- package/frontend/lib/components/chat/input/composables/use-file-handling.svelte.ts +216 -0
- package/frontend/lib/components/chat/input/composables/use-input-state.svelte.ts +357 -0
- package/frontend/lib/components/chat/input/composables/use-textarea-resize.svelte.ts +57 -0
- package/frontend/lib/components/chat/message/ChatMessage.svelte +478 -0
- package/frontend/lib/components/chat/message/ChatMessages.svelte +541 -0
- package/frontend/lib/components/chat/message/DateSeparator.svelte +86 -0
- package/frontend/lib/components/chat/message/MessageBubble.svelte +86 -0
- package/frontend/lib/components/chat/message/MessageHeader.svelte +157 -0
- package/frontend/lib/components/chat/modal/DebugModal.svelte +59 -0
- package/frontend/lib/components/chat/modal/TokenUsageModal.svelte +124 -0
- package/frontend/lib/components/chat/shared/index.ts +2 -0
- package/frontend/lib/components/chat/shared/utils.ts +116 -0
- package/frontend/lib/components/chat/tools/BashOutputTool.svelte +35 -0
- package/frontend/lib/components/chat/tools/BashTool.svelte +46 -0
- package/frontend/lib/components/chat/tools/CustomMcpTool.svelte +139 -0
- package/frontend/lib/components/chat/tools/EditTool.svelte +48 -0
- package/frontend/lib/components/chat/tools/ExitPlanModeTool.svelte +32 -0
- package/frontend/lib/components/chat/tools/GlobTool.svelte +51 -0
- package/frontend/lib/components/chat/tools/GrepTool.svelte +90 -0
- package/frontend/lib/components/chat/tools/KillShellTool.svelte +26 -0
- package/frontend/lib/components/chat/tools/ListMcpResourcesTool.svelte +31 -0
- package/frontend/lib/components/chat/tools/NotebookEditTool.svelte +38 -0
- package/frontend/lib/components/chat/tools/ReadMcpResourceTool.svelte +34 -0
- package/frontend/lib/components/chat/tools/ReadTool.svelte +41 -0
- package/frontend/lib/components/chat/tools/TaskTool.svelte +64 -0
- package/frontend/lib/components/chat/tools/TodoWriteTool.svelte +75 -0
- package/frontend/lib/components/chat/tools/WebFetchTool.svelte +35 -0
- package/frontend/lib/components/chat/tools/WebSearchTool.svelte +84 -0
- package/frontend/lib/components/chat/tools/WriteTool.svelte +33 -0
- package/frontend/lib/components/chat/tools/components/CodeBlock.svelte +79 -0
- package/frontend/lib/components/chat/tools/components/DiffBlock.svelte +408 -0
- package/frontend/lib/components/chat/tools/components/FileHeader.svelte +45 -0
- package/frontend/lib/components/chat/tools/components/InfoLine.svelte +19 -0
- package/frontend/lib/components/chat/tools/components/StatsBadges.svelte +27 -0
- package/frontend/lib/components/chat/tools/components/TerminalCommand.svelte +54 -0
- package/frontend/lib/components/chat/tools/components/index.ts +7 -0
- package/frontend/lib/components/chat/tools/index.ts +26 -0
- package/frontend/lib/components/chat/widgets/FloatingTodoList.svelte +249 -0
- package/frontend/lib/components/chat/widgets/TokenUsage.svelte +78 -0
- package/frontend/lib/components/checkpoint/TimelineModal.svelte +391 -0
- package/frontend/lib/components/checkpoint/timeline/TimelineEdge.svelte +26 -0
- package/frontend/lib/components/checkpoint/timeline/TimelineGraph.svelte +87 -0
- package/frontend/lib/components/checkpoint/timeline/TimelineNode.svelte +108 -0
- package/frontend/lib/components/checkpoint/timeline/TimelineVersionGroup.svelte +59 -0
- package/frontend/lib/components/checkpoint/timeline/animation.ts +168 -0
- package/frontend/lib/components/checkpoint/timeline/config.ts +44 -0
- package/frontend/lib/components/checkpoint/timeline/graph-builder.ts +304 -0
- package/frontend/lib/components/checkpoint/timeline/types.ts +65 -0
- package/frontend/lib/components/checkpoint/timeline/utils.ts +53 -0
- package/frontend/lib/components/common/Alert.svelte +139 -0
- package/frontend/lib/components/common/AvatarBubble.svelte +56 -0
- package/frontend/lib/components/common/Button.svelte +71 -0
- package/frontend/lib/components/common/Card.svelte +102 -0
- package/frontend/lib/components/common/Checkbox.svelte +48 -0
- package/frontend/lib/components/common/Dialog.svelte +249 -0
- package/frontend/lib/components/common/FolderBrowser.svelte +843 -0
- package/frontend/lib/components/common/Icon.svelte +58 -0
- package/frontend/lib/components/common/Input.svelte +72 -0
- package/frontend/lib/components/common/Lightbox.svelte +233 -0
- package/frontend/lib/components/common/LoadingScreen.svelte +52 -0
- package/frontend/lib/components/common/LoadingSpinner.svelte +48 -0
- package/frontend/lib/components/common/Modal.svelte +177 -0
- package/frontend/lib/components/common/ModalProvider.svelte +28 -0
- package/frontend/lib/components/common/ModelSelector.svelte +110 -0
- package/frontend/lib/components/common/MonacoEditor.svelte +569 -0
- package/frontend/lib/components/common/NotificationToast.svelte +113 -0
- package/frontend/lib/components/common/PageTemplate.svelte +76 -0
- package/frontend/lib/components/common/ProjectUserAvatars.svelte +79 -0
- package/frontend/lib/components/common/Select.svelte +98 -0
- package/frontend/lib/components/common/Textarea.svelte +80 -0
- package/frontend/lib/components/common/ThemeToggle.svelte +44 -0
- package/frontend/lib/components/common/lucide-icons.ts +1642 -0
- package/frontend/lib/components/common/material-icons.ts +1082 -0
- package/frontend/lib/components/common/xterm/XTerm.svelte +796 -0
- package/frontend/lib/components/common/xterm/index.ts +16 -0
- package/frontend/lib/components/common/xterm/terminal-config.ts +68 -0
- package/frontend/lib/components/common/xterm/types.ts +31 -0
- package/frontend/lib/components/common/xterm/xterm-service.ts +353 -0
- package/frontend/lib/components/files/FileNode.svelte +384 -0
- package/frontend/lib/components/files/FileTree.svelte +681 -0
- package/frontend/lib/components/files/FileViewer.svelte +728 -0
- package/frontend/lib/components/files/SearchResults.svelte +303 -0
- package/frontend/lib/components/git/BranchManager.svelte +458 -0
- package/frontend/lib/components/git/ChangesSection.svelte +107 -0
- package/frontend/lib/components/git/CommitForm.svelte +76 -0
- package/frontend/lib/components/git/ConflictResolver.svelte +158 -0
- package/frontend/lib/components/git/DiffViewer.svelte +364 -0
- package/frontend/lib/components/git/FileChangeItem.svelte +97 -0
- package/frontend/lib/components/git/GitButton.svelte +33 -0
- package/frontend/lib/components/git/GitLog.svelte +361 -0
- package/frontend/lib/components/git/GitModal.svelte +80 -0
- package/frontend/lib/components/history/HistoryModal.svelte +563 -0
- package/frontend/lib/components/history/HistoryView.svelte +615 -0
- package/frontend/lib/components/index.ts +34 -0
- package/frontend/lib/components/preview/browser/BrowserPreview.svelte +549 -0
- package/frontend/lib/components/preview/browser/components/Canvas.svelte +1058 -0
- package/frontend/lib/components/preview/browser/components/ConsolePanel.svelte +757 -0
- package/frontend/lib/components/preview/browser/components/Container.svelte +450 -0
- package/frontend/lib/components/preview/browser/components/ContextMenu.svelte +236 -0
- package/frontend/lib/components/preview/browser/components/SelectDropdown.svelte +224 -0
- package/frontend/lib/components/preview/browser/components/Toolbar.svelte +339 -0
- package/frontend/lib/components/preview/browser/components/VirtualCursor.svelte +36 -0
- package/frontend/lib/components/preview/browser/core/cleanup.svelte.ts +155 -0
- package/frontend/lib/components/preview/browser/core/coordinator.svelte.ts +837 -0
- package/frontend/lib/components/preview/browser/core/interactions.svelte.ts +113 -0
- package/frontend/lib/components/preview/browser/core/mcp-handlers.svelte.ts +296 -0
- package/frontend/lib/components/preview/browser/core/native-ui-handlers.svelte.ts +391 -0
- package/frontend/lib/components/preview/browser/core/stream-handler.svelte.ts +231 -0
- package/frontend/lib/components/preview/browser/core/tab-manager.svelte.ts +210 -0
- package/frontend/lib/components/preview/browser/core/tab-operations.svelte.ts +239 -0
- package/frontend/lib/components/preview/index.ts +2 -0
- package/frontend/lib/components/settings/SettingsModal.svelte +235 -0
- package/frontend/lib/components/settings/SettingsView.svelte +36 -0
- package/frontend/lib/components/settings/appearance/AppearanceSettings.svelte +51 -0
- package/frontend/lib/components/settings/appearance/LayoutPresetSettings.svelte +160 -0
- package/frontend/lib/components/settings/appearance/LayoutPreview.svelte +76 -0
- package/frontend/lib/components/settings/engines/AIEnginesSettings.svelte +917 -0
- package/frontend/lib/components/settings/general/AdvancedSettings.svelte +187 -0
- package/frontend/lib/components/settings/general/DataManagementSettings.svelte +203 -0
- package/frontend/lib/components/settings/general/GeneralSettings.svelte +10 -0
- package/frontend/lib/components/settings/model/ModelSettings.svelte +357 -0
- package/frontend/lib/components/settings/notifications/NotificationSettings.svelte +205 -0
- package/frontend/lib/components/settings/user/UserSettings.svelte +197 -0
- package/frontend/lib/components/terminal/Terminal.svelte +368 -0
- package/frontend/lib/components/terminal/TerminalTabs.svelte +87 -0
- package/frontend/lib/components/terminal/TerminalView.svelte +55 -0
- package/frontend/lib/components/tunnel/TunnelActive.svelte +142 -0
- package/frontend/lib/components/tunnel/TunnelButton.svelte +54 -0
- package/frontend/lib/components/tunnel/TunnelInactive.svelte +284 -0
- package/frontend/lib/components/tunnel/TunnelModal.svelte +47 -0
- package/frontend/lib/components/tunnel/TunnelQRCode.svelte +49 -0
- package/frontend/lib/components/workspace/DesktopNavigator.svelte +382 -0
- package/frontend/lib/components/workspace/MobileNavigator.svelte +403 -0
- package/frontend/lib/components/workspace/PanelContainer.svelte +100 -0
- package/frontend/lib/components/workspace/PanelHeader.svelte +505 -0
- package/frontend/lib/components/workspace/ViewMenu.svelte +162 -0
- package/frontend/lib/components/workspace/WorkspaceLayout.svelte +169 -0
- package/frontend/lib/components/workspace/layout/DesktopLayout.svelte +15 -0
- package/frontend/lib/components/workspace/layout/MobileLayout.svelte +17 -0
- package/frontend/lib/components/workspace/layout/split-pane/Container.svelte +42 -0
- package/frontend/lib/components/workspace/layout/split-pane/Handle.svelte +85 -0
- package/frontend/lib/components/workspace/layout/split-pane/Layout.svelte +37 -0
- package/frontend/lib/components/workspace/panels/ChatPanel.svelte +274 -0
- package/frontend/lib/components/workspace/panels/FilesPanel.svelte +1261 -0
- package/frontend/lib/components/workspace/panels/GitPanel.svelte +1560 -0
- package/frontend/lib/components/workspace/panels/PreviewPanel.svelte +150 -0
- package/frontend/lib/components/workspace/panels/TerminalPanel.svelte +73 -0
- package/frontend/lib/constants/preview.ts +45 -0
- package/frontend/lib/services/chat/chat.service.ts +704 -0
- package/frontend/lib/services/chat/index.ts +7 -0
- package/frontend/lib/services/notification/global-stream-monitor.ts +86 -0
- package/frontend/lib/services/notification/index.ts +8 -0
- package/frontend/lib/services/notification/push.service.ts +144 -0
- package/frontend/lib/services/notification/sound.service.ts +127 -0
- package/frontend/lib/services/preview/browser/browser-console.service.ts +61 -0
- package/frontend/lib/services/preview/browser/browser-webcodecs.service.ts +1499 -0
- package/frontend/lib/services/preview/browser/mcp-integration.svelte.ts +67 -0
- package/frontend/lib/services/preview/index.ts +23 -0
- package/frontend/lib/services/project/index.ts +8 -0
- package/frontend/lib/services/project/status.service.ts +159 -0
- package/frontend/lib/services/snapshot/snapshot.service.ts +47 -0
- package/frontend/lib/services/terminal/background/index.ts +130 -0
- package/frontend/lib/services/terminal/background/session-restore.ts +274 -0
- package/frontend/lib/services/terminal/background/stream-manager.ts +286 -0
- package/frontend/lib/services/terminal/index.ts +14 -0
- package/frontend/lib/services/terminal/persistence.service.ts +260 -0
- package/frontend/lib/services/terminal/project.service.ts +953 -0
- package/frontend/lib/services/terminal/session.service.ts +364 -0
- package/frontend/lib/services/terminal/terminal.service.ts +369 -0
- package/frontend/lib/stores/core/app.svelte.ts +117 -0
- package/frontend/lib/stores/core/files.svelte.ts +73 -0
- package/frontend/lib/stores/core/presence.svelte.ts +48 -0
- package/frontend/lib/stores/core/projects.svelte.ts +317 -0
- package/frontend/lib/stores/core/sessions.svelte.ts +383 -0
- package/frontend/lib/stores/features/claude-accounts.svelte.ts +58 -0
- package/frontend/lib/stores/features/models.svelte.ts +89 -0
- package/frontend/lib/stores/features/settings.svelte.ts +87 -0
- package/frontend/lib/stores/features/terminal.svelte.ts +701 -0
- package/frontend/lib/stores/features/tunnel.svelte.ts +161 -0
- package/frontend/lib/stores/features/user.svelte.ts +96 -0
- package/frontend/lib/stores/ui/chat-input.svelte.ts +57 -0
- package/frontend/lib/stores/ui/chat-model.svelte.ts +61 -0
- package/frontend/lib/stores/ui/dialog.svelte.ts +59 -0
- package/frontend/lib/stores/ui/edit-mode.svelte.ts +214 -0
- package/frontend/lib/stores/ui/notification.svelte.ts +166 -0
- package/frontend/lib/stores/ui/settings-modal.svelte.ts +88 -0
- package/frontend/lib/stores/ui/theme.svelte.ts +179 -0
- package/frontend/lib/stores/ui/workspace.svelte.ts +754 -0
- package/frontend/lib/types/native-ui.ts +73 -0
- package/frontend/lib/utils/chat/date-separator.ts +39 -0
- package/frontend/lib/utils/chat/message-grouper.ts +219 -0
- package/frontend/lib/utils/chat/message-processor.ts +135 -0
- package/frontend/lib/utils/chat/tool-handler.ts +161 -0
- package/frontend/lib/utils/chat/virtual-scroll.svelte.ts +142 -0
- package/frontend/lib/utils/click-outside.ts +20 -0
- package/frontend/lib/utils/context-manager.ts +257 -0
- package/frontend/lib/utils/file-icon-mappings.ts +769 -0
- package/frontend/lib/utils/folder-icon-mappings.ts +1030 -0
- package/frontend/lib/utils/git-status.ts +68 -0
- package/frontend/lib/utils/platform.ts +113 -0
- package/frontend/lib/utils/port-check.ts +65 -0
- package/frontend/lib/utils/terminalFormatter.ts +207 -0
- package/frontend/lib/utils/theme.ts +6 -0
- package/frontend/lib/utils/tree-visualizer.ts +320 -0
- package/frontend/lib/utils/ws.ts +44 -0
- package/frontend/main.ts +13 -0
- package/index.html +70 -0
- package/package.json +111 -0
- package/scripts/generate-icons.ts +87 -0
- package/scripts/pre-publish-check.sh +142 -0
- package/scripts/setup-hooks.sh +134 -0
- package/scripts/validate-branch-name.sh +47 -0
- package/scripts/validate-commit-msg.sh +42 -0
- package/shared/constants/engines.ts +134 -0
- package/shared/types/database/connection.ts +16 -0
- package/shared/types/database/index.ts +6 -0
- package/shared/types/database/schema.ts +141 -0
- package/shared/types/engine/index.ts +45 -0
- package/shared/types/filesystem/index.ts +22 -0
- package/shared/types/git.ts +171 -0
- package/shared/types/messaging/index.ts +239 -0
- package/shared/types/messaging/tool.ts +526 -0
- package/shared/types/network/api.ts +18 -0
- package/shared/types/network/index.ts +5 -0
- package/shared/types/stores/app.ts +23 -0
- package/shared/types/stores/dialog.ts +21 -0
- package/shared/types/stores/index.ts +3 -0
- package/shared/types/stores/settings.ts +15 -0
- package/shared/types/terminal/index.ts +44 -0
- package/shared/types/ui/components.ts +61 -0
- package/shared/types/ui/icons.ts +23 -0
- package/shared/types/ui/index.ts +22 -0
- package/shared/types/ui/notifications.ts +14 -0
- package/shared/types/ui/theme.ts +12 -0
- package/shared/types/websocket/index.ts +43 -0
- package/shared/types/window.d.ts +13 -0
- package/shared/utils/anonymous-user.ts +168 -0
- package/shared/utils/async.ts +10 -0
- package/shared/utils/diff-calculator.ts +184 -0
- package/shared/utils/file-type-detection.ts +166 -0
- package/shared/utils/logger.ts +158 -0
- package/shared/utils/message-formatter.ts +79 -0
- package/shared/utils/path.ts +47 -0
- package/shared/utils/ws-client.ts +768 -0
- package/shared/utils/ws-server.ts +660 -0
- package/static/audio/notification.ogg +0 -0
- package/static/favicon.svg +8 -0
- package/static/fonts/dm-sans/dm-sans-italic-latin-ext.woff2 +0 -0
- package/static/fonts/dm-sans/dm-sans-italic-latin.woff2 +0 -0
- package/static/fonts/dm-sans/dm-sans-normal-latin-ext.woff2 +0 -0
- package/static/fonts/dm-sans/dm-sans-normal-latin.woff2 +0 -0
- package/static/fonts/dm-sans.css +96 -0
- package/svelte.config.js +20 -0
- package/vite.config.ts +33 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Git-Like Commit Graph System
|
|
3
|
+
* Purpose: Implement parent-child relationships for messages (like git commits)
|
|
4
|
+
*
|
|
5
|
+
* Changes:
|
|
6
|
+
* - Add parent_message_id to messages (commit parent pointer)
|
|
7
|
+
* - Add current_head_message_id to chat_sessions (branch HEAD pointer)
|
|
8
|
+
* - Build parent links from existing messages
|
|
9
|
+
* - Clear old branch data (reset is_deleted, branch_id)
|
|
10
|
+
* - Add branches table for tracking named branches
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
14
|
+
|
|
15
|
+
import { debug } from '$shared/utils/logger';
|
|
16
|
+
export const description = 'Implement git-like commit graph with parent relationships';
|
|
17
|
+
|
|
18
|
+
export const up = (db: DatabaseConnection): void => {
|
|
19
|
+
debug.log('migration', '📋 Implementing git-like commit graph system...');
|
|
20
|
+
|
|
21
|
+
// 1. Add parent_message_id to messages table
|
|
22
|
+
db.exec(`
|
|
23
|
+
ALTER TABLE messages
|
|
24
|
+
ADD COLUMN parent_message_id TEXT
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
// 2. Add current_head_message_id to chat_sessions table
|
|
28
|
+
db.exec(`
|
|
29
|
+
ALTER TABLE chat_sessions
|
|
30
|
+
ADD COLUMN current_head_message_id TEXT
|
|
31
|
+
`);
|
|
32
|
+
|
|
33
|
+
// 3. Create branches table for tracking named branches
|
|
34
|
+
db.exec(`
|
|
35
|
+
CREATE TABLE IF NOT EXISTS branches (
|
|
36
|
+
id TEXT PRIMARY KEY,
|
|
37
|
+
session_id TEXT NOT NULL,
|
|
38
|
+
branch_name TEXT NOT NULL,
|
|
39
|
+
head_message_id TEXT NOT NULL,
|
|
40
|
+
created_at TEXT NOT NULL,
|
|
41
|
+
FOREIGN KEY (session_id) REFERENCES chat_sessions(id) ON DELETE CASCADE,
|
|
42
|
+
FOREIGN KEY (head_message_id) REFERENCES messages(id) ON DELETE CASCADE
|
|
43
|
+
)
|
|
44
|
+
`);
|
|
45
|
+
|
|
46
|
+
// 4. Build parent links for existing messages (by timestamp order per session)
|
|
47
|
+
debug.log('migration', '🔗 Building parent links from existing messages...');
|
|
48
|
+
|
|
49
|
+
const sessions = db.prepare('SELECT DISTINCT session_id FROM messages').all() as { session_id: string }[];
|
|
50
|
+
|
|
51
|
+
for (const { session_id } of sessions) {
|
|
52
|
+
// Get all active messages for this session, ordered by timestamp
|
|
53
|
+
const messages = db.prepare(`
|
|
54
|
+
SELECT id, timestamp
|
|
55
|
+
FROM messages
|
|
56
|
+
WHERE session_id = ? AND (is_deleted IS NULL OR is_deleted = 0)
|
|
57
|
+
ORDER BY timestamp ASC
|
|
58
|
+
`).all(session_id) as { id: string; timestamp: string }[];
|
|
59
|
+
|
|
60
|
+
// Build parent links (each message points to previous message)
|
|
61
|
+
for (let i = 1; i < messages.length; i++) {
|
|
62
|
+
db.prepare(`
|
|
63
|
+
UPDATE messages
|
|
64
|
+
SET parent_message_id = ?
|
|
65
|
+
WHERE id = ?
|
|
66
|
+
`).run(messages[i - 1].id, messages[i].id);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Set session HEAD to last message
|
|
70
|
+
if (messages.length > 0) {
|
|
71
|
+
const lastMessage = messages[messages.length - 1];
|
|
72
|
+
db.prepare(`
|
|
73
|
+
UPDATE chat_sessions
|
|
74
|
+
SET current_head_message_id = ?
|
|
75
|
+
WHERE id = ?
|
|
76
|
+
`).run(lastMessage.id, session_id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
debug.log('migration', ` ✓ Built ${messages.length - 1} parent links for session ${session_id}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 5. Clear old branch data (fresh start)
|
|
83
|
+
debug.log('migration', '🧹 Clearing old branch data...');
|
|
84
|
+
|
|
85
|
+
// Reset all is_deleted to 0 (all messages visible again)
|
|
86
|
+
db.exec(`
|
|
87
|
+
UPDATE messages
|
|
88
|
+
SET is_deleted = 0
|
|
89
|
+
WHERE is_deleted = 1
|
|
90
|
+
`);
|
|
91
|
+
|
|
92
|
+
// Clear all branch_id (will be reassigned on undo)
|
|
93
|
+
db.exec(`
|
|
94
|
+
UPDATE messages
|
|
95
|
+
SET branch_id = NULL
|
|
96
|
+
WHERE branch_id IS NOT NULL
|
|
97
|
+
`);
|
|
98
|
+
|
|
99
|
+
// Clear snapshot soft deletes
|
|
100
|
+
db.exec(`
|
|
101
|
+
UPDATE message_snapshots
|
|
102
|
+
SET is_deleted = 0
|
|
103
|
+
WHERE is_deleted = 1
|
|
104
|
+
`);
|
|
105
|
+
|
|
106
|
+
db.exec(`
|
|
107
|
+
UPDATE message_snapshots
|
|
108
|
+
SET branch_id = NULL
|
|
109
|
+
WHERE branch_id IS NOT NULL
|
|
110
|
+
`);
|
|
111
|
+
|
|
112
|
+
// 6. Create indexes for fast graph traversal
|
|
113
|
+
db.exec(`
|
|
114
|
+
CREATE INDEX idx_messages_parent_id ON messages(parent_message_id)
|
|
115
|
+
`);
|
|
116
|
+
|
|
117
|
+
db.exec(`
|
|
118
|
+
CREATE INDEX idx_messages_session_parent ON messages(session_id, parent_message_id)
|
|
119
|
+
`);
|
|
120
|
+
|
|
121
|
+
db.exec(`
|
|
122
|
+
CREATE INDEX idx_branches_session ON branches(session_id)
|
|
123
|
+
`);
|
|
124
|
+
|
|
125
|
+
db.exec(`
|
|
126
|
+
CREATE INDEX idx_branches_head ON branches(head_message_id)
|
|
127
|
+
`);
|
|
128
|
+
|
|
129
|
+
db.exec(`
|
|
130
|
+
CREATE INDEX idx_chat_sessions_head ON chat_sessions(current_head_message_id)
|
|
131
|
+
`);
|
|
132
|
+
|
|
133
|
+
debug.log('migration', '✅ Git-like commit graph system implemented successfully!');
|
|
134
|
+
debug.log('migration', ' 📊 All existing messages preserved with parent links');
|
|
135
|
+
debug.log('migration', ' 🔄 Old branch data cleared (fresh start)');
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const down = (db: DatabaseConnection): void => {
|
|
139
|
+
debug.log('migration', '🗑️ Removing git-like commit graph system...');
|
|
140
|
+
|
|
141
|
+
// Drop indexes
|
|
142
|
+
db.exec('DROP INDEX IF EXISTS idx_chat_sessions_head');
|
|
143
|
+
db.exec('DROP INDEX IF EXISTS idx_branches_head');
|
|
144
|
+
db.exec('DROP INDEX IF EXISTS idx_branches_session');
|
|
145
|
+
db.exec('DROP INDEX IF EXISTS idx_messages_session_parent');
|
|
146
|
+
db.exec('DROP INDEX IF EXISTS idx_messages_parent_id');
|
|
147
|
+
|
|
148
|
+
// Drop branches table
|
|
149
|
+
db.exec('DROP TABLE IF EXISTS branches');
|
|
150
|
+
|
|
151
|
+
// Note: SQLite doesn't support DROP COLUMN easily
|
|
152
|
+
// Columns parent_message_id and current_head_message_id remain but unused
|
|
153
|
+
debug.warn('migration', '⚠️ Columns parent_message_id and current_head_message_id remain but unused');
|
|
154
|
+
|
|
155
|
+
debug.log('migration', '✅ Git-like commit graph system rollback completed');
|
|
156
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Add file change statistics to message snapshots
|
|
3
|
+
* Purpose: Store git-like file change stats (files changed, insertions, deletions)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
7
|
+
import { debug } from '$shared/utils/logger';
|
|
8
|
+
|
|
9
|
+
export const description = 'Add file change statistics to message snapshots';
|
|
10
|
+
|
|
11
|
+
export const up = (db: DatabaseConnection): void => {
|
|
12
|
+
debug.log('migration', '📊 Adding file change statistics fields...');
|
|
13
|
+
|
|
14
|
+
// Add columns for file change statistics
|
|
15
|
+
db.exec(`
|
|
16
|
+
ALTER TABLE message_snapshots
|
|
17
|
+
ADD COLUMN files_changed INTEGER DEFAULT 0
|
|
18
|
+
`);
|
|
19
|
+
|
|
20
|
+
db.exec(`
|
|
21
|
+
ALTER TABLE message_snapshots
|
|
22
|
+
ADD COLUMN insertions INTEGER DEFAULT 0
|
|
23
|
+
`);
|
|
24
|
+
|
|
25
|
+
db.exec(`
|
|
26
|
+
ALTER TABLE message_snapshots
|
|
27
|
+
ADD COLUMN deletions INTEGER DEFAULT 0
|
|
28
|
+
`);
|
|
29
|
+
|
|
30
|
+
debug.log('migration', '✅ File change statistics fields added');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const down = (db: DatabaseConnection): void => {
|
|
34
|
+
debug.log('migration', '🗑️ Removing file change statistics fields...');
|
|
35
|
+
|
|
36
|
+
// SQLite doesn't support DROP COLUMN easily, so we'd need to recreate table
|
|
37
|
+
// For now, this is a forward-only migration
|
|
38
|
+
debug.warn('migration', '⚠️ Rollback not implemented for file change statistics');
|
|
39
|
+
|
|
40
|
+
debug.log('migration', '✅ File change statistics rollback skipped');
|
|
41
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Checkpoint Tree State
|
|
3
|
+
* Purpose: Track active child per checkpoint for tree display ordering.
|
|
4
|
+
* This replaces the fragile branch_id-based approach with a clean
|
|
5
|
+
* parent-child tracking mechanism.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
9
|
+
import { debug } from '$shared/utils/logger';
|
|
10
|
+
|
|
11
|
+
export const description = 'Add checkpoint tree state for display ordering';
|
|
12
|
+
|
|
13
|
+
export const up = (db: DatabaseConnection): void => {
|
|
14
|
+
debug.log('migration', '📋 Creating checkpoint_tree_state table...');
|
|
15
|
+
|
|
16
|
+
// Track which child checkpoint continues the "main line" (straight)
|
|
17
|
+
// at each branch point. This is used for tree display ordering.
|
|
18
|
+
db.exec(`
|
|
19
|
+
CREATE TABLE IF NOT EXISTS checkpoint_tree_state (
|
|
20
|
+
session_id TEXT NOT NULL,
|
|
21
|
+
parent_checkpoint_id TEXT NOT NULL,
|
|
22
|
+
active_child_id TEXT NOT NULL,
|
|
23
|
+
PRIMARY KEY (session_id, parent_checkpoint_id)
|
|
24
|
+
)
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
db.exec(`
|
|
28
|
+
CREATE INDEX IF NOT EXISTS idx_checkpoint_tree_session
|
|
29
|
+
ON checkpoint_tree_state(session_id)
|
|
30
|
+
`);
|
|
31
|
+
|
|
32
|
+
// Initialize checkpoint_tree_state for existing sessions
|
|
33
|
+
// by analyzing HEAD path relationships
|
|
34
|
+
debug.log('migration', '🔗 Initializing tree state from existing sessions...');
|
|
35
|
+
|
|
36
|
+
const sessions = db.prepare(`
|
|
37
|
+
SELECT id, current_head_message_id FROM chat_sessions
|
|
38
|
+
WHERE current_head_message_id IS NOT NULL
|
|
39
|
+
`).all() as { id: string; current_head_message_id: string }[];
|
|
40
|
+
|
|
41
|
+
for (const session of sessions) {
|
|
42
|
+
try {
|
|
43
|
+
// Walk HEAD path from head to root
|
|
44
|
+
const path: string[] = [];
|
|
45
|
+
let currentId: string | null = session.current_head_message_id;
|
|
46
|
+
|
|
47
|
+
while (currentId) {
|
|
48
|
+
path.unshift(currentId);
|
|
49
|
+
const msg = db.prepare(`
|
|
50
|
+
SELECT parent_message_id FROM messages WHERE id = ?
|
|
51
|
+
`).get(currentId) as { parent_message_id: string | null } | null;
|
|
52
|
+
if (!msg) break;
|
|
53
|
+
currentId = msg.parent_message_id || null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Find checkpoint messages (user messages with text, not tool confirmations)
|
|
57
|
+
const checkpointsOnPath: string[] = [];
|
|
58
|
+
for (const msgId of path) {
|
|
59
|
+
const msg = db.prepare(`
|
|
60
|
+
SELECT sdk_message FROM messages WHERE id = ?
|
|
61
|
+
`).get(msgId) as { sdk_message: string } | null;
|
|
62
|
+
if (!msg) continue;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const sdk = JSON.parse(msg.sdk_message);
|
|
66
|
+
if (sdk.type !== 'user') continue;
|
|
67
|
+
|
|
68
|
+
// Check if it's a tool confirmation (not a real user message)
|
|
69
|
+
const content = sdk.message?.content;
|
|
70
|
+
if (Array.isArray(content) && content.some((b: any) => b.type === 'tool_result')) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if it has text
|
|
75
|
+
let hasText = false;
|
|
76
|
+
if (typeof content === 'string' && content.trim()) {
|
|
77
|
+
hasText = true;
|
|
78
|
+
} else if (Array.isArray(content)) {
|
|
79
|
+
hasText = content.some((b: any) => typeof b === 'object' && 'text' in b && b.text?.trim());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (hasText) {
|
|
83
|
+
checkpointsOnPath.push(msgId);
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
// Skip unparseable messages
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Set active child for consecutive checkpoints on the path
|
|
91
|
+
for (let i = 0; i < checkpointsOnPath.length - 1; i++) {
|
|
92
|
+
const parentCp = checkpointsOnPath[i];
|
|
93
|
+
const childCp = checkpointsOnPath[i + 1];
|
|
94
|
+
|
|
95
|
+
db.prepare(`
|
|
96
|
+
INSERT OR REPLACE INTO checkpoint_tree_state
|
|
97
|
+
(session_id, parent_checkpoint_id, active_child_id)
|
|
98
|
+
VALUES (?, ?, ?)
|
|
99
|
+
`).run(session.id, parentCp, childCp);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (checkpointsOnPath.length > 1) {
|
|
103
|
+
debug.log('migration', ` ✓ Session ${session.id}: ${checkpointsOnPath.length - 1} active child links`);
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
debug.warn('migration', ` ⚠ Could not process session ${session.id}: ${err}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
debug.log('migration', '✅ Checkpoint tree state created');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const down = (db: DatabaseConnection): void => {
|
|
114
|
+
debug.log('migration', '🗑️ Removing checkpoint tree state...');
|
|
115
|
+
db.exec('DROP INDEX IF EXISTS idx_checkpoint_tree_session');
|
|
116
|
+
db.exec('DROP TABLE IF EXISTS checkpoint_tree_state');
|
|
117
|
+
debug.log('migration', '✅ Checkpoint tree state removed');
|
|
118
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
|
|
3
|
+
import { debug } from '$shared/utils/logger';
|
|
4
|
+
export const description = 'Add engine column to chat_sessions table for multi-engine support';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', '🔧 Adding engine column to chat_sessions...');
|
|
8
|
+
|
|
9
|
+
db.exec(`
|
|
10
|
+
ALTER TABLE chat_sessions ADD COLUMN engine TEXT DEFAULT 'claude-code'
|
|
11
|
+
`);
|
|
12
|
+
|
|
13
|
+
debug.log('migration', '✅ Engine column added to chat_sessions');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const down = (db: DatabaseConnection): void => {
|
|
17
|
+
debug.log('migration', '🗑️ SQLite does not support DROP COLUMN directly, skipping...');
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
|
|
3
|
+
import { debug } from '$shared/utils/logger';
|
|
4
|
+
export const description = 'Add model column to chat_sessions table for model persistence';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', 'Adding model column to chat_sessions...');
|
|
8
|
+
|
|
9
|
+
db.exec(`
|
|
10
|
+
ALTER TABLE chat_sessions ADD COLUMN model TEXT DEFAULT NULL
|
|
11
|
+
`);
|
|
12
|
+
|
|
13
|
+
debug.log('migration', 'Model column added to chat_sessions');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const down = (db: DatabaseConnection): void => {
|
|
17
|
+
debug.log('migration', 'SQLite does not support DROP COLUMN directly, skipping...');
|
|
18
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Create user_projects table for per-user project lists';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', 'Creating user_projects table...');
|
|
8
|
+
|
|
9
|
+
db.exec(`
|
|
10
|
+
CREATE TABLE IF NOT EXISTS user_projects (
|
|
11
|
+
user_id TEXT NOT NULL,
|
|
12
|
+
project_id TEXT NOT NULL,
|
|
13
|
+
joined_at TEXT NOT NULL,
|
|
14
|
+
PRIMARY KEY (user_id, project_id),
|
|
15
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
|
|
16
|
+
)
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
db.exec(`
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_user_projects_user_id ON user_projects(user_id)
|
|
21
|
+
`);
|
|
22
|
+
|
|
23
|
+
db.exec(`
|
|
24
|
+
CREATE INDEX IF NOT EXISTS idx_user_projects_project_id ON user_projects(project_id)
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
debug.log('migration', 'user_projects table created');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const down = (db: DatabaseConnection): void => {
|
|
31
|
+
debug.log('migration', 'Dropping user_projects table...');
|
|
32
|
+
db.exec('DROP TABLE IF EXISTS user_projects');
|
|
33
|
+
debug.log('migration', 'user_projects table dropped');
|
|
34
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Add current_session_id to user_projects for session restore on refresh';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', 'Adding current_session_id to user_projects...');
|
|
8
|
+
db.exec(`ALTER TABLE user_projects ADD COLUMN current_session_id TEXT`);
|
|
9
|
+
debug.log('migration', 'current_session_id column added');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const down = (db: DatabaseConnection): void => {
|
|
13
|
+
debug.log('migration', 'Removing current_session_id from user_projects...');
|
|
14
|
+
db.exec(`
|
|
15
|
+
CREATE TABLE user_projects_backup AS SELECT user_id, project_id, joined_at FROM user_projects
|
|
16
|
+
`);
|
|
17
|
+
db.exec(`DROP TABLE user_projects`);
|
|
18
|
+
db.exec(`
|
|
19
|
+
CREATE TABLE user_projects (
|
|
20
|
+
user_id TEXT NOT NULL,
|
|
21
|
+
project_id TEXT NOT NULL,
|
|
22
|
+
joined_at TEXT NOT NULL,
|
|
23
|
+
PRIMARY KEY (user_id, project_id),
|
|
24
|
+
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
|
|
25
|
+
)
|
|
26
|
+
`);
|
|
27
|
+
db.exec(`INSERT INTO user_projects SELECT * FROM user_projects_backup`);
|
|
28
|
+
db.exec(`DROP TABLE user_projects_backup`);
|
|
29
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_user_projects_user_id ON user_projects(user_id)`);
|
|
30
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_user_projects_project_id ON user_projects(project_id)`);
|
|
31
|
+
debug.log('migration', 'current_session_id column removed');
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Create claude_accounts table for multi-account management';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', 'Creating claude_accounts table...');
|
|
8
|
+
db.exec(`
|
|
9
|
+
CREATE TABLE IF NOT EXISTS claude_accounts (
|
|
10
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
11
|
+
name TEXT NOT NULL,
|
|
12
|
+
oauth_token TEXT NOT NULL,
|
|
13
|
+
is_active INTEGER NOT NULL DEFAULT 0,
|
|
14
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
15
|
+
)
|
|
16
|
+
`);
|
|
17
|
+
debug.log('migration', 'claude_accounts table created');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const down = (db: DatabaseConnection): void => {
|
|
21
|
+
debug.log('migration', 'Dropping claude_accounts table...');
|
|
22
|
+
db.exec('DROP TABLE IF EXISTS claude_accounts');
|
|
23
|
+
debug.log('migration', 'claude_accounts table dropped');
|
|
24
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
|
|
3
|
+
import { debug } from '$shared/utils/logger';
|
|
4
|
+
export const description = 'Add claude_account_id column to chat_sessions for per-session account selection';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', 'Adding claude_account_id column to chat_sessions...');
|
|
8
|
+
|
|
9
|
+
db.exec(`
|
|
10
|
+
ALTER TABLE chat_sessions ADD COLUMN claude_account_id INTEGER DEFAULT NULL
|
|
11
|
+
`);
|
|
12
|
+
|
|
13
|
+
debug.log('migration', 'claude_account_id column added to chat_sessions');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const down = (db: DatabaseConnection): void => {
|
|
17
|
+
debug.log('migration', 'SQLite does not support DROP COLUMN directly, skipping...');
|
|
18
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Add tree_hash column to message_snapshots
|
|
3
|
+
* Purpose: Support blob-store format where file contents are stored externally
|
|
4
|
+
* in ~/.clopen/snapshots/ instead of in the database.
|
|
5
|
+
*
|
|
6
|
+
* When tree_hash is not null, the snapshot uses the new blob-store format:
|
|
7
|
+
* - files_snapshot = '{}' (empty, content is in blob store)
|
|
8
|
+
* - delta_changes contains hash references instead of full file content
|
|
9
|
+
* - Tree file at ~/.clopen/snapshots/trees/{snapshotId}.json maps filepath -> blob hash
|
|
10
|
+
* - Blobs at ~/.clopen/snapshots/blobs/{hash[0:2]}/{hash}.gz contain compressed file content
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
14
|
+
import { debug } from '$shared/utils/logger';
|
|
15
|
+
|
|
16
|
+
export const description = 'Add tree_hash for blob-store snapshot format';
|
|
17
|
+
|
|
18
|
+
export const up = (db: DatabaseConnection): void => {
|
|
19
|
+
debug.log('migration', 'Adding tree_hash column to message_snapshots...');
|
|
20
|
+
|
|
21
|
+
db.exec(`
|
|
22
|
+
ALTER TABLE message_snapshots
|
|
23
|
+
ADD COLUMN tree_hash TEXT
|
|
24
|
+
`);
|
|
25
|
+
|
|
26
|
+
debug.log('migration', 'tree_hash column added');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const down = (db: DatabaseConnection): void => {
|
|
30
|
+
debug.log('migration', 'Removing tree_hash column...');
|
|
31
|
+
debug.warn('migration', 'Rollback not implemented for tree_hash (SQLite limitation)');
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
|
|
3
|
+
import { debug } from '$shared/utils/logger';
|
|
4
|
+
export const description = 'Drop prompt_templates table - templates feature removed';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', '🗑️ Dropping prompt_templates table...');
|
|
8
|
+
db.exec('DROP TABLE IF EXISTS prompt_templates');
|
|
9
|
+
debug.log('migration', '✅ Prompt templates table dropped');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const down = (db: DatabaseConnection): void => {
|
|
13
|
+
debug.log('migration', '📋 Recreating prompt_templates table...');
|
|
14
|
+
|
|
15
|
+
db.exec(`
|
|
16
|
+
CREATE TABLE IF NOT EXISTS prompt_templates (
|
|
17
|
+
id TEXT PRIMARY KEY,
|
|
18
|
+
name TEXT NOT NULL,
|
|
19
|
+
category TEXT NOT NULL,
|
|
20
|
+
content TEXT NOT NULL,
|
|
21
|
+
description TEXT NOT NULL,
|
|
22
|
+
created_at TEXT NOT NULL,
|
|
23
|
+
tags TEXT,
|
|
24
|
+
usage_count INTEGER DEFAULT 0
|
|
25
|
+
)
|
|
26
|
+
`);
|
|
27
|
+
|
|
28
|
+
db.exec(`
|
|
29
|
+
CREATE INDEX IF NOT EXISTS idx_prompt_templates_category ON prompt_templates(category)
|
|
30
|
+
`);
|
|
31
|
+
|
|
32
|
+
debug.log('migration', '✅ Prompt templates table recreated');
|
|
33
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Import all migrations
|
|
2
|
+
import * as migration001 from './001_create_projects_table';
|
|
3
|
+
import * as migration002 from './002_create_chat_sessions_table';
|
|
4
|
+
import * as migration003 from './003_create_messages_table';
|
|
5
|
+
import * as migration004 from './004_create_prompt_templates_table';
|
|
6
|
+
import * as migration005 from './005_create_settings_table';
|
|
7
|
+
import * as migration006 from './006_add_user_to_messages';
|
|
8
|
+
import * as migration007 from './007_create_stream_states_table';
|
|
9
|
+
import * as migration008 from './008_create_message_snapshots_table';
|
|
10
|
+
import * as migration009 from './009_add_delta_snapshot_fields';
|
|
11
|
+
import * as migration010 from './010_add_soft_delete_and_branch_support';
|
|
12
|
+
import * as migration011 from './011_git_like_commit_graph';
|
|
13
|
+
import * as migration012 from './012_add_file_change_statistics';
|
|
14
|
+
import * as migration013 from './013_checkpoint_tree_state';
|
|
15
|
+
import * as migration014 from './014_add_engine_to_sessions';
|
|
16
|
+
import * as migration015 from './015_add_model_to_sessions';
|
|
17
|
+
import * as migration016 from './016_create_user_projects_table';
|
|
18
|
+
import * as migration017 from './017_add_current_session_to_user_projects';
|
|
19
|
+
import * as migration018 from './018_create_claude_accounts_table';
|
|
20
|
+
import * as migration019 from './019_add_claude_account_to_sessions';
|
|
21
|
+
import * as migration020 from './020_add_snapshot_tree_hash';
|
|
22
|
+
import * as migration021 from './021_drop_prompt_templates_table';
|
|
23
|
+
|
|
24
|
+
// Export all migrations in order
|
|
25
|
+
export const migrations = [
|
|
26
|
+
{
|
|
27
|
+
id: '001',
|
|
28
|
+
description: migration001.description,
|
|
29
|
+
up: migration001.up,
|
|
30
|
+
down: migration001.down
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: '002',
|
|
34
|
+
description: migration002.description,
|
|
35
|
+
up: migration002.up,
|
|
36
|
+
down: migration002.down
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: '003',
|
|
40
|
+
description: migration003.description,
|
|
41
|
+
up: migration003.up,
|
|
42
|
+
down: migration003.down
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: '004',
|
|
46
|
+
description: migration004.description,
|
|
47
|
+
up: migration004.up,
|
|
48
|
+
down: migration004.down
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: '005',
|
|
52
|
+
description: migration005.description,
|
|
53
|
+
up: migration005.up,
|
|
54
|
+
down: migration005.down
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: '006',
|
|
58
|
+
description: migration006.description,
|
|
59
|
+
up: migration006.up,
|
|
60
|
+
down: migration006.down
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: '007',
|
|
64
|
+
description: migration007.description,
|
|
65
|
+
up: migration007.up,
|
|
66
|
+
down: migration007.down
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: '008',
|
|
70
|
+
description: migration008.description,
|
|
71
|
+
up: migration008.up,
|
|
72
|
+
down: migration008.down
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: '009',
|
|
76
|
+
description: migration009.description,
|
|
77
|
+
up: migration009.up,
|
|
78
|
+
down: migration009.down
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: '010',
|
|
82
|
+
description: migration010.description,
|
|
83
|
+
up: migration010.up,
|
|
84
|
+
down: migration010.down
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: '011',
|
|
88
|
+
description: migration011.description,
|
|
89
|
+
up: migration011.up,
|
|
90
|
+
down: migration011.down
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: '012',
|
|
94
|
+
description: migration012.description,
|
|
95
|
+
up: migration012.up,
|
|
96
|
+
down: migration012.down
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: '013',
|
|
100
|
+
description: migration013.description,
|
|
101
|
+
up: migration013.up,
|
|
102
|
+
down: migration013.down
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: '014',
|
|
106
|
+
description: migration014.description,
|
|
107
|
+
up: migration014.up,
|
|
108
|
+
down: migration014.down
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: '015',
|
|
112
|
+
description: migration015.description,
|
|
113
|
+
up: migration015.up,
|
|
114
|
+
down: migration015.down
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: '016',
|
|
118
|
+
description: migration016.description,
|
|
119
|
+
up: migration016.up,
|
|
120
|
+
down: migration016.down
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: '017',
|
|
124
|
+
description: migration017.description,
|
|
125
|
+
up: migration017.up,
|
|
126
|
+
down: migration017.down
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: '018',
|
|
130
|
+
description: migration018.description,
|
|
131
|
+
up: migration018.up,
|
|
132
|
+
down: migration018.down
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: '019',
|
|
136
|
+
description: migration019.description,
|
|
137
|
+
up: migration019.up,
|
|
138
|
+
down: migration019.down
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: '020',
|
|
142
|
+
description: migration020.description,
|
|
143
|
+
up: migration020.up,
|
|
144
|
+
down: migration020.down
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: '021',
|
|
148
|
+
description: migration021.description,
|
|
149
|
+
up: migration021.up,
|
|
150
|
+
down: migration021.down
|
|
151
|
+
}
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
export default migrations;
|