@kabmo-labs/kabmo 0.16.0 → 0.18.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/README.md +2 -2
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +552 -471
- package/dist/client/static/js/index-hp75vsv9.css +1 -0
- package/dist/client/static/js/{index-cpydmygd.js → index-tc09dtca.js} +897 -886
- package/package.json +1 -1
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +143 -0
- package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
- package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
- package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
- package/src/client/components/common/code-surface/extensions.ts +7 -4
- package/src/client/components/common/code-surface/theme.ts +34 -9
- package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
- package/src/client/components/common/code-surface/whitespace.ts +140 -0
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
- package/src/client/components/common/markdown-review/index.tsx +129 -0
- package/src/client/components/common/{server-switcher/index.tsx → server-control/Panel.tsx} +92 -44
- package/src/client/components/common/server-control/index.test.tsx +217 -0
- package/src/client/components/common/server-control/index.tsx +120 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +42 -21
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
- package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +28 -10
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
- package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
- package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
- package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
- package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
- package/src/client/components/settings/Modal.tsx +9 -3
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +38 -44
- package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
- package/src/client/components/settings/categories/McpSettings.tsx +4 -21
- package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
- package/src/client/components/settings/categories/ProjectSettings.tsx +122 -156
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
- package/src/client/components/settings/categories/SkillSettings.tsx +8 -5
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +14 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
- package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +91 -76
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +26 -13
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
- package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
- package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
- package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.test.tsx +189 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
- package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
- package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
- package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
- package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
- package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
- package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
- package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
- package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
- package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +236 -0
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +164 -239
- package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +144 -87
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +188 -0
- package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
- package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
- package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
- package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
- package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
- package/src/client/components/workspace/browser-panel/index.tsx +50 -4
- package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +46 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +29 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
- package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
- package/src/client/components/workspace/diff-panel/changes.ts +28 -12
- package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
- package/src/client/components/workspace/diff-panel/merge.ts +21 -1
- package/src/client/components/workspace/editor/Body.tsx +7 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
- package/src/client/components/workspace/editor/FilePane.tsx +12 -0
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
- package/src/client/components/workspace/editor/index.tsx +25 -22
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
- package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
- package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +18 -2
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
- package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
- package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
- package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
- package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
- package/src/client/components/workspace/file-explorer/index.tsx +21 -20
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
- package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
- package/src/client/data/agent-data/builtin.ts +0 -10
- package/src/client/data/agent-data/orchestrator.ts +0 -45
- package/src/client/data/agent-data/specialist.ts +0 -100
- package/src/client/data/mock/token-usage.ts +170 -120
- package/src/client/data/settings/omp-schema.json +123 -4
- package/src/client/data/settings/project.ts +9 -28
- package/src/client/data/settings/skill.ts +6 -32
- package/src/client/hooks/browser/use-annotate.test.ts +143 -0
- package/src/client/hooks/browser/use-annotate.ts +98 -0
- package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
- package/src/client/hooks/browser/use-close-tab.ts +67 -0
- package/src/client/hooks/browser/use-screencast.ts +13 -1
- package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
- package/src/client/hooks/chat/composer/browser-context.ts +40 -16
- package/src/client/hooks/chat/composer/items.test.ts +1 -1
- package/src/client/hooks/chat/composer/review-context.ts +38 -0
- package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
- package/src/client/hooks/chat/composer/use-draft.ts +31 -2
- package/src/client/hooks/chat/timeline/pending-model.ts +28 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
- package/src/client/hooks/editor/use-document-annotations.ts +124 -0
- package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
- package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
- package/src/client/hooks/editor/use-preview-review.ts +148 -0
- package/src/client/hooks/settings/agents.ts +149 -0
- package/src/client/hooks/settings/crud-list.test.ts +28 -6
- package/src/client/hooks/settings/crud-list.ts +96 -57
- package/src/client/hooks/settings/omp-config.ts +164 -0
- package/src/client/hooks/settings/projects/index.ts +294 -0
- package/src/client/hooks/settings/projects.test.ts +237 -0
- package/src/client/hooks/settings/skill-catalog.ts +101 -9
- package/src/client/hooks/settings/skill-git-import.ts +153 -0
- package/src/client/hooks/settings/useTokenUsage.ts +125 -0
- package/src/client/hooks/settings/write-feedback.test.ts +104 -0
- package/src/client/hooks/settings/write-feedback.ts +63 -0
- package/src/client/hooks/shell/servers.test.ts +166 -0
- package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/updates/index.test.ts +100 -1
- package/src/client/hooks/ui/updates/index.ts +50 -0
- package/src/client/hooks/ui/updates/notes.test.ts +138 -0
- package/src/client/hooks/ui/updates/notes.ts +57 -0
- package/src/client/hooks/ui/updates/shell-download.ts +1 -1
- package/src/client/hooks/ui/updates/shell-update.ts +2 -6
- package/src/client/hooks/workspace/file-row-drag.ts +41 -0
- package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
- package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
- package/src/client/hooks/workspace/root-drop-target.ts +77 -0
- package/src/client/hooks/workspace/unfolded-chains.ts +165 -0
- package/src/client/lib/browser/element-at.test.ts +229 -0
- package/src/client/lib/browser/element-at.ts +139 -0
- package/src/client/lib/desktop/dropped-paths.ts +1 -1
- package/src/client/lib/desktop/titlebar.test.ts +12 -3
- package/src/client/lib/desktop/titlebar.ts +1 -1
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/lib/shell/desktop.ts +117 -0
- package/src/client/lib/shell/servers.ts +75 -0
- package/src/client/lib/shell/transport.ts +216 -0
- package/src/client/main.tsx +9 -0
- package/src/client/tailwind.css +65 -0
- package/src/server/lib/btw/lifecycle.server.ts +2 -2
- package/src/server/lib/db/schema.ts +7 -0
- package/src/server/lib/db/seed-terminal.test.ts +4 -0
- package/src/server/lib/fs/git-merge-conflict.test.ts +14 -1
- package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
- package/src/server/lib/omp/config/agents.ts +231 -61
- package/src/server/lib/omp/config/definitions.test.ts +9 -105
- package/src/server/lib/omp/config/extensions.ts +16 -7
- package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
- package/src/server/lib/omp/config/skill-sources.ts +49 -0
- package/src/server/lib/omp/config/skills-git-install.ts +155 -0
- package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
- package/src/server/lib/omp/config/skills-git.test.ts +220 -0
- package/src/server/lib/omp/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/process.ts +11 -14
- package/src/server/lib/omp/rpc/session-commands.ts +6 -3
- package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
- package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
- package/src/server/lib/omp/rpc/utility.ts +12 -0
- package/src/server/lib/review/schema.server.ts +45 -0
- package/src/server/lib/review/store.server.ts +138 -0
- package/src/server/lib/terminal/attach-replay.test.ts +132 -0
- package/src/server/lib/terminal/output.test.ts +166 -0
- package/src/server/lib/terminal/output.ts +104 -0
- package/src/server/lib/terminal/runtime.server.ts +5 -0
- package/src/server/lib/terminal/send-result.test.ts +33 -0
- package/src/server/lib/terminal/send-result.ts +32 -0
- package/src/server/lib/terminal/session.server.ts +45 -11
- package/src/server/lib/terminal/store-liveness.test.ts +4 -0
- package/src/server/lib/updates/active-notes.test.ts +149 -0
- package/src/server/lib/updates/active-notes.ts +75 -0
- package/src/server/lib/updates/changelog-file.ts +42 -11
- package/src/server/lib/updates/changelog.test.ts +15 -1
- package/src/server/lib/updates/omp.ts +42 -15
- package/src/server/lib/updates/release-url.ts +27 -1
- package/src/server/lib/usage/index-parse.test.ts +200 -0
- package/src/server/lib/usage/index-parse.ts +178 -0
- package/src/server/lib/usage/index-query.server.ts +248 -0
- package/src/server/lib/usage/index-scan.server.ts +343 -0
- package/src/server/lib/usage/index-schema.server.ts +82 -0
- package/src/server/lib/usage/index.test.ts +234 -0
- package/src/server/lib/usage/providers.server.ts +4 -53
- package/src/server/lib/workspace/project-model.server.test.ts +102 -0
- package/src/server/lib/workspace/project-model.server.ts +47 -0
- package/src/server/lib/workspace/project-patch.server.ts +156 -0
- package/src/server/routes/agent/new.ts +8 -1
- package/src/server/routes/browser/index.ts +3 -0
- package/src/server/routes/browser/stream.ts +31 -2
- package/src/server/routes/browser/tabs.test.ts +94 -0
- package/src/server/routes/browser/tabs.ts +85 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/review/bindings.ts +11 -0
- package/src/server/routes/review/index.ts +127 -0
- package/src/server/routes/review/routes.test.ts +191 -0
- package/src/server/routes/settings/agents.test.ts +180 -0
- package/src/server/routes/settings/agents.ts +99 -94
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/projects.ts +53 -19
- package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
- package/src/server/routes/settings/settings-store-routes.test.ts +11 -115
- package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
- package/src/server/routes/settings/skills.test.ts +225 -0
- package/src/server/routes/settings/skills.ts +18 -15
- package/src/server/routes/telemetry/tokens.test.ts +145 -0
- package/src/server/routes/telemetry/tokens.ts +70 -149
- package/src/server/routes/terminal/ws.ts +6 -5
- package/src/server/routes/updates/index.ts +2 -0
- package/src/server/routes/updates/notes.ts +34 -0
- package/src/server/routes/updates/routes.test.ts +49 -0
- package/src/shared/lib/browser/annotate.test.ts +283 -0
- package/src/shared/lib/browser/annotate.ts +231 -0
- package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
- package/src/shared/lib/browser/frame-gate.test.ts +91 -0
- package/src/shared/lib/browser/frame-gate.ts +69 -0
- package/src/shared/lib/browser/frame-params.test.ts +43 -0
- package/src/shared/lib/browser/frame-params.ts +60 -0
- package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
- package/src/shared/lib/browser/frame-pipeline.ts +80 -0
- package/src/shared/lib/browser/page-context.ts +60 -4
- package/src/shared/lib/browser/snapshot.test.ts +115 -0
- package/src/shared/lib/browser/snapshot.ts +112 -0
- package/src/shared/lib/browser/tab-close.test.ts +74 -0
- package/src/shared/lib/browser/tab-close.ts +77 -0
- package/src/shared/lib/browser/viewer.ts +45 -26
- package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
- package/src/shared/lib/chat/tool/artifact.ts +55 -20
- package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
- package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
- package/src/shared/lib/chat/tool/minimized.ts +64 -0
- package/src/shared/lib/chat/tool/summary.test.ts +28 -8
- package/src/shared/lib/chat/tool/summary.ts +3 -32
- package/src/shared/lib/fs/folder-chain.test.ts +81 -1
- package/src/shared/lib/fs/folder-chain.ts +84 -0
- package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
- package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
- package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
- package/src/shared/lib/markdown/blocks/scan.ts +100 -0
- package/src/shared/lib/markdown/blocks/types.ts +62 -0
- package/src/shared/lib/markdown/marked.ts +58 -147
- package/src/shared/lib/markdown/math-extensions.ts +168 -0
- package/src/shared/lib/markdown/review/prompt.ts +77 -0
- package/src/shared/lib/markdown/review/reconcile.ts +55 -0
- package/src/shared/lib/markdown/review/review.test.ts +96 -0
- package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
- package/src/shared/lib/markdown/xml-sections.ts +139 -0
- package/src/shared/lib/models/provider/label.ts +57 -0
- package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
- package/src/shared/lib/omp/config/agent-file.ts +43 -0
- package/src/shared/lib/omp/config/row-value.test.ts +95 -0
- package/src/shared/lib/omp/config/row-value.ts +97 -0
- package/src/shared/lib/omp/config/schema.test.ts +66 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +48 -47
- package/src/shared/lib/omp/rpc/frame.ts +49 -40
- package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
- package/src/shared/lib/omp/session/job-progress.ts +31 -0
- package/src/shared/lib/omp/session/proc.ts +5 -0
- package/src/shared/lib/omp/session/wait.ts +5 -0
- package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
- package/src/shared/lib/ui/menu-anchor.ts +89 -0
- package/src/shared/lib/ui/mobile-overlay.ts +61 -0
- package/src/shared/lib/ui/svg-scope.test.ts +97 -0
- package/src/shared/lib/ui/svg-scope.ts +134 -0
- package/src/shared/lib/usage/breakdown.test.ts +197 -0
- package/src/shared/lib/usage/breakdown.ts +241 -0
- package/src/shared/lib/usage/range.test.ts +204 -0
- package/src/shared/lib/usage/range.ts +240 -0
- package/src/shared/lib/usage/view.test.ts +85 -0
- package/src/shared/lib/usage/view.ts +74 -0
- package/src/shared/lib/workspace/project-accent.test.ts +69 -0
- package/src/shared/lib/workspace/project-accent.ts +63 -0
- package/src/shared/lib/workspace/project-icon.ts +40 -0
- package/src/shared/lib/workspace/project-model.test.ts +79 -0
- package/src/shared/lib/workspace/project-model.ts +64 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/skill.ts +53 -3
- package/src/shared/types/settings/state.ts +4 -3
- package/src/shared/types/settings/write.ts +6 -0
- package/src/shared/types/tokenUsage.ts +128 -21
- package/src/shared/types/updates.ts +20 -0
- package/src/test-support/file-explorer-disk.test-util.ts +25 -1
- package/src/test-support/file-explorer-drag.test-util.ts +88 -0
- package/src/test-support/file-explorer.test-util.ts +47 -47
- package/dist/client/static/js/index-fjnq2z2d.css +0 -1
- package/src/client/components/common/code-surface/indent-guide.ts +0 -104
- package/src/client/components/common/server-switcher/index.test.tsx +0 -150
- package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
- package/src/client/hooks/desktop/servers.test.ts +0 -73
- package/src/client/lib/desktop/bridge.ts +0 -203
- package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
- package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
- package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
- package/src/server/lib/omp/session/usage/shaping.ts +0 -130
- package/src/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
- package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
|
@@ -1,128 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Native omp agents — the definitions omp itself loads.
|
|
8
|
+
*
|
|
9
|
+
* A definition is a markdown file with frontmatter, and the FILE is the only
|
|
10
|
+
* thing omp reads: user agents at `~/.omp/agent/agents/*.md`, project agents at
|
|
11
|
+
* `<workspace>/.omp/agents/*.md`. The panel therefore reads and writes those
|
|
12
|
+
* files directly. It used to keep a mirrored list in Kabmo's SQLite and POST
|
|
13
|
+
* into it, which made "Create Agent" a button that reported success and changed
|
|
14
|
+
* nothing the agent could see.
|
|
15
|
+
*
|
|
16
|
+
* Project agents stay read-only: that directory belongs to the workspace, and a
|
|
17
|
+
* console that rewrites another checkout's definitions is a surprise. The route
|
|
18
|
+
* still lists them, flagged `sourceRoot: 'project'`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
1
21
|
import { json } from '@/server/lib/remix-compat';
|
|
2
22
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
3
23
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
4
|
-
import { getDb } from '@/server/db.server';
|
|
5
24
|
import { DEFAULT_AGENTS_LIST } from '@/client/data/agent-data';
|
|
6
25
|
import { isMockMode } from '@/server/mock.server';
|
|
26
|
+
import { join } from 'path';
|
|
27
|
+
import {
|
|
28
|
+
deleteAgentDefinition,
|
|
29
|
+
discoverNativeAgents,
|
|
30
|
+
writeAgentDefinition,
|
|
31
|
+
type DiscoveredAgent,
|
|
32
|
+
} from '@/server/lib/omp/config/agents';
|
|
33
|
+
import { agentFileBaseName } from '@/shared/lib/omp/config/agent-file';
|
|
34
|
+
import { resolveRoot } from '@/server/lib/fs/root';
|
|
7
35
|
import type { AgentItem } from '@/shared/types';
|
|
8
|
-
import { createSettingsListStore } from '@/server/lib/db/settings-store';
|
|
9
|
-
import { deleteAgentDefinition, discoverNativeAgents, writeAgentDefinition, type DiscoveredAgent } from '@/server/lib/omp/config/agents';
|
|
10
|
-
|
|
11
|
-
const agentsStore = createSettingsListStore<AgentItem>({
|
|
12
|
-
key: 'omp_agents',
|
|
13
|
-
mockDefaults: DEFAULT_AGENTS_LIST,
|
|
14
|
-
idOf: (agent) => agent.id,
|
|
15
|
-
singular: 'agent',
|
|
16
|
-
plural: 'agents',
|
|
17
|
-
});
|
|
18
36
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
* Native agents are surfaced as read-only built-ins (isBuiltIn) so the UI
|
|
22
|
-
* lists them alongside app-local custom agents without offering edits that
|
|
23
|
-
* would silently not persist.
|
|
24
|
-
*/
|
|
25
|
-
function nativeToAgentItem(agent: DiscoveredAgent): AgentItem & { sourceRoot: string } {
|
|
37
|
+
/** Project agents are listed but never written from here. */
|
|
38
|
+
function toAgentItem(agent: DiscoveredAgent): AgentItem {
|
|
26
39
|
return {
|
|
27
40
|
id: agent.id,
|
|
28
41
|
name: agent.name,
|
|
29
|
-
description: agent.description || `
|
|
42
|
+
description: agent.description || `omp agent (${agent.sourceRoot})`,
|
|
30
43
|
scope: agent.sourceRoot === 'user' ? 'user' : 'project',
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
topP: agent.topP,
|
|
44
|
+
...(agent.tools ? { tools: agent.tools } : {}),
|
|
45
|
+
...(agent.spawns ? { spawns: agent.spawns } : {}),
|
|
46
|
+
...(agent.model ? { model: agent.model } : {}),
|
|
47
|
+
...(agent.thinkingLevel ? { thinkingLevel: agent.thinkingLevel } : {}),
|
|
36
48
|
systemPrompt: agent.systemPrompt,
|
|
37
|
-
isBuiltIn:
|
|
49
|
+
isBuiltIn: agent.sourceRoot !== 'user',
|
|
50
|
+
filePath: agent.filePath,
|
|
51
|
+
fileName: agentFileBaseName(agent.filePath),
|
|
38
52
|
sourceRoot: agent.sourceRoot,
|
|
39
53
|
};
|
|
40
54
|
}
|
|
41
55
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return
|
|
56
|
+
async function readList(projectRoot: string | null): Promise<AgentItem[]> {
|
|
57
|
+
const projectDir = projectRoot
|
|
58
|
+
? join(await resolveRoot(projectRoot, ''), '.omp', 'agents')
|
|
59
|
+
: undefined;
|
|
60
|
+
return (await discoverNativeAgents(projectDir)).map(toAgentItem);
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
export async function loader({ request }: LoaderFunctionArgs) {
|
|
64
|
+
const mock = isMockMode();
|
|
65
|
+
if (mock) return json({ agents: DEFAULT_AGENTS_LIST, isMock: true });
|
|
50
66
|
try {
|
|
51
|
-
const db = await getDb();
|
|
52
67
|
const url = new URL(request.url);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return json({ agents: await mergeAgents(agents), isMock: mock });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return json({ agents, isMock: mock });
|
|
62
|
-
} catch (error: any) {
|
|
63
|
-
return json({ error: error.message, agents: isMockMode() ? DEFAULT_AGENTS_LIST : [], isMock: isMockMode() }, { status: 500 });
|
|
68
|
+
const root = url.searchParams.get('root');
|
|
69
|
+
return json({ agents: await readList(root), isMock: false });
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
+
return json({ error: message, agents: [], isMock: false }, { status: 500 });
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
export async function action({ request, params }: ActionFunctionArgs) {
|
|
77
|
+
if (request.method !== 'POST') {
|
|
78
|
+
return methodNotAllowed({ request, params });
|
|
79
|
+
}
|
|
80
|
+
if (isMockMode()) {
|
|
81
|
+
return json({ error: 'Agent files cannot be written in mock mode' }, { status: 400 });
|
|
82
|
+
}
|
|
68
83
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const url = new URL(request.url);
|
|
73
|
-
const id = url.searchParams.get('id');
|
|
74
|
-
if (!id) {
|
|
75
|
-
return json({ error: 'id is required' }, { status: 400 });
|
|
76
|
-
}
|
|
77
|
-
if (id.startsWith('omp-')) {
|
|
78
|
-
return json({ error: 'Native omp agents are read-only in Kabmo' }, { status: 403 });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const list = await agentsStore.remove(db, id);
|
|
82
|
-
return json({ success: true, agents: list });
|
|
84
|
+
const body: unknown = await request.json();
|
|
85
|
+
if (typeof body !== 'object' || body === null || !('type' in body)) {
|
|
86
|
+
return json({ error: 'type is required (write or delete)' }, { status: 400 });
|
|
83
87
|
}
|
|
88
|
+
const root = 'root' in body && typeof body.root === 'string' ? body.root : null;
|
|
84
89
|
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// Native agent file write: { type: "write_native", fileName, ...definition }
|
|
89
|
-
if (body.type === 'write_native') {
|
|
90
|
-
if (isMockMode()) return json({ error: 'Native agent writes are unavailable in mock mode' }, { status: 400 });
|
|
91
|
-
const written = await writeAgentDefinition({
|
|
92
|
-
fileName: String(body.fileName ?? ''),
|
|
93
|
-
name: typeof body.name === 'string' ? body.name : undefined,
|
|
94
|
-
description: typeof body.description === 'string' ? body.description : undefined,
|
|
95
|
-
mode: typeof body.mode === 'string' ? body.mode : undefined,
|
|
96
|
-
model: typeof body.model === 'string' ? body.model : undefined,
|
|
97
|
-
thinking: typeof body.thinking === 'string' ? body.thinking : undefined,
|
|
98
|
-
temperature: typeof body.temperature === 'number' ? body.temperature : null,
|
|
99
|
-
topP: typeof body.topP === 'number' ? body.topP : null,
|
|
100
|
-
tools: Array.isArray(body.tools) ? body.tools.map(String) : undefined,
|
|
101
|
-
systemPrompt: String(body.systemPrompt ?? ''),
|
|
102
|
-
});
|
|
103
|
-
return json({ success: true, path: written.path, agents: await mergeAgents([]) });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Native agent file delete: { type: "delete_native", fileName }
|
|
107
|
-
if (body.type === 'delete_native') {
|
|
108
|
-
if (isMockMode()) return json({ error: 'Native agent deletes are unavailable in mock mode' }, { status: 400 });
|
|
109
|
-
const removed = await deleteAgentDefinition(String(body.fileName ?? ''));
|
|
110
|
-
if (!removed) return json({ error: 'Native agent file not found' }, { status: 404 });
|
|
111
|
-
return json({ success: true, agents: await mergeAgents([]) });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!Array.isArray(body) && !Array.isArray(body.agents) && body.agent
|
|
115
|
-
&& typeof body.agent.id === 'string' && body.agent.id.startsWith('omp-')) {
|
|
116
|
-
return json({ error: 'Native omp agents are read-only in Kabmo' }, { status: 403 });
|
|
90
|
+
if (body.type === 'delete') {
|
|
91
|
+
if (!('fileName' in body) || typeof body.fileName !== 'string') {
|
|
92
|
+
return json({ error: 'fileName is required' }, { status: 400 });
|
|
117
93
|
}
|
|
94
|
+
const removed = await deleteAgentDefinition(body.fileName);
|
|
95
|
+
if (!removed) return json({ error: `No agent file named “${body.fileName}”` }, { status: 404 });
|
|
96
|
+
return json({ success: true, agents: await readList(root) });
|
|
97
|
+
}
|
|
118
98
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
99
|
+
if (body.type === 'write') {
|
|
100
|
+
const fileName = 'fileName' in body && typeof body.fileName === 'string' ? body.fileName : '';
|
|
101
|
+
const systemPrompt = 'systemPrompt' in body && typeof body.systemPrompt === 'string' ? body.systemPrompt : '';
|
|
102
|
+
const text = (key: string): string | undefined => (
|
|
103
|
+
key in body && typeof body[key as keyof typeof body] === 'string'
|
|
104
|
+
? String(body[key as keyof typeof body])
|
|
105
|
+
: undefined
|
|
106
|
+
);
|
|
107
|
+
const tools = 'tools' in body && Array.isArray(body.tools)
|
|
108
|
+
? body.tools.filter((item): item is string => typeof item === 'string')
|
|
109
|
+
: undefined;
|
|
110
|
+
const written = await writeAgentDefinition({
|
|
111
|
+
fileName,
|
|
112
|
+
name: text('name') ?? fileName,
|
|
113
|
+
description: text('description') ?? '',
|
|
114
|
+
...(text('model') ? { model: text('model') } : {}),
|
|
115
|
+
...(text('thinkingLevel') ? { thinkingLevel: text('thinkingLevel') } : {}),
|
|
116
|
+
...(text('spawns') ? { spawns: text('spawns') } : {}),
|
|
117
|
+
...(tools ? { tools } : {}),
|
|
118
|
+
systemPrompt,
|
|
119
|
+
});
|
|
120
|
+
// A rename writes the new file and removes the old one, so one definition
|
|
121
|
+
// cannot survive under two names.
|
|
122
|
+
const previous = 'previousFileName' in body && typeof body.previousFileName === 'string'
|
|
123
|
+
? body.previousFileName
|
|
124
|
+
: '';
|
|
125
|
+
if (previous && previous !== fileName) await deleteAgentDefinition(previous);
|
|
126
|
+
return json({ success: true, path: written.path, agents: await readList(root) });
|
|
122
127
|
}
|
|
123
128
|
|
|
124
|
-
return
|
|
125
|
-
} catch (error
|
|
126
|
-
return json({ error: error.message }, { status:
|
|
129
|
+
return json({ error: `Unknown action “${String(body.type)}”` }, { status: 400 });
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 });
|
|
127
132
|
}
|
|
128
133
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MCP settings route's write contract: every mutating answer carries the
|
|
8
|
+
* list it just changed.
|
|
9
|
+
*
|
|
10
|
+
* WHY this has its own suite: three branches returned `json({ servers:
|
|
11
|
+
* mergeServers(...) })` WITHOUT `await`. JSON.stringify turns a Promise into
|
|
12
|
+
* `{}` rather than failing, so the response was a 200 with `servers: {}` — the
|
|
13
|
+
* save landed in `mcp.json` and on disk, while the panel reading its own answer
|
|
14
|
+
* emptied the list. A missing `await` is invisible to the type checker (the
|
|
15
|
+
* value is `unknown` to `json()`) and invisible at runtime except as an empty
|
|
16
|
+
* collection, so every branch that reports the list is pinned here.
|
|
17
|
+
*
|
|
18
|
+
* Everything runs against a temp agent dir: no case may spawn `omp` or touch the
|
|
19
|
+
* developer's real `~/.omp`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
23
|
+
import fs from 'fs';
|
|
24
|
+
import os from 'os';
|
|
25
|
+
import path from 'path';
|
|
26
|
+
import { closeDb } from '@/server/db.server';
|
|
27
|
+
import { action as mcpAction, loader as mcpLoader } from '@/server/routes/settings/mcp';
|
|
28
|
+
import type { McpServerItem } from '@/shared/types';
|
|
29
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
30
|
+
|
|
31
|
+
const ROOT = path.join(os.tmpdir(), 'omc-settings-mcp-route-test');
|
|
32
|
+
const AGENT_DIR = path.join(ROOT, 'agent');
|
|
33
|
+
const MCP_JSON = path.join(AGENT_DIR, 'mcp.json');
|
|
34
|
+
const API = 'http://localhost/api/settings';
|
|
35
|
+
|
|
36
|
+
beforeEach(async () => {
|
|
37
|
+
// CLOSE the handle before removing its directory, never drop the slot.
|
|
38
|
+
// `globalThis.__kabmoDb = undefined` leaves an open `bun:sqlite` connection
|
|
39
|
+
// holding `db.sqlite`, and `removeDir` then spins its full 5s retry window
|
|
40
|
+
// before throwing — which is what made every case in this file fail as
|
|
41
|
+
// "a beforeEach/afterEach hook timed out for this test" on Windows, where the
|
|
42
|
+
// lock is real rather than advisory.
|
|
43
|
+
await closeDb();
|
|
44
|
+
removeDir(ROOT);
|
|
45
|
+
fs.mkdirSync(AGENT_DIR, { recursive: true });
|
|
46
|
+
Bun.env.PI_CODING_AGENT_DIR = AGENT_DIR;
|
|
47
|
+
Bun.env.KABMO_DB_PATH = path.join(ROOT, 'db.sqlite');
|
|
48
|
+
Bun.env.SYNC_WORKSPACE = 'false';
|
|
49
|
+
delete Bun.env.MOCK;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterAll(async () => {
|
|
53
|
+
await closeDb();
|
|
54
|
+
delete Bun.env.PI_CODING_AGENT_DIR;
|
|
55
|
+
delete Bun.env.KABMO_DB_PATH;
|
|
56
|
+
delete Bun.env.SYNC_WORKSPACE;
|
|
57
|
+
removeDir(ROOT);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
type Handler = (args: never) => unknown;
|
|
61
|
+
|
|
62
|
+
function call(handler: Handler, request: Request): Promise<Response> {
|
|
63
|
+
return handler({ request, params: {} } as never) as Promise<Response>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function send(method: string, body?: unknown): Request {
|
|
67
|
+
return new Request(`${API}/mcp`, {
|
|
68
|
+
method,
|
|
69
|
+
...(body === undefined ? {} : { body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function server(name: string): McpServerItem {
|
|
74
|
+
return {
|
|
75
|
+
id: `mcp-${name}`,
|
|
76
|
+
name,
|
|
77
|
+
scope: 'every-project',
|
|
78
|
+
enabled: true,
|
|
79
|
+
reachType: 'command',
|
|
80
|
+
commandArgs: ['bunx', '@modelcontextprotocol/server-everything'],
|
|
81
|
+
envVars: [],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
describe('MCP route write answers', () => {
|
|
86
|
+
test('a create answers with the list, not an empty object', async () => {
|
|
87
|
+
const res = await call(mcpAction, send('POST', { server: server('first') }));
|
|
88
|
+
expect(res.status).toBe(200);
|
|
89
|
+
const body = await res.json();
|
|
90
|
+
expect(Array.isArray(body.servers)).toBe(true);
|
|
91
|
+
expect(body.servers.map((item: McpServerItem) => item.name)).toEqual(['first']);
|
|
92
|
+
// The file is the record omp reads, so both sides must agree.
|
|
93
|
+
expect(JSON.parse(fs.readFileSync(MCP_JSON, 'utf8')).mcpServers.first.command).toBe('bunx');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('a legacy { scope: "user", name, server } write answers with the list', async () => {
|
|
97
|
+
const res = await call(mcpAction, send('POST', {
|
|
98
|
+
scope: 'user',
|
|
99
|
+
name: 'legacy',
|
|
100
|
+
server: server('legacy'),
|
|
101
|
+
}));
|
|
102
|
+
expect(res.status).toBe(200);
|
|
103
|
+
const body = await res.json();
|
|
104
|
+
expect(Array.isArray(body.servers)).toBe(true);
|
|
105
|
+
expect(body.servers.map((item: McpServerItem) => item.name)).toEqual(['legacy']);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('a whole-list PUT answers with the list', async () => {
|
|
109
|
+
const res = await call(mcpAction, send('PUT', { servers: [server('a'), server('b')] }));
|
|
110
|
+
expect(res.status).toBe(200);
|
|
111
|
+
const body = await res.json();
|
|
112
|
+
expect(Array.isArray(body.servers)).toBe(true);
|
|
113
|
+
expect(body.servers.map((item: McpServerItem) => item.name).sort()).toEqual(['a', 'b']);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('a delete answers with the list it left behind', async () => {
|
|
117
|
+
await call(mcpAction, send('POST', { server: server('gone') }));
|
|
118
|
+
const list = await (await call(mcpLoader, new Request(`${API}/mcp`))).json();
|
|
119
|
+
const id = list.servers[0].id as string;
|
|
120
|
+
|
|
121
|
+
const res = await call(mcpAction, new Request(`${API}/mcp?id=${encodeURIComponent(id)}`, { method: 'DELETE' }));
|
|
122
|
+
expect(res.status).toBe(200);
|
|
123
|
+
const body = await res.json();
|
|
124
|
+
expect(Array.isArray(body.servers)).toBe(true);
|
|
125
|
+
expect(body.servers).toEqual([]);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('a rename leaves one entry, not two', async () => {
|
|
129
|
+
await call(mcpAction, send('POST', { server: server('before') }));
|
|
130
|
+
await call(mcpAction, send('POST', { server: { ...server('after'), id: 'omp-user-before' } }));
|
|
131
|
+
const body = await (await call(mcpLoader, new Request(`${API}/mcp`))).json();
|
|
132
|
+
expect(body.servers.map((item: McpServerItem) => item.name)).toEqual(['after']);
|
|
133
|
+
expect(Object.keys(JSON.parse(fs.readFileSync(MCP_JSON, 'utf8')).mcpServers)).toEqual(['after']);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -207,13 +207,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
207
207
|
if (body.scope === 'user' && typeof body.name === 'string' && body.server) {
|
|
208
208
|
await writeUserMcpServer(body.name, toNativeServer(body.server));
|
|
209
209
|
const custom = await readCustomServers(db);
|
|
210
|
-
return json({ success: true, servers: mergeServers(custom) });
|
|
210
|
+
return json({ success: true, servers: await mergeServers(custom) });
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
if (Array.isArray(body) || Array.isArray(body.servers)) {
|
|
214
214
|
const updatedServers: McpServerItem[] = Array.isArray(body) ? body : body.servers;
|
|
215
215
|
await writeCustomServers(db, updatedServers);
|
|
216
|
-
return json({ success: true, servers: isMockMode() ? updatedServers : mergeServers(updatedServers) });
|
|
216
|
+
return json({ success: true, servers: isMockMode() ? updatedServers : await mergeServers(updatedServers) });
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
if (!body.server) return json({ error: 'server is required' }, { status: 400 });
|
|
@@ -235,23 +235,31 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
const mock = isMockMode();
|
|
238
|
+
const previousName = previousNativeName(server.id, server.name);
|
|
238
239
|
if (!mock) {
|
|
239
240
|
if (server.scope === 'this-project') {
|
|
240
241
|
if (!projectPath) {
|
|
241
242
|
return json({ error: 'A registered projectPath is required for project-scoped servers' }, { status: 400 });
|
|
242
243
|
}
|
|
243
|
-
await writeProjectMcpServer(projectPath, server.name, toNativeServer(server),
|
|
244
|
+
await writeProjectMcpServer(projectPath, server.name, toNativeServer(server), previousName);
|
|
244
245
|
} else {
|
|
245
|
-
await writeUserMcpServer(server.name, toNativeServer(server), undefined,
|
|
246
|
+
await writeUserMcpServer(server.name, toNativeServer(server), undefined, previousName);
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
// Upsert the DB row so ids/enabled stay stable across scope changes.
|
|
250
251
|
const storedServer: McpServerItem = projectPath ? { ...server, projectPath } : server;
|
|
251
|
-
const
|
|
252
|
+
const upserted = await mcpStore.upsertItem(db, storedServer, { absent: mock ? DEFAULT_MCP_SERVERS : [] });
|
|
253
|
+
// A RENAME leaves the old name behind as a second row: the native file is
|
|
254
|
+
// rewritten under the new name, but the app-local row that mirrored the
|
|
255
|
+
// old one still answers the old name and the panel lists both. The row is
|
|
256
|
+
// the one thing the native write cannot clean up.
|
|
257
|
+
const custom = previousName
|
|
258
|
+
? upserted.filter((entry) => entry.name.toLowerCase() !== previousName.toLowerCase())
|
|
259
|
+
: upserted;
|
|
252
260
|
await writeCustomServers(db, custom);
|
|
253
261
|
|
|
254
|
-
return json({ success: true, servers: mock ? custom : mergeServers(custom, projectPath ?? undefined) });
|
|
262
|
+
return json({ success: true, servers: mock ? custom : await mergeServers(custom, projectPath ?? undefined) });
|
|
255
263
|
}
|
|
256
264
|
|
|
257
265
|
return methodNotAllowed({ request, params });
|
|
@@ -2,13 +2,25 @@ import { json } from '@/server/lib/remix-compat';
|
|
|
2
2
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
3
3
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
4
4
|
import { getDb } from '@/server/db.server';
|
|
5
|
-
import {
|
|
6
|
-
import { deleteWorkspaceFolder,
|
|
5
|
+
import { PROJECT_ACCENT_OPTIONS } from '@/shared/lib/workspace/project-accent';
|
|
6
|
+
import { deleteWorkspaceFolder, projectConfigFromFolder, updateWorkspaceFolder } from '@/shared/lib/workspace/project-settings';
|
|
7
7
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
8
8
|
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
9
|
+
import { syncDiscoveryRootsWatch } from '@/server/lib/omp/config/roots-watch.server';
|
|
10
|
+
import { prepareProjectPatch } from '@/server/lib/workspace/project-patch.server';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The fields this route accepts from a project form. Anything else in the body
|
|
14
|
+
* (an `id`, a `path` read back from the list) is derived from the row: `path` is
|
|
15
|
+
* the API's name for `project_path`, and a client echoing the whole project back
|
|
16
|
+
* must not be able to write a column through a synonym.
|
|
17
|
+
*
|
|
18
|
+
* The default model is NOT served from here. It is one of `provider:modelId`
|
|
19
|
+
* from the live catalog (`/api/models`), and this route used to answer with a
|
|
20
|
+
* hardcoded list of display names that no session could ever start on.
|
|
21
|
+
*/
|
|
22
|
+
function projectPatchBody(project: Record<string, unknown>): Record<string, unknown> {
|
|
23
|
+
return {
|
|
12
24
|
name: project.name,
|
|
13
25
|
projectPath: project.projectPath ?? project.path,
|
|
14
26
|
model: project.model,
|
|
@@ -17,27 +29,23 @@ function projectPatch(project: Record<string, unknown>) {
|
|
|
17
29
|
customIconUrl: project.customIconUrl,
|
|
18
30
|
isPinned: project.isPinned,
|
|
19
31
|
isExpanded: project.isExpanded,
|
|
20
|
-
}
|
|
32
|
+
};
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
export async function loader({ request: _request }: LoaderFunctionArgs) {
|
|
24
36
|
try {
|
|
25
37
|
const db = await getDb();
|
|
26
38
|
const folders = await db.all('SELECT * FROM workspace_folders ORDER BY id ASC');
|
|
27
|
-
const projects = folders.map(projectConfigFromFolder);
|
|
28
|
-
|
|
29
39
|
return json({
|
|
30
|
-
projects,
|
|
31
|
-
|
|
32
|
-
accentColorOptions: ACCENT_COLOR_OPTIONS,
|
|
40
|
+
projects: folders.map(projectConfigFromFolder),
|
|
41
|
+
accentColorOptions: PROJECT_ACCENT_OPTIONS,
|
|
33
42
|
});
|
|
34
43
|
} catch (error) {
|
|
35
44
|
const message = error instanceof Error ? error.message : 'Failed to load projects';
|
|
36
45
|
return json({
|
|
37
46
|
error: message,
|
|
38
47
|
projects: [],
|
|
39
|
-
|
|
40
|
-
accentColorOptions: ACCENT_COLOR_OPTIONS,
|
|
48
|
+
accentColorOptions: PROJECT_ACCENT_OPTIONS,
|
|
41
49
|
}, { status: 500 });
|
|
42
50
|
}
|
|
43
51
|
}
|
|
@@ -52,6 +60,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
52
60
|
|
|
53
61
|
const deleted = await deleteWorkspaceFolder(db, folderId);
|
|
54
62
|
if (!deleted) return json({ error: 'Workspace not found' }, { status: 404 });
|
|
63
|
+
// The removed workspace's `.omp` roots leave scope with it; a lingering
|
|
64
|
+
// watcher would keep broadcasting reloads for a tree Kabmo no longer reads.
|
|
65
|
+
void syncDiscoveryRootsWatch();
|
|
55
66
|
emitRealtimeSignal('sidebar-structure');
|
|
56
67
|
return json({ success: true });
|
|
57
68
|
}
|
|
@@ -75,15 +86,38 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
75
86
|
const folderId = typeof project.folderId === 'number' ? String(project.folderId) : undefined;
|
|
76
87
|
if (!folderId) return json({ error: 'project.folderId is required' }, { status: 400 });
|
|
77
88
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
const before = await db.get<{ project_path: string | null }>(
|
|
90
|
+
'SELECT project_path FROM workspace_folders WHERE id = ?',
|
|
91
|
+
[folderId],
|
|
92
|
+
);
|
|
93
|
+
if (!before) return json({ error: 'Workspace not found' }, { status: 404 });
|
|
94
|
+
|
|
95
|
+
const prepared = await prepareProjectPatch(db, folderId, projectPatchBody(project));
|
|
96
|
+
if (!prepared.ok) {
|
|
97
|
+
return json({ error: prepared.error, ...(prepared.code ? { code: prepared.code } : {}) }, { status: prepared.status });
|
|
82
98
|
}
|
|
83
99
|
|
|
100
|
+
const patch = prepared.patch;
|
|
101
|
+
const updated = await updateWorkspaceFolder(db, folderId, patch);
|
|
84
102
|
const folder = await db.get('SELECT * FROM workspace_folders WHERE id = ?', [folderId]);
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
|
|
104
|
+
const pathChanged = patch.projectPath !== undefined && (folder?.project_path ?? null) !== before.project_path;
|
|
105
|
+
if (pathChanged) {
|
|
106
|
+
// The watched discovery-root set is keyed by `project_path`, so a re-bind
|
|
107
|
+
// has to re-sync it: without this the OLD root stayed watched and the new
|
|
108
|
+
// one was never added until a restart.
|
|
109
|
+
void syncDiscoveryRootsWatch();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// A project field (name, model, accent, icon, pin, path) rides the sidebar's
|
|
113
|
+
// own folder rows, so this write is a structure change there.
|
|
87
114
|
emitRealtimeSignal('sidebar-structure');
|
|
88
|
-
|
|
115
|
+
// `changed: false` is an answer, not a failure: the form re-sent what it
|
|
116
|
+
// already had, or touched a field the store deliberately ignores.
|
|
117
|
+
return json({
|
|
118
|
+
success: true,
|
|
119
|
+
changed: Boolean(updated),
|
|
120
|
+
project: folder ? projectConfigFromFolder(folder) : null,
|
|
121
|
+
accentColorOptions: PROJECT_ACCENT_OPTIONS,
|
|
122
|
+
});
|
|
89
123
|
}
|