@kabmo-labs/kabmo 0.27.0 → 0.29.0
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/bunfig.toml +6 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.js +530 -493
- package/dist/client/static/js/{index-e3qh2yps.js → index-43z47ngg.js} +1178 -1034
- package/dist/client/static/js/index-naa91727.css +1 -0
- package/dist/client/static/{manifest-q6h8k9e0.webmanifest → manifest-vdvdqpre.webmanifest} +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -17
- package/marketplace/plugins/command-runner/settings-schema.json +14 -0
- package/marketplace/plugins/git-forge/README.md +17 -7
- package/marketplace/plugins/git-forge/package.json +4 -30
- package/marketplace/plugins/git-forge/panel.css +16 -0
- package/marketplace/plugins/git-forge/settings-schema.json +27 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +35 -22
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +20 -24
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +16 -7
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +31 -26
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +18 -2
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +160 -96
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +60 -44
- package/marketplace/plugins/git-forge/src/panel/List.tsx +150 -22
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +11 -5
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +17 -15
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +84 -61
- package/marketplace/plugins/git-forge/src/panel/format.test.ts +99 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +59 -16
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +109 -5
- package/marketplace/plugins/git-forge/src/panel/index.tsx +37 -4
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +17 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +31 -0
- package/marketplace/plugins/session-info/package.json +2 -10
- package/marketplace/plugins/session-info/settings-schema.json +8 -0
- package/marketplace/plugins/stats/README.md +17 -5
- package/marketplace/plugins/stats/package.json +3 -23
- package/marketplace/plugins/stats/settings-schema.json +20 -0
- package/marketplace/plugins/stats/src/app.tsx +1 -1
- package/marketplace/plugins/stats/src/groups.test.ts +46 -1
- package/marketplace/plugins/stats/src/groups.ts +22 -11
- package/marketplace/plugins/stats/src/harness-leases.test.ts +84 -0
- package/marketplace/plugins/stats/src/harness-leases.ts +132 -0
- package/marketplace/plugins/stats/src/labels.test.ts +54 -1
- package/marketplace/plugins/stats/src/labels.ts +33 -7
- package/marketplace/plugins/stats/src/sampler.test.ts +61 -0
- package/marketplace/plugins/stats/src/sampler.ts +39 -5
- package/marketplace/plugins/stats/src/snapshot.ts +6 -0
- package/package.json +4 -3
- package/public/manifest.webmanifest +1 -0
- package/src/client/components/common/ComposerTextarea.test.tsx +109 -0
- package/src/client/components/common/ComposerTextarea.tsx +6 -0
- package/src/client/components/common/ReloadPageButton.test.tsx +14 -0
- package/src/client/components/common/ReloadPageButton.tsx +11 -2
- package/src/client/components/common/diagram-viewer/read-block.test.ts +71 -0
- package/src/client/components/common/diagram-viewer/read-block.ts +40 -16
- package/src/client/components/common/file-icon/index.tsx +7 -1
- package/src/client/components/common/harness-glyph/brands.ts +7 -1
- package/src/client/components/common/harness-glyph/index.tsx +18 -1
- package/src/client/components/common/image-viewer/index.tsx +37 -165
- package/src/client/components/common/picker-search/index.tsx +70 -0
- package/src/client/components/common/search-select/index.tsx +2 -7
- package/src/client/components/common/session-actions-menu/index.test.tsx +106 -0
- package/src/client/components/common/session-actions-menu/index.tsx +43 -1
- package/src/client/components/common/session-row/TrailingSlot.tsx +9 -4
- package/src/client/components/common/session-row/index.tsx +4 -0
- package/src/client/components/common/session-row/session-row.test.tsx +6 -0
- package/src/client/components/common/zoom-pan-stage/index.tsx +258 -0
- package/src/client/components/common/zoom-pan-stage/zoom-pan-stage.test.tsx +87 -0
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +2 -1
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +9 -1
- package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +7 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +4 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +12 -1
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.test.tsx +82 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +23 -3
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +1 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +202 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +80 -19
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +29 -7
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +3 -0
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +8 -0
- package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +181 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +41 -86
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +6 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +9 -1
- package/src/client/components/settings/Modal.tsx +6 -2
- package/src/client/components/settings/Sidebar.tsx +32 -7
- package/src/client/components/settings/categories/HarnessSettings.tsx +15 -9
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +40 -15
- package/src/client/components/settings/categories/NotificationSettings.tsx +142 -64
- package/src/client/components/settings/categories/PanelPluginSettings.tsx +3 -3
- package/src/client/components/settings/categories/PluginSettings.tsx +1 -1
- package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +3 -6
- package/src/client/components/settings/categories/harness-settings/CustomHarnessForm.tsx +186 -0
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +36 -0
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +11 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +1 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +15 -1
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -3
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.test.tsx +165 -0
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.tsx +260 -0
- package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +18 -4
- package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +64 -61
- package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +15 -4
- package/src/client/components/settings/groups.test.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +24 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +8 -4
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +34 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -2
- package/src/client/components/workspace/chat-timeline/IrcNotice.test.tsx +55 -0
- package/src/client/components/workspace/chat-timeline/IrcNotice.tsx +71 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.fork.test.ts +80 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +13 -4
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +8 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +9 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +19 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +32 -3
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.search.test.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +53 -33
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +5 -5
- package/src/client/components/workspace/chat-timeline/index.tsx +11 -5
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +1 -9
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +129 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +30 -12
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +47 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +55 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
- package/src/client/components/workspace/editor/FilePane.tsx +41 -4
- package/src/client/components/workspace/editor/Notices.tsx +2 -2
- package/src/client/components/workspace/editor/Pane.tsx +2 -2
- package/src/client/components/workspace/editor/Toolbar.tsx +20 -10
- package/src/client/components/workspace/editor/index.tsx +6 -10
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +5 -3
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +26 -14
- package/src/client/components/workspace/editor/viewers/CsvGrid.tsx +52 -5
- package/src/client/components/workspace/editor/viewers/DataGrid.tsx +227 -41
- package/src/client/components/workspace/editor/viewers/DrawioView.tsx +93 -0
- package/src/client/components/workspace/editor/viewers/GridRow.tsx +91 -0
- package/src/client/components/workspace/editor/viewers/GridToolbar.tsx +53 -0
- package/src/client/components/workspace/editor/viewers/SheetView.tsx +152 -57
- package/src/client/components/workspace/editor/viewers/dispatch.tsx +42 -9
- package/src/client/components/workspace/editor/viewers/drawio-pages.test.ts +80 -0
- package/src/client/components/workspace/editor/viewers/drawio-pages.ts +63 -0
- package/src/client/components/workspace/editor/viewers/grid.test.ts +296 -0
- package/src/client/components/workspace/editor/viewers/use-cell-edit.ts +64 -0
- package/src/client/components/workspace/editor/viewers/use-grid-interaction.ts +216 -0
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +47 -2
- package/src/client/components/workspace/editor/viewers/workbook.ts +149 -0
- package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +262 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +30 -6
- package/src/client/components/workspace/file-explorer/Modals.tsx +8 -3
- package/src/client/components/workspace/file-explorer/RootOverlays.tsx +60 -0
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +6 -2
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +39 -49
- package/src/client/components/workspace/file-explorer/TreeItemModals.tsx +80 -0
- package/src/client/components/workspace/file-explorer/index.tsx +53 -29
- package/src/client/components/workspace/file-explorer/selection.test.tsx +109 -0
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +9 -1
- package/src/client/components/workspace/terminal-panel/focus.test.ts +70 -0
- package/src/client/components/workspace/terminal-panel/focus.ts +46 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +14 -1
- package/src/client/components/workspace/terminal-panel/mount.ts +17 -9
- package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +158 -0
- package/src/client/components/workspace/terminal-panel/scroll-hold.ts +136 -0
- package/src/client/data/settings/omp-schema.json +169 -22
- package/src/client/glass.css +39 -14
- package/src/client/glass.test.ts +37 -0
- package/src/client/hooks/chat/composer/history.test.ts +267 -0
- package/src/client/hooks/chat/composer/history.ts +146 -0
- package/src/client/hooks/chat/composer/use-draft.ts +45 -1
- package/src/client/hooks/chat/omp/pending-sessions.waiting.test.ts +11 -10
- package/src/client/hooks/chat/omp/pending-waiting.ts +15 -7
- package/src/client/hooks/chat/omp/prompt-send.test.ts +11 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +3 -0
- package/src/client/hooks/chat/timeline/actions.ts +4 -4
- package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
- package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
- package/src/client/hooks/chat/timeline/composer-modes.ts +13 -2
- package/src/client/hooks/chat/timeline/fork-open.ts +52 -0
- package/src/client/hooks/chat/timeline/index.ts +5 -2
- package/src/client/hooks/chat/timeline/mode-availability.ts +7 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
- package/src/client/hooks/chat/timeline/modes-hydrate.ts +93 -0
- package/src/client/hooks/chat/timeline/modes.ts +32 -52
- package/src/client/hooks/chat/timeline/new-chat-open.ts +7 -6
- package/src/client/hooks/chat/timeline/new-chat.ts +10 -1
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +4 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.test.ts +136 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.ts +69 -0
- package/src/client/hooks/chat/timeline/pending-warmup.test.ts +147 -0
- package/src/client/hooks/chat/timeline/pending-warmup.ts +62 -0
- package/src/client/hooks/chat/timeline/run-identity.test.ts +12 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +4 -1
- package/src/client/hooks/chat/timeline/send-props.ts +2 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test.ts +1 -0
- package/src/client/hooks/chat/timeline/session-harness.ts +4 -0
- package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
- package/src/client/hooks/chat/timeline/use-fork-session.ts +9 -22
- package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
- package/src/client/hooks/chat/waiting/cancel.ts +13 -6
- package/src/client/hooks/chat/waiting/choice.ts +13 -16
- package/src/client/hooks/chat/waiting/composer-wait.ts +70 -0
- package/src/client/hooks/chat/waiting/dispatch.ts +48 -28
- package/src/client/hooks/chat/waiting/held.ts +37 -13
- package/src/client/hooks/chat/waiting/hold.test.ts +22 -0
- package/src/client/hooks/chat/waiting/hold.ts +20 -11
- package/src/client/hooks/chat/waiting/restore.test.ts +69 -0
- package/src/client/hooks/chat/waiting/restore.ts +34 -0
- package/src/client/hooks/chat/waiting/store.ts +9 -3
- package/src/client/hooks/editor/file-editor-types.ts +36 -12
- package/src/client/hooks/editor/save-bytes.ts +79 -0
- package/src/client/hooks/editor/save-file.test.ts +1 -1
- package/src/client/hooks/editor/save-file.ts +35 -8
- package/src/client/hooks/editor/target-key.ts +17 -0
- package/src/client/hooks/editor/use-disk-digest.test.ts +82 -0
- package/src/client/hooks/editor/use-disk-digest.ts +164 -0
- package/src/client/hooks/editor/use-disk-sync.ts +212 -0
- package/src/client/hooks/editor/use-file-cache.ts +113 -0
- package/src/client/hooks/editor/use-file-editor.test.ts +120 -0
- package/src/client/hooks/editor/use-file-editor.ts +143 -57
- package/src/client/hooks/editor/use-file-read.ts +45 -12
- package/src/client/hooks/editor/use-file-writes.ts +4 -4
- package/src/client/hooks/editor/use-grid-selection.ts +160 -0
- package/src/client/hooks/models/harness-catalog.ts +15 -0
- package/src/client/hooks/models/use-harness-update.test.ts +35 -2
- package/src/client/hooks/models/use-harness-update.ts +49 -10
- package/src/client/hooks/ui/notifications.ts +17 -8
- package/src/client/hooks/workspace/diff-file.test.ts +72 -0
- package/src/client/hooks/workspace/diff-file.ts +12 -6
- package/src/client/hooks/workspace/file-archive.ts +220 -0
- package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
- package/src/client/hooks/workspace/file-clipboard.ts +37 -26
- package/src/client/hooks/workspace/file-selection.test.ts +67 -0
- package/src/client/hooks/workspace/file-selection.ts +156 -0
- package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
- package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
- package/src/client/hooks/workspace/panel-registry.ts +1 -1
- package/src/client/hooks/workspace/scheduled-tasks.ts +26 -11
- package/src/client/lib/editor/workbook-drafts.ts +42 -0
- package/src/client/lib/launch/file-handlers.ts +2 -2
- package/src/client/lib/notifications/os.test.ts +1 -30
- package/src/client/lib/notifications/os.ts +0 -15
- package/src/client/lib/notifications/platform.test.ts +68 -0
- package/src/client/lib/notifications/platform.ts +36 -0
- package/src/client/lib/scrollbar-activity.test.ts +21 -88
- package/src/client/lib/scrollbar-activity.ts +71 -73
- package/src/client/lib/scrollbar-events.ts +143 -0
- package/src/client/lib/scrollbar-input.test.ts +126 -0
- package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
- package/src/client/tailwind.css +32 -1
- package/src/server/db.server.test.ts +50 -1
- package/src/server/db.server.ts +36 -3
- package/src/server/index.ts +7 -0
- package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
- package/src/server/lib/chat/prompt-history.server.ts +65 -0
- package/src/server/lib/chat/schema.server.ts +35 -0
- package/src/server/lib/db/schema.ts +3 -0
- package/src/server/lib/fs/archive.test.ts +139 -0
- package/src/server/lib/fs/archive.ts +259 -0
- package/src/server/lib/fs/git-diff.test.ts +26 -1
- package/src/server/lib/fs/git-diff.ts +43 -15
- package/src/server/lib/harness/acp/client.ts +81 -87
- package/src/server/lib/harness/acp/prewarm.server.ts +237 -0
- package/src/server/lib/harness/acp/prewarm.test.ts +171 -0
- package/src/server/lib/harness/acp/prompt.test.ts +70 -1
- package/src/server/lib/harness/acp/prompt.ts +32 -1
- package/src/server/lib/harness/acp/protocol.ts +23 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +26 -0
- package/src/server/lib/harness/acp/session-handshake.ts +22 -20
- package/src/server/lib/harness/acp/session-options.ts +16 -0
- package/src/server/lib/harness/acp/session-process.ts +43 -0
- package/src/server/lib/harness/acp/session.ts +11 -12
- package/src/server/lib/harness/acp/stdio.ts +129 -0
- package/src/server/lib/harness/acp/verbs.test.ts +97 -0
- package/src/server/lib/harness/acp/verbs.ts +16 -6
- package/src/server/lib/harness/auto-probe.server.ts +4 -3
- package/src/server/lib/harness/capabilities.ts +8 -0
- package/src/server/lib/harness/config.server.ts +3 -2
- package/src/server/lib/harness/custom.server.ts +209 -0
- package/src/server/lib/harness/launch-table.ts +19 -0
- package/src/server/lib/harness/launch.ts +6 -1
- package/src/server/lib/harness/provider-entry.ts +1 -1
- package/src/server/lib/harness/provider-file.server.ts +1 -1
- package/src/server/lib/harness/provider-sources.server.ts +2 -1
- package/src/server/lib/harness/provider-write.server.ts +2 -1
- package/src/server/lib/harness/register.server.ts +8 -1
- package/src/server/lib/harness/schema.server.ts +21 -0
- package/src/server/lib/harness/session-lease.server.test.ts +99 -0
- package/src/server/lib/harness/session-lease.server.ts +193 -0
- package/src/server/lib/harness/session-store.server.test.ts +8 -8
- package/src/server/lib/harness/session-store.server.ts +25 -4
- package/src/server/lib/harness/session-title.server.ts +12 -2
- package/src/server/lib/harness/spawn.server.ts +123 -20
- package/src/server/lib/harness/update-job-store.ts +12 -0
- package/src/server/lib/harness/update-queue.server.ts +18 -13
- package/src/server/lib/lifecycle/after-listen.ts +12 -1
- package/src/server/lib/lifecycle/paths.ts +19 -1
- package/src/server/lib/mcp/registry.server.ts +155 -0
- package/src/server/lib/mcp/registry.test.ts +169 -0
- package/src/server/lib/mcp/store.server.ts +38 -0
- package/src/server/lib/omp/rpc/frame-fold-contract.ts +59 -0
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +64 -1
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +2 -1
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
- package/src/server/lib/omp/rpc/frame-fold.test.ts +7 -2
- package/src/server/lib/omp/rpc/frame-fold.ts +6 -45
- package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
- package/src/server/lib/omp/rpc/prewarm-pool.ts +19 -5
- package/src/server/lib/omp/rpc/run-model.test.ts +116 -0
- package/src/server/lib/omp/rpc/run-model.ts +4 -2
- package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
- package/src/server/lib/omp/session/delete.server.ts +1 -0
- package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
- package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
- package/src/server/lib/omp/session/sidebar-data.harness.test.ts +6 -3
- package/src/server/lib/omp/session/standby.server.ts +13 -2
- package/src/server/lib/panels/auto-update.server.test.ts +5 -2
- package/src/server/lib/panels/git-update.server.test.ts +5 -2
- package/src/server/lib/panels/install.server.test.ts +5 -2
- package/src/server/lib/panels/manifest.test.ts +47 -1
- package/src/server/lib/panels/manifest.ts +19 -0
- package/src/server/lib/panels/registry.server.ts +19 -2
- package/src/server/lib/panels/remove.server.test.ts +5 -2
- package/src/server/lib/panels/scan.server.ts +26 -2
- package/src/server/lib/panels/settings-schema.server.ts +72 -0
- package/src/server/lib/plugins/background.server.ts +21 -3
- package/src/server/lib/plugins/background.test.ts +13 -0
- package/src/server/lib/plugins/loader.server.ts +35 -51
- package/src/server/lib/plugins/mcp.server.ts +100 -0
- package/src/server/lib/plugins/mcp.test.ts +75 -0
- package/src/server/lib/plugins/schedule-runner.server.ts +153 -0
- package/src/server/lib/plugins/schedule-runner.test.ts +186 -0
- package/src/server/lib/plugins/schedule-store.server.ts +107 -0
- package/src/server/lib/plugins/schema.server.ts +8 -0
- package/src/server/lib/plugins/settings.server.ts +56 -19
- package/src/server/lib/plugins/shutdown.server.ts +58 -0
- package/src/server/lib/plugins/shutdown.test.ts +28 -3
- package/src/server/lib/realtime/topics/global.server.ts +5 -1
- package/src/server/lib/schedule/rows.server.ts +9 -0
- package/src/server/lib/schedule/runtime.server.test.ts +91 -0
- package/src/server/lib/schedule/runtime.server.ts +101 -23
- package/src/server/lib/schedule/schema.server.ts +15 -0
- package/src/server/lib/schedule/store.server.test.ts +34 -0
- package/src/server/lib/schedule/store.server.ts +33 -9
- package/src/server/lib/sessions/fork.server.test.ts +47 -0
- package/src/server/lib/sessions/fork.server.ts +17 -1
- package/src/server/lib/sessions/spawn.server.ts +2 -2
- package/src/server/lib/waiting/runtime.server.test.ts +48 -0
- package/src/server/lib/waiting/runtime.server.ts +22 -0
- package/src/server/lib/waiting/schema.server.ts +8 -0
- package/src/server/lib/waiting/store.server.test.ts +14 -0
- package/src/server/lib/waiting/store.server.ts +6 -2
- package/src/server/routes/agent/command-resume.test.ts +9 -4
- package/src/server/routes/agent/command.ts +11 -0
- package/src/server/routes/agent/new-mode.test.ts +40 -0
- package/src/server/routes/agent/new.ts +36 -10
- package/src/server/routes/agent/prewarm.ts +48 -7
- package/src/server/routes/chat/index.ts +5 -0
- package/src/server/routes/chat/prompt-history.test.ts +67 -0
- package/src/server/routes/chat/prompt-history.ts +31 -0
- package/src/server/routes/chat/stream.test.ts +21 -0
- package/src/server/routes/chat/stream.ts +5 -0
- package/src/server/routes/fs/action-archive.test.ts +128 -0
- package/src/server/routes/fs/action-bulk.ts +106 -0
- package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
- package/src/server/routes/fs/action-transfer.test.ts +26 -0
- package/src/server/routes/fs/action.ts +100 -12
- package/src/server/routes/fs/archive.ts +20 -0
- package/src/server/routes/fs/digest.test.ts +100 -0
- package/src/server/routes/fs/digest.ts +106 -0
- package/src/server/routes/fs/grant.test.ts +5 -2
- package/src/server/routes/fs/index.ts +4 -0
- package/src/server/routes/fs/read.ts +6 -1
- package/src/server/routes/fs/scope.test.ts +6 -2
- package/src/server/routes/harness/custom.test.ts +131 -0
- package/src/server/routes/harness/import-action.ts +3 -3
- package/src/server/routes/harness/root.ts +47 -9
- package/src/server/routes/harness/summary.test.ts +50 -0
- package/src/server/routes/harness/update-status.ts +41 -2
- package/src/server/routes/harness/update.test.ts +56 -2
- package/src/server/routes/harness/update.ts +2 -2
- package/src/server/routes/panels/bindings.ts +2 -0
- package/src/server/routes/panels/settings.test.ts +165 -0
- package/src/server/routes/panels/settings.ts +106 -0
- package/src/server/routes/schedule/body.ts +14 -0
- package/src/server/routes/schedule/index.ts +28 -4
- package/src/server/routes/sessions/delete.test.ts +4 -0
- package/src/server/routes/settings/mcp.ts +9 -26
- package/src/server/routes/waiting/index.ts +21 -2
- package/src/server/routes/waiting/routes.test.ts +21 -0
- package/src/shared/lib/chat/ask-form/index.ts +39 -31
- package/src/shared/lib/chat/ask-form/labels.ts +46 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
- package/src/shared/lib/chat/ask-form.test.ts +57 -0
- package/src/shared/lib/chat/ask-questions.ts +31 -0
- package/src/shared/lib/chat/composer/delegation.ts +3 -3
- package/src/shared/lib/chat/composer/history.test.ts +67 -0
- package/src/shared/lib/chat/composer/history.ts +61 -0
- package/src/shared/lib/chat/irc-notice.ts +42 -0
- package/src/shared/lib/chat/timeline/fork-anchor.test.ts +99 -0
- package/src/shared/lib/chat/timeline/fork-anchor.ts +47 -0
- package/src/shared/lib/chat/todo/parser.ts +6 -4
- package/src/shared/lib/fs/archive.test.ts +101 -0
- package/src/shared/lib/fs/archive.ts +191 -0
- package/src/shared/lib/fs/clipboard.test.ts +32 -7
- package/src/shared/lib/fs/clipboard.ts +59 -14
- package/src/shared/lib/fs/content-hash.ts +29 -0
- package/src/shared/lib/fs/csv.test.ts +50 -0
- package/src/shared/lib/fs/csv.ts +40 -0
- package/src/shared/lib/fs/document-kind.test.ts +13 -6
- package/src/shared/lib/fs/document-kind.ts +18 -6
- package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
- package/src/shared/lib/fs/file-kind.test.ts +2 -7
- package/src/shared/lib/fs/file-kind.ts +4 -2
- package/src/shared/lib/fs/grid-edit.test.ts +24 -0
- package/src/shared/lib/fs/grid-edit.ts +29 -0
- package/src/shared/lib/fs/grid-selection.test.ts +137 -0
- package/src/shared/lib/fs/grid-selection.ts +138 -0
- package/src/shared/lib/harness/brand-color.ts +5 -0
- package/src/shared/lib/harness/catalog.test.ts +22 -0
- package/src/shared/lib/harness/catalog.ts +60 -7
- package/src/shared/lib/harness/config-fields.test.ts +25 -0
- package/src/shared/lib/harness/config-fields.ts +33 -3
- package/src/shared/lib/harness/dialects.ts +1 -1
- package/src/shared/lib/harness/fork.ts +60 -0
- package/src/shared/lib/harness/mcp-facts.test.ts +30 -0
- package/src/shared/lib/harness/mcp-facts.ts +69 -0
- package/src/shared/lib/harness/menu.test.ts +16 -1
- package/src/shared/lib/harness/menu.ts +2 -2
- package/src/shared/lib/harness/provider-contracts.ts +109 -0
- package/src/shared/lib/harness/provider-facts.test.ts +2 -1
- package/src/shared/lib/harness/provider-facts.ts +24 -115
- package/src/shared/lib/harness/provider-lookup.ts +37 -0
- package/src/shared/lib/harness/providers.ts +2 -1
- package/src/shared/lib/harness/rewind.ts +6 -6
- package/src/shared/lib/harness/session-modes.ts +31 -0
- package/src/shared/lib/harness/transcript.test.ts +29 -0
- package/src/shared/lib/harness/transcript.ts +19 -0
- package/src/shared/lib/harness/updates.ts +10 -0
- package/src/shared/lib/notifications/settings.test.ts +21 -0
- package/src/shared/lib/notifications/settings.ts +24 -0
- package/src/shared/lib/omp/session/mapper.test.ts +31 -0
- package/src/shared/lib/omp/session/mapper.ts +17 -0
- package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
- package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
- package/src/shared/lib/omp/session/messages-map.ts +17 -0
- package/src/shared/lib/omp/session/prewarm.test.ts +28 -4
- package/src/shared/lib/omp/session/prewarm.ts +25 -6
- package/src/shared/lib/omp/session/stream-state.server.test.ts +25 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +8 -4
- package/src/shared/lib/omp/session/wait.ts +10 -1
- package/src/shared/lib/panels/capabilities.test.ts +1 -1
- package/src/shared/lib/panels/capabilities.ts +3 -0
- package/src/shared/lib/plugins/settings.ts +22 -0
- package/src/shared/lib/schedule/parse.test.ts +48 -0
- package/src/shared/lib/schedule/parse.ts +69 -45
- package/src/shared/lib/schedule/timezone.ts +128 -0
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/settings/sections.ts +8 -4
- package/src/shared/lib/ui/picker-filter.test.ts +23 -0
- package/src/shared/lib/ui/picker-filter.ts +20 -0
- package/src/shared/lib/workspace/refresh-cadence.test.ts +25 -1
- package/src/shared/lib/workspace/relative-time.ts +16 -0
- package/src/shared/types/chat.ts +4 -0
- package/src/shared/types/harness.ts +12 -1
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/omp/session.ts +18 -0
- package/src/shared/types/panels-registry.ts +3 -3
- package/src/shared/types/panels.ts +4 -2
- package/src/shared/types/schedule.ts +13 -0
- package/src/shared/types/settings/state.ts +18 -7
- package/src/shared/types/todo.ts +3 -1
- package/src/shared/types/waiting.ts +9 -0
- package/src/test-support/file-actions.test-util.ts +4 -0
- package/src/test-support/file-archive.test-util.ts +41 -0
- package/src/test-support/file-clipboard.test-util.ts +9 -6
- package/src/test-support/file-editor.test-util.ts +70 -5
- package/src/test-support/harness-table.test-util.ts +2 -0
- package/src/test-support/preload.ts +46 -0
- package/dist/client/static/js/index-32rpkj6b.css +0 -1
- package/src/client/hooks/editor/use-external-change-notice.ts +0 -71
- package/src/client/hooks/editor/use-external-change.test.ts +0 -88
- package/src/client/hooks/editor/use-external-change.ts +0 -146
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The anchor a per-message Fork carries. Only a transcript Kabmo can read can
|
|
8
|
+
* be cut at a message; an agent that keeps its own history forks the chat whole
|
|
9
|
+
* — except the adapters that read the AIR fork point, which fork at an
|
|
10
|
+
* assistant message.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, expect, test } from 'bun:test';
|
|
14
|
+
import { canForkAt, forkAnchorFor } from '@/shared/lib/chat/timeline/fork-anchor';
|
|
15
|
+
import { canForkChat, forkCapability } from '@/shared/lib/harness/fork';
|
|
16
|
+
|
|
17
|
+
describe('forkCapability', () => {
|
|
18
|
+
test('omp and the AIR adapters fork at a message', () => {
|
|
19
|
+
expect(forkCapability('omp-rpc')).toBe('message');
|
|
20
|
+
expect(forkCapability('omp-acp')).toBe('message');
|
|
21
|
+
expect(forkCapability('claude')).toBe('message');
|
|
22
|
+
expect(forkCapability('codex')).toBe('message');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('a whole-chat-only harness is tip', () => {
|
|
26
|
+
expect(forkCapability('opencode')).toBe('tip');
|
|
27
|
+
expect(forkCapability('minimax')).toBe('tip');
|
|
28
|
+
expect(forkCapability('zcode')).toBe('tip');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('a harness with no session/fork is none', () => {
|
|
32
|
+
expect(forkCapability('qwen')).toBe('none');
|
|
33
|
+
expect(forkCapability('dsh')).toBe('none');
|
|
34
|
+
expect(forkCapability('antigravity')).toBe('none');
|
|
35
|
+
expect(forkCapability('jcode')).toBe('none');
|
|
36
|
+
expect(forkCapability('grok')).toBe('none');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('canForkChat', () => {
|
|
41
|
+
test('the probe is authoritative when it has an answer', () => {
|
|
42
|
+
expect(canForkChat('qwen', true)).toBe(true);
|
|
43
|
+
expect(canForkChat('claude', false)).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('without a probe the expected capability decides', () => {
|
|
47
|
+
expect(canForkChat('zcode')).toBe(true);
|
|
48
|
+
expect(canForkChat('qwen')).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('canForkAt', () => {
|
|
53
|
+
test('omp forks at either row', () => {
|
|
54
|
+
expect(canForkAt('omp-rpc', 'user')).toBe(true);
|
|
55
|
+
expect(canForkAt('omp-acp', 'assistant')).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('an AIR adapter forks at an assistant row only', () => {
|
|
59
|
+
expect(canForkAt('claude', 'assistant')).toBe(true);
|
|
60
|
+
expect(canForkAt('codex', 'assistant')).toBe(true);
|
|
61
|
+
expect(canForkAt('claude', 'user')).toBe(false);
|
|
62
|
+
expect(canForkAt('codex', 'user')).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a whole-chat-only harness forks at neither row', () => {
|
|
66
|
+
expect(canForkAt('zcode', 'assistant')).toBe(false);
|
|
67
|
+
expect(canForkAt('opencode', 'user')).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('an unresolved harness keeps the historical allow', () => {
|
|
71
|
+
expect(canForkAt(undefined, 'user')).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('forkAnchorFor', () => {
|
|
76
|
+
test('an omp chat forks at the clicked message, user or assistant', () => {
|
|
77
|
+
expect(forkAnchorFor('omp-rpc', 'u2', 'user')).toBe('u2');
|
|
78
|
+
expect(forkAnchorFor('omp-acp', 'a2', 'assistant')).toBe('a2');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('claude and codex fork at an assistant message through the AIR extension', () => {
|
|
82
|
+
expect(forkAnchorFor('claude', 'a2', 'assistant')).toBe('a2');
|
|
83
|
+
expect(forkAnchorFor('codex', 'a2', 'assistant')).toBe('a2');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('an AIR adapter has no fork point on a user row', () => {
|
|
87
|
+
expect(forkAnchorFor('claude', 'u2', 'user')).toBeNull();
|
|
88
|
+
expect(forkAnchorFor('codex', 'u2', 'user')).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a harness with its own store and no fork point forks the whole chat', () => {
|
|
92
|
+
expect(forkAnchorFor('zcode', 'a2', 'assistant')).toBeNull();
|
|
93
|
+
expect(forkAnchorFor('opencode', 'u2', 'user')).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('an unresolved harness keeps the anchor', () => {
|
|
97
|
+
expect(forkAnchorFor(undefined, 'u2', 'user')).toBe('u2');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The anchor a per-message Fork may carry.
|
|
8
|
+
*
|
|
9
|
+
* A fork cuts the transcript Kabmo can read, so the anchor is only meaningful
|
|
10
|
+
* where that transcript exists (`harnessHasLocalTranscript`). An agent that
|
|
11
|
+
* keeps its history in its own store forks the chat WHOLE — `session/fork`
|
|
12
|
+
* takes no anchor — so the anchor is dropped here and the composer's preview
|
|
13
|
+
* shows every row the branch will hold, instead of promising a cut the agent
|
|
14
|
+
* cannot make.
|
|
15
|
+
*
|
|
16
|
+
* `claude` is the exception: claude-agent-acp reads a fork point from
|
|
17
|
+
* `_meta.jetbrains.air.fork` (the AIR extension) and keeps the history up to
|
|
18
|
+
* that message. Its resolver only groups ASSISTANT entries, so a user row has
|
|
19
|
+
* no fork point there and stays a whole-chat fork.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { harnessHasLocalTranscript } from '@/shared/lib/harness/transcript';
|
|
23
|
+
import { forkCapability } from '@/shared/lib/harness/fork';
|
|
24
|
+
|
|
25
|
+
/** The two rows that offer Fork: a user turn and an assistant run footer. */
|
|
26
|
+
export type ForkAnchorRole = 'user' | 'assistant';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether this harness can fork at a row of this role at all. The UI asks this
|
|
30
|
+
* before drawing the button: a control that can only answer "whole chat" (or
|
|
31
|
+
* nothing) is not a per-message fork.
|
|
32
|
+
*/
|
|
33
|
+
export function canForkAt(
|
|
34
|
+
harness: string | null | undefined,
|
|
35
|
+
role: ForkAnchorRole,
|
|
36
|
+
): boolean {
|
|
37
|
+
if (forkCapability(harness) !== 'message') return false;
|
|
38
|
+
return harnessHasLocalTranscript(harness) || role === 'assistant';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function forkAnchorFor(
|
|
42
|
+
harness: string | null | undefined,
|
|
43
|
+
messageId: string,
|
|
44
|
+
role: ForkAnchorRole,
|
|
45
|
+
): string | null {
|
|
46
|
+
return canForkAt(harness, role) ? messageId : null;
|
|
47
|
+
}
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Two shapes the summary can carry are handled here rather than in the card:
|
|
18
18
|
*
|
|
19
|
-
* - The status vocabulary is omp's own
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* parser
|
|
19
|
+
* - The status vocabulary is omp's own, not the three the card used to know.
|
|
20
|
+
* `abandoned` is real (measured in the author's sessions: 21 results
|
|
21
|
+
* mention a dropped task), and `blocked` was too until omp 18.19.0 removed
|
|
22
|
+
* it — the parser keeps both because it reads tool text, and sessions
|
|
23
|
+
* recorded before that pin still carry `(blocked: …)` lines. A parser that
|
|
24
|
+
* only understood three drew them as plain pending.
|
|
23
25
|
* - A task whose content is an init-list entry rather than prose is recorded
|
|
24
26
|
* that way by omp itself (see `./nested-phase`), so it is labelled by the
|
|
25
27
|
* phase it names instead of being rendered as a JSON blob.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The archive naming rules the dialog and the route both read.
|
|
8
|
+
*
|
|
9
|
+
* The suffix table is the one that decides whether a right-click offers
|
|
10
|
+
* Extract, so a `.tar.gz` read as `.gz` would unpack one gzip layer and leave a
|
|
11
|
+
* tarball behind. The default names are what the Compress dialog shows before
|
|
12
|
+
* the user types, and a wrong one (naming a multi-selection after its first
|
|
13
|
+
* file) hides what the archive holds.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import {
|
|
18
|
+
archiveExtension,
|
|
19
|
+
archiveKindOf,
|
|
20
|
+
archiveKindLabel,
|
|
21
|
+
defaultArchiveDestination,
|
|
22
|
+
defaultArchiveName,
|
|
23
|
+
defaultExtractDestination,
|
|
24
|
+
isArchiveName,
|
|
25
|
+
commonParentDir,
|
|
26
|
+
stripArchiveSuffix,
|
|
27
|
+
} from '@/shared/lib/fs/archive';
|
|
28
|
+
|
|
29
|
+
const file = (path: string, name = path.split('/').pop() ?? path) => ({ path, name, kind: 'file' as const });
|
|
30
|
+
|
|
31
|
+
describe('archiveKindOf', () => {
|
|
32
|
+
test('reads the longest suffix first', () => {
|
|
33
|
+
expect(archiveKindOf('src.tar.gz')).toBe('tar.gz');
|
|
34
|
+
expect(archiveKindOf('src.tgz')).toBe('tar.gz');
|
|
35
|
+
expect(archiveKindOf('src.tar.bz2')).toBe('tar.bz2');
|
|
36
|
+
expect(archiveKindOf('src.tar.xz')).toBe('tar.xz');
|
|
37
|
+
expect(archiveKindOf('src.tar')).toBe('tar');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('recognises every single-file compressor', () => {
|
|
41
|
+
expect(archiveKindOf('a.zip')).toBe('zip');
|
|
42
|
+
expect(archiveKindOf('a.7z')).toBe('7z');
|
|
43
|
+
expect(archiveKindOf('a.rar')).toBe('rar');
|
|
44
|
+
expect(archiveKindOf('a.gz')).toBe('gz');
|
|
45
|
+
expect(archiveKindOf('a.bz2')).toBe('bz2');
|
|
46
|
+
expect(archiveKindOf('a.xz')).toBe('xz');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('is case-insensitive and rejects a normal file', () => {
|
|
50
|
+
expect(archiveKindOf('SRC.ZIP')).toBe('zip');
|
|
51
|
+
expect(archiveKindOf('main.ts')).toBeNull();
|
|
52
|
+
expect(archiveKindOf('zip')).toBeNull();
|
|
53
|
+
expect(isArchiveName('photo.ZIP')).toBe(true);
|
|
54
|
+
expect(isArchiveName('notes.md')).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('labels the kind for the dialog', () => {
|
|
58
|
+
expect(archiveKindLabel('tar.gz')).toBe('TAR.GZ');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('stripArchiveSuffix', () => {
|
|
63
|
+
test('removes the whole archive suffix', () => {
|
|
64
|
+
expect(stripArchiveSuffix('src.tar.gz')).toBe('src');
|
|
65
|
+
expect(stripArchiveSuffix('src.zip')).toBe('src');
|
|
66
|
+
expect(stripArchiveSuffix('main.ts')).toBe('main.ts');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('defaultArchiveName', () => {
|
|
71
|
+
test('one file keeps its stem, one folder its own name', () => {
|
|
72
|
+
expect(defaultArchiveName([file('src/report.pdf', 'report.pdf')], 'zip')).toBe('report.zip');
|
|
73
|
+
expect(defaultArchiveName([{ path: 'src', name: 'src', kind: 'folder' }], 'tar.gz')).toBe('src.tar.gz');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('a multi-selection takes the name of the folder that holds it', () => {
|
|
77
|
+
expect(defaultArchiveName([file('src/a.ts'), file('src/b.ts')], '7z')).toBe('src.7z');
|
|
78
|
+
// Different branches share the root, which is the common folder.
|
|
79
|
+
expect(defaultArchiveName([file('src/a.ts'), file('docs/b.md')], 'zip')).toBe('archive.zip');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('format extension follows the chosen format', () => {
|
|
83
|
+
expect(archiveExtension('rar')).toBe('rar');
|
|
84
|
+
expect(archiveExtension('tar.gz')).toBe('tar.gz');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('commonParentDir and destinations', () => {
|
|
89
|
+
test('finds the deepest shared folder', () => {
|
|
90
|
+
expect(commonParentDir(['src/a.ts', 'src/b.ts'])).toBe('src');
|
|
91
|
+
expect(commonParentDir(['src/deep/a.ts', 'src/deep/b.ts'])).toBe('src/deep');
|
|
92
|
+
expect(commonParentDir(['src/a.ts', 'docs/b.md'])).toBe('.');
|
|
93
|
+
expect(commonParentDir([])).toBe('.');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('compress lands beside the selection; extract lands in a stem folder', () => {
|
|
97
|
+
expect(defaultArchiveDestination([file('src/a.ts')])).toBe('src');
|
|
98
|
+
expect(defaultExtractDestination('src/bundle.zip')).toBe('src/bundle');
|
|
99
|
+
expect(defaultExtractDestination('bundle.tar.gz')).toBe('bundle');
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Archive names, formats and destinations — the facts BOTH ends need.
|
|
8
|
+
*
|
|
9
|
+
* The Files panel decides which menu rows to offer (Extract only on an archive,
|
|
10
|
+
* Compress on any selection) and which name a new archive should take; the
|
|
11
|
+
* server decides which binary runs and refuses what cannot be written. Keeping
|
|
12
|
+
* the suffix table, the format list and the default names in one module is what
|
|
13
|
+
* stops the dialog from offering `.zip` while the route expects `.7z`.
|
|
14
|
+
*
|
|
15
|
+
* The compress list is intentionally shorter than the extract list: extracting
|
|
16
|
+
* a `.rar` only needs a reader, while creating one needs the proprietary `rar`
|
|
17
|
+
* binary, which most machines do not ship. The dialog reports the formats the
|
|
18
|
+
* server can actually run.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** A format the Compress dialog can write. */
|
|
22
|
+
export type ArchiveFormat = 'zip' | '7z' | 'rar' | 'tar' | 'tar.gz';
|
|
23
|
+
|
|
24
|
+
/** Every archive spelling the Extract menu recognises. */
|
|
25
|
+
export type ArchiveKind =
|
|
26
|
+
| 'zip'
|
|
27
|
+
| '7z'
|
|
28
|
+
| 'rar'
|
|
29
|
+
| 'tar'
|
|
30
|
+
| 'tar.gz'
|
|
31
|
+
| 'tar.bz2'
|
|
32
|
+
| 'tar.xz'
|
|
33
|
+
| 'gz'
|
|
34
|
+
| 'bz2'
|
|
35
|
+
| 'xz';
|
|
36
|
+
|
|
37
|
+
export interface ArchiveFormatInfo {
|
|
38
|
+
id: ArchiveFormat;
|
|
39
|
+
/** What the dialog shows. */
|
|
40
|
+
label: string;
|
|
41
|
+
/** The suffix the default name takes, without a dot. */
|
|
42
|
+
extension: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const COMPRESS_FORMATS: readonly ArchiveFormatInfo[] = [
|
|
46
|
+
{ id: 'zip', label: 'ZIP', extension: 'zip' },
|
|
47
|
+
{ id: '7z', label: '7Z', extension: '7z' },
|
|
48
|
+
{ id: 'rar', label: 'RAR', extension: 'rar' },
|
|
49
|
+
{ id: 'tar', label: 'TAR', extension: 'tar' },
|
|
50
|
+
{ id: 'tar.gz', label: 'TAR.GZ', extension: 'tar.gz' },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/** Suffix → kind, longest first so `.tar.gz` is not read as `.gz`. */
|
|
54
|
+
const KIND_SUFFIXES: ReadonlyArray<readonly [string, ArchiveKind]> = [
|
|
55
|
+
['.tar.gz', 'tar.gz'],
|
|
56
|
+
['.tar.bz2', 'tar.bz2'],
|
|
57
|
+
['.tar.xz', 'tar.xz'],
|
|
58
|
+
['.tgz', 'tar.gz'],
|
|
59
|
+
['.tbz2', 'tar.bz2'],
|
|
60
|
+
['.txz', 'tar.xz'],
|
|
61
|
+
['.tar', 'tar'],
|
|
62
|
+
['.zip', 'zip'],
|
|
63
|
+
['.7z', '7z'],
|
|
64
|
+
['.rar', 'rar'],
|
|
65
|
+
['.gz', 'gz'],
|
|
66
|
+
['.bz2', 'bz2'],
|
|
67
|
+
['.xz', 'xz'],
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
/** The archive kind `name` is spelled as, or null when it is not one. */
|
|
71
|
+
export function archiveKindOf(name: string): ArchiveKind | null {
|
|
72
|
+
const lower = name.toLowerCase();
|
|
73
|
+
for (const [suffix, kind] of KIND_SUFFIXES) {
|
|
74
|
+
if (lower.endsWith(suffix)) return kind;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Whether a row is an archive the panel can offer Extract for. */
|
|
80
|
+
export function isArchiveName(name: string): boolean {
|
|
81
|
+
return archiveKindOf(name) !== null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The format entry for an id, or undefined for an unknown id. */
|
|
85
|
+
export function archiveFormatInfo(format: string): ArchiveFormatInfo | undefined {
|
|
86
|
+
return COMPRESS_FORMATS.find((entry) => entry.id === format);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The extension a format's file name ends with, without the dot. */
|
|
90
|
+
export function archiveExtension(format: ArchiveFormat): string {
|
|
91
|
+
return archiveFormatInfo(format)?.extension ?? 'zip';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The name with any recognised archive suffix removed (`a.tar.gz` → `a`). */
|
|
95
|
+
export function stripArchiveSuffix(name: string): string {
|
|
96
|
+
const lower = name.toLowerCase();
|
|
97
|
+
for (const [suffix] of KIND_SUFFIXES) {
|
|
98
|
+
if (lower.endsWith(suffix)) return name.slice(0, -suffix.length);
|
|
99
|
+
}
|
|
100
|
+
return name;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The folder part of a relative POSIX path, `.` at the top. */
|
|
104
|
+
export function parentDirOf(path: string): string {
|
|
105
|
+
const cut = path.lastIndexOf('/');
|
|
106
|
+
return cut === -1 ? '.' : path.slice(0, cut) || '.';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The last segment of a relative POSIX path. */
|
|
110
|
+
export function baseNameOf(path: string): string {
|
|
111
|
+
const cut = path.lastIndexOf('/');
|
|
112
|
+
return cut === -1 ? path : path.slice(cut + 1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The deepest folder that contains every path.
|
|
117
|
+
*
|
|
118
|
+
* A compress runs with that folder as its working directory, so every argument
|
|
119
|
+
* is a clean relative name rather than a `../` climb — which is also the rule
|
|
120
|
+
* the server enforces. Paths from different branches therefore share `.` and
|
|
121
|
+
* the archive sits at the listing root.
|
|
122
|
+
*/
|
|
123
|
+
export function commonParentDir(paths: readonly string[]): string {
|
|
124
|
+
if (paths.length === 0) return '.';
|
|
125
|
+
const split = paths.map((path) => parentDirOf(path).split('/').filter((segment) => segment !== '.'));
|
|
126
|
+
let shared = split[0] ?? [];
|
|
127
|
+
for (const segments of split.slice(1)) {
|
|
128
|
+
let index = 0;
|
|
129
|
+
while (index < shared.length && index < segments.length && shared[index] === segments[index]) index += 1;
|
|
130
|
+
shared = shared.slice(0, index);
|
|
131
|
+
}
|
|
132
|
+
return shared.length === 0 ? '.' : shared.join('/');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface ArchiveNameSource {
|
|
136
|
+
path: string;
|
|
137
|
+
name: string;
|
|
138
|
+
kind: 'file' | 'folder';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The name a Compress dialog proposes.
|
|
143
|
+
*
|
|
144
|
+
* One file keeps its stem (`report.pdf` → `report.zip`), one folder its own
|
|
145
|
+
* name (`src` → `src.zip`), and a multi-selection takes the name of the folder
|
|
146
|
+
* they live in — naming the archive after the first arbitrary file would hide
|
|
147
|
+
* what it holds.
|
|
148
|
+
*/
|
|
149
|
+
export function defaultArchiveName(entries: readonly ArchiveNameSource[], format: ArchiveFormat): string {
|
|
150
|
+
const extension = archiveExtension(format);
|
|
151
|
+
if (entries.length === 1) {
|
|
152
|
+
const entry = entries[0]!;
|
|
153
|
+
// A file's own extension is dropped too: `report.pdf` compresses to
|
|
154
|
+
// `report.zip`, not `report.pdf.zip`, which reads as an archive of a PDF
|
|
155
|
+
// renamed twice.
|
|
156
|
+
const withoutArchive = stripArchiveSuffix(entry.name);
|
|
157
|
+
const dot = withoutArchive.lastIndexOf('.');
|
|
158
|
+
const stem = entry.kind === 'folder'
|
|
159
|
+
? entry.name
|
|
160
|
+
: dot > 0 ? withoutArchive.slice(0, dot) : withoutArchive;
|
|
161
|
+
return `${stem || 'archive'}.${extension}`;
|
|
162
|
+
}
|
|
163
|
+
const common = commonParentDir(entries.map((entry) => entry.path));
|
|
164
|
+
const folder = baseNameOf(common);
|
|
165
|
+
return `${folder === '.' || folder === '' ? 'archive' : folder}.${extension}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The destination a Compress dialog proposes: the folder the selection lives
|
|
170
|
+
* in, which is where the archive appears beside it.
|
|
171
|
+
*/
|
|
172
|
+
export function defaultArchiveDestination(entries: readonly ArchiveNameSource[]): string {
|
|
173
|
+
return commonParentDir(entries.map((entry) => entry.path));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The folder an Extract dialog proposes: a sibling of the archive named after
|
|
178
|
+
* its stem (`src.zip` → `src`). Extracting in place is the same call with `.`
|
|
179
|
+
* typed in the field, so the default never scatters files beside the archive.
|
|
180
|
+
*/
|
|
181
|
+
export function defaultExtractDestination(archivePath: string): string {
|
|
182
|
+
const parent = parentDirOf(archivePath);
|
|
183
|
+
const stem = stripArchiveSuffix(baseNameOf(archivePath));
|
|
184
|
+
if (!stem) return parent;
|
|
185
|
+
return parent === '.' ? stem : `${parent}/${stem}`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** The display name of an archive kind, for the dialog's subtitle. */
|
|
189
|
+
export function archiveKindLabel(kind: ArchiveKind): string {
|
|
190
|
+
return kind.toUpperCase();
|
|
191
|
+
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { describe, expect, test } from 'bun:test';
|
|
17
17
|
import {
|
|
18
|
+
clipboardLabel,
|
|
18
19
|
dropRefusal,
|
|
19
20
|
duplicateName,
|
|
20
21
|
fsClipboardScope,
|
|
@@ -29,9 +30,7 @@ import {
|
|
|
29
30
|
|
|
30
31
|
const clip = (over: Partial<FsClipboard> = {}): FsClipboard => ({
|
|
31
32
|
scope: 'ws\u0000.',
|
|
32
|
-
path: 'src/a.ts',
|
|
33
|
-
name: 'a.ts',
|
|
34
|
-
kind: 'file',
|
|
33
|
+
entries: [{ path: 'src/a.ts', name: 'a.ts', kind: 'file' }],
|
|
35
34
|
mode: 'copy',
|
|
36
35
|
...over,
|
|
37
36
|
});
|
|
@@ -140,15 +139,26 @@ describe('pasteRefusal', () => {
|
|
|
140
139
|
|
|
141
140
|
test('allows a paste of this listing’s entry and applies the folder rule', () => {
|
|
142
141
|
expect(pasteRefusal(clip(), 'ws\u0000.', 'other')).toBeNull();
|
|
143
|
-
expect(pasteRefusal(clip({ path: 'src', kind: 'folder' }), 'ws\u0000.', 'src/sub')).toContain('itself');
|
|
142
|
+
expect(pasteRefusal(clip({ entries: [{ path: 'src', name: 'src', kind: 'folder' }] }), 'ws\u0000.', 'src/sub')).toContain('itself');
|
|
144
143
|
});
|
|
145
144
|
|
|
146
145
|
test('a CUT into its own folder is refused; a COPY into it is how a copy is made', () => {
|
|
147
146
|
// The two modes differ here on purpose: copying a file into the directory
|
|
148
147
|
// it already lives in is how `a copy.ts` is produced, while a cut there
|
|
149
148
|
// would have nothing to do.
|
|
150
|
-
expect(pasteRefusal(clip({
|
|
151
|
-
expect(pasteRefusal(clip({
|
|
149
|
+
expect(pasteRefusal(clip({ mode: 'cut' }), 'ws\u0000.', 'src')).toBe('Already in this folder');
|
|
150
|
+
expect(pasteRefusal(clip({ mode: 'copy' }), 'ws\u0000.', 'src')).toBeNull();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('clipboardLabel', () => {
|
|
155
|
+
test('names the one entry, or counts a selection', () => {
|
|
156
|
+
expect(clipboardLabel(null)).toBeNull();
|
|
157
|
+
expect(clipboardLabel(clip())).toBe('a.ts');
|
|
158
|
+
expect(clipboardLabel(clip({ entries: [
|
|
159
|
+
{ path: 'a.ts', name: 'a.ts', kind: 'file' },
|
|
160
|
+
{ path: 'b.ts', name: 'b.ts', kind: 'file' },
|
|
161
|
+
] }))).toBe('2 items');
|
|
152
162
|
});
|
|
153
163
|
});
|
|
154
164
|
|
|
@@ -165,10 +175,23 @@ describe('readFsClipboard', () => {
|
|
|
165
175
|
expect(readFsClipboard(clip())).toEqual(clip());
|
|
166
176
|
});
|
|
167
177
|
|
|
178
|
+
test('accepts a multi-entry selection', () => {
|
|
179
|
+
const multi = clip({ entries: [
|
|
180
|
+
{ path: 'src/a.ts', name: 'a.ts', kind: 'file' },
|
|
181
|
+
{ path: 'src/deep', name: 'deep', kind: 'folder' },
|
|
182
|
+
] });
|
|
183
|
+
expect(readFsClipboard(multi)).toEqual(multi);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('migrates the single-entry shape an older tab wrote', () => {
|
|
187
|
+
const legacy = { scope: 'ws\u0000.', path: 'src/a.ts', name: 'a.ts', kind: 'file', mode: 'copy' };
|
|
188
|
+
expect(readFsClipboard(legacy)).toEqual(clip());
|
|
189
|
+
});
|
|
190
|
+
|
|
168
191
|
test('rejects a path that names no child of the listing root', () => {
|
|
169
192
|
// Every one of these would resolve outside the folder the entry claims.
|
|
170
193
|
for (const path of ['.', '', '..', 'a/../b', '/etc/passwd', 'a//b']) {
|
|
171
|
-
expect(readFsClipboard(clip({ path }))).toBeNull();
|
|
194
|
+
expect(readFsClipboard(clip({ entries: [{ path, name: 'x', kind: 'file' }] }))).toBeNull();
|
|
172
195
|
}
|
|
173
196
|
});
|
|
174
197
|
|
|
@@ -178,5 +201,7 @@ describe('readFsClipboard', () => {
|
|
|
178
201
|
expect(readFsClipboard({ path: 'a.ts', name: 'a.ts', scope: 's', kind: 'file' })).toBeNull();
|
|
179
202
|
expect(readFsClipboard({ path: 'a.ts', name: 'a.ts', scope: 's', mode: 'copy' })).toBeNull();
|
|
180
203
|
expect(readFsClipboard({ path: 'a.ts', name: 'a.ts', scope: 's', kind: 'file', mode: 'move' })).toBeNull();
|
|
204
|
+
expect(readFsClipboard({ scope: 's', entries: [], mode: 'copy' })).toBeNull();
|
|
205
|
+
expect(readFsClipboard({ scope: 's', entries: [{ path: 'a.ts', name: 'a.ts', kind: 'link' }], mode: 'copy' })).toBeNull();
|
|
181
206
|
});
|
|
182
207
|
});
|
|
@@ -20,17 +20,30 @@
|
|
|
20
20
|
* user copied somewhere else.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
export interface
|
|
25
|
-
/** The `\0`-joined `root\0repo` the path is relative to. */
|
|
26
|
-
scope: string;
|
|
23
|
+
/** One entry a Cut or a Copy put on the clipboard. */
|
|
24
|
+
export interface FsClipboardEntry {
|
|
27
25
|
/** Path relative to the listed root; never `.` — the root itself cannot be moved. */
|
|
28
26
|
path: string;
|
|
29
27
|
name: string;
|
|
30
28
|
kind: 'file' | 'folder';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What a Cut or a Copy put on the clipboard: one entry, or a whole selection. */
|
|
32
|
+
export interface FsClipboard {
|
|
33
|
+
/** The `\0`-joined `root\0repo` the paths are relative to. */
|
|
34
|
+
scope: string;
|
|
35
|
+
/** The entries in the order they were selected; never empty. */
|
|
36
|
+
entries: FsClipboardEntry[];
|
|
31
37
|
mode: 'copy' | 'cut';
|
|
32
38
|
}
|
|
33
39
|
|
|
40
|
+
/** The label a Paste row shows for a multi-entry clipboard. */
|
|
41
|
+
export function clipboardLabel(clip: FsClipboard | null): string | null {
|
|
42
|
+
if (!clip) return null;
|
|
43
|
+
if (clip.entries.length === 1) return clip.entries[0]!.name;
|
|
44
|
+
return `${clip.entries.length} items`;
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
/** The scope key a panel's listing uses: `${rootPath}\0${repo}`. */
|
|
35
48
|
export function fsClipboardScope(rootPath: string | undefined, repo: string): string {
|
|
36
49
|
return `${rootPath ?? ''}\u0000${repo}`;
|
|
@@ -112,13 +125,21 @@ export function dropRefusal(
|
|
|
112
125
|
* route holds the resolved directory.
|
|
113
126
|
*/
|
|
114
127
|
export function pasteRefusal(clip: FsClipboard | null, scope: string, targetDir: string): string | null {
|
|
115
|
-
if (!clip) return 'Nothing to paste';
|
|
128
|
+
if (!clip || clip.entries.length === 0) return 'Nothing to paste';
|
|
116
129
|
if (clip.scope !== scope) return 'The clipboard holds an entry from another workspace';
|
|
117
130
|
// A cut has nothing to do in the folder it is already in — the entry would be
|
|
118
131
|
// renamed to a `copy` name, which is the opposite of what a cut means. The
|
|
119
|
-
// route refuses the same case in the same words.
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
// route refuses the same case in the same words. A multi-entry cut refuses
|
|
133
|
+
// whole if ANY entry already sits there: pasting the rest while silently
|
|
134
|
+
// dropping one is not the operation the user asked for.
|
|
135
|
+
if (clip.mode === 'cut' && clip.entries.some((entry) => targetDir === parentOf(entry.path))) {
|
|
136
|
+
return 'Already in this folder';
|
|
137
|
+
}
|
|
138
|
+
for (const entry of clip.entries) {
|
|
139
|
+
const refusal = transferRefusal(entry, targetDir);
|
|
140
|
+
if (refusal) return refusal;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
122
143
|
}
|
|
123
144
|
|
|
124
145
|
/**
|
|
@@ -167,16 +188,40 @@ export function duplicateName(name: string, kind: 'file' | 'folder', taken: (can
|
|
|
167
188
|
* whose shape is not what Cut/Copy wrote is dropped rather than trusted. The
|
|
168
189
|
* path check is the one that matters: a `.`, a `..` segment or an absolute
|
|
169
190
|
* spelling would name a directory other than the one the entry claims.
|
|
191
|
+
*
|
|
192
|
+
* The single-entry shape from before multi-selection is migrated rather than
|
|
193
|
+
* dropped: a clipboard taken in an older tab must still paste after an update,
|
|
194
|
+
* and the two shapes differ only in nesting.
|
|
170
195
|
*/
|
|
171
196
|
export function readFsClipboard(value: unknown): FsClipboard | null {
|
|
172
197
|
if (typeof value !== 'object' || value === null) return null;
|
|
173
|
-
const clip = value as
|
|
174
|
-
if (typeof clip.scope !== 'string'
|
|
175
|
-
if (clip.kind !== 'file' && clip.kind !== 'folder') return null;
|
|
198
|
+
const clip = value as { scope?: unknown; mode?: unknown; entries?: unknown; path?: unknown; name?: unknown; kind?: unknown };
|
|
199
|
+
if (typeof clip.scope !== 'string') return null;
|
|
176
200
|
if (clip.mode !== 'copy' && clip.mode !== 'cut') return null;
|
|
177
|
-
const
|
|
178
|
-
|
|
201
|
+
const rawEntries = Array.isArray(clip.entries)
|
|
202
|
+
? clip.entries
|
|
203
|
+
: typeof clip.path === 'string'
|
|
204
|
+
? [{ path: clip.path, name: clip.name, kind: clip.kind }]
|
|
205
|
+
: [];
|
|
206
|
+
const entries: FsClipboardEntry[] = [];
|
|
207
|
+
for (const raw of rawEntries) {
|
|
208
|
+
const entry = readEntry(raw);
|
|
209
|
+
if (!entry) return null;
|
|
210
|
+
entries.push(entry);
|
|
211
|
+
}
|
|
212
|
+
if (entries.length === 0) return null;
|
|
213
|
+
return { scope: clip.scope, entries, mode: clip.mode };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** One clipboard entry, or null when its shape or path is not trustworthy. */
|
|
217
|
+
function readEntry(value: unknown): FsClipboardEntry | null {
|
|
218
|
+
if (typeof value !== 'object' || value === null) return null;
|
|
219
|
+
const entry = value as Partial<FsClipboardEntry>;
|
|
220
|
+
if (typeof entry.path !== 'string' || typeof entry.name !== 'string') return null;
|
|
221
|
+
if (entry.kind !== 'file' && entry.kind !== 'folder') return null;
|
|
222
|
+
const segments = entry.path.split('/');
|
|
223
|
+
if (entry.path === '' || entry.path.startsWith('/') || segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {
|
|
179
224
|
return null;
|
|
180
225
|
}
|
|
181
|
-
return {
|
|
226
|
+
return { path: entry.path, name: entry.name, kind: entry.kind };
|
|
182
227
|
}
|