@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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `POST /api/settings/projects` — the refusal half of the project form.
|
|
8
|
+
*
|
|
9
|
+
* The pane edits facts that decide where a chat runs and which sessions the
|
|
10
|
+
* sidebar lists, so every rule that can make a write unhonourable is enforced
|
|
11
|
+
* here and named in the response:
|
|
12
|
+
*
|
|
13
|
+
* - an empty name (the store skips it, so the form would show a value the row
|
|
14
|
+
* never took),
|
|
15
|
+
* - a name another workspace already holds (case-insensitively — the sidebar
|
|
16
|
+
* identifies a workspace by name),
|
|
17
|
+
* - a path that is not an existing directory (a typo bound a folder that then
|
|
18
|
+
* listed nothing, with no reason on screen),
|
|
19
|
+
* - a directory another workspace is already bound to (two rows would list the
|
|
20
|
+
* same sessions and fight over the discovery tombstones).
|
|
21
|
+
*
|
|
22
|
+
* A refusal must also leave the stored row UNCHANGED — half-applied writes are
|
|
23
|
+
* what made a rename look successful until the next refresh.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
27
|
+
import fs from 'fs';
|
|
28
|
+
import os from 'os';
|
|
29
|
+
import path from 'path';
|
|
30
|
+
|
|
31
|
+
import { getDb } from '@/server/db.server';
|
|
32
|
+
import { action as projectsAction, loader as projectsLoader } from '@/server/routes/settings/projects';
|
|
33
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
34
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
35
|
+
|
|
36
|
+
const ROOT = path.join(os.tmpdir(), 'omc-settings-projects-routes-test');
|
|
37
|
+
const API = 'http://localhost/api/settings/projects';
|
|
38
|
+
const AGENT_DIR = path.join(ROOT, 'agent');
|
|
39
|
+
|
|
40
|
+
type Handler = (args: never) => unknown;
|
|
41
|
+
|
|
42
|
+
function call(handler: Handler, request: Request): Promise<Response> {
|
|
43
|
+
return handler({ request, params: {} } as never) as Promise<Response>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function send(url: string, verb: string, body?: unknown): Request {
|
|
47
|
+
return new Request(url, {
|
|
48
|
+
method: verb,
|
|
49
|
+
...(body === undefined ? {} : { body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function folderId(name: string): Promise<number> {
|
|
54
|
+
const db = await getDb();
|
|
55
|
+
const row = await db.get<{ id: number }>('SELECT id FROM workspace_folders WHERE name = ?', [name]);
|
|
56
|
+
if (!row) throw new Error(`no folder named ${name}`);
|
|
57
|
+
return row.id;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
beforeAll(async () => {
|
|
61
|
+
removeDir(ROOT);
|
|
62
|
+
fs.mkdirSync(AGENT_DIR, { recursive: true });
|
|
63
|
+
Bun.env.PI_CODING_AGENT_DIR = AGENT_DIR;
|
|
64
|
+
Bun.env.SYNC_WORKSPACE = 'false';
|
|
65
|
+
delete Bun.env.MOCK;
|
|
66
|
+
await isolateDb();
|
|
67
|
+
await getDb();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
beforeEach(async () => {
|
|
71
|
+
const db = await getDb();
|
|
72
|
+
await db.run('DELETE FROM workspace_folders');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
afterAll(async () => {
|
|
76
|
+
await releaseDb();
|
|
77
|
+
delete Bun.env.PI_CODING_AGENT_DIR;
|
|
78
|
+
delete Bun.env.SYNC_WORKSPACE;
|
|
79
|
+
removeDir(ROOT);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('settings projects route', () => {
|
|
83
|
+
test('the loader serves the accent palette but no model list', async () => {
|
|
84
|
+
const body = await (await call(projectsLoader, new Request(API))).json();
|
|
85
|
+
expect(Array.isArray(body.projects)).toBe(true);
|
|
86
|
+
expect(body.accentColorOptions[0]).toMatchObject({ label: 'None', value: '' });
|
|
87
|
+
// The default model is a `provider:modelId` from the live catalog, so this
|
|
88
|
+
// route must not answer with a hardcoded list of display names.
|
|
89
|
+
expect(body.availableModels).toBeUndefined();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('an empty name is refused and the stored name survives', async () => {
|
|
93
|
+
const db = await getDb();
|
|
94
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['Keep']);
|
|
95
|
+
const id = await folderId('Keep');
|
|
96
|
+
|
|
97
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, name: ' ' } }));
|
|
98
|
+
expect(res.status).toBe(400);
|
|
99
|
+
expect(await res.json()).toMatchObject({ code: 'name_required' });
|
|
100
|
+
expect((await db.get<{ name: string }>('SELECT name FROM workspace_folders WHERE id = ?', [id]))?.name).toBe('Keep');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('a duplicate name is a 409 naming the clash, and nothing is written', async () => {
|
|
104
|
+
const db = await getDb();
|
|
105
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['alpha']);
|
|
106
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['beta']);
|
|
107
|
+
const id = await folderId('beta');
|
|
108
|
+
|
|
109
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, name: 'ALPHA' } }));
|
|
110
|
+
expect(res.status).toBe(409);
|
|
111
|
+
expect(await res.json()).toMatchObject({ code: 'duplicate_name' });
|
|
112
|
+
expect((await db.get<{ name: string }>('SELECT name FROM workspace_folders WHERE id = ?', [id]))?.name).toBe('beta');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('a path that is not a directory is refused and the old binding survives', async () => {
|
|
116
|
+
const db = await getDb();
|
|
117
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded, project_path) VALUES (?, 1, ?)', ['bound', AGENT_DIR]);
|
|
118
|
+
const id = await folderId('bound');
|
|
119
|
+
|
|
120
|
+
const res = await call(
|
|
121
|
+
projectsAction,
|
|
122
|
+
send(API, 'POST', { project: { folderId: id, projectPath: path.join(ROOT, 'nope') } }),
|
|
123
|
+
);
|
|
124
|
+
expect(res.status).toBe(400);
|
|
125
|
+
expect(await res.json()).toMatchObject({ code: 'directory_not_found' });
|
|
126
|
+
expect((await db.get<{ project_path: string }>('SELECT project_path FROM workspace_folders WHERE id = ?', [id]))?.project_path)
|
|
127
|
+
.toBe(AGENT_DIR);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('a directory another workspace already holds is a 409 naming the holder', async () => {
|
|
131
|
+
await getDb().then((db) => db.run(
|
|
132
|
+
'INSERT INTO workspace_folders (name, is_expanded, project_path) VALUES (?, 1, ?)',
|
|
133
|
+
['first', AGENT_DIR],
|
|
134
|
+
));
|
|
135
|
+
await getDb().then((db) => db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['second']));
|
|
136
|
+
const id = await folderId('second');
|
|
137
|
+
|
|
138
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, projectPath: AGENT_DIR } }));
|
|
139
|
+
expect(res.status).toBe(409);
|
|
140
|
+
expect(await res.json()).toMatchObject({ code: 'duplicate_path' });
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('an accepted bind is stored as the absolute path, and changing the path re-syncs discovery', async () => {
|
|
144
|
+
const db = await getDb();
|
|
145
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['tilde']);
|
|
146
|
+
const id = await folderId('tilde');
|
|
147
|
+
|
|
148
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, projectPath: AGENT_DIR } }));
|
|
149
|
+
expect(res.status).toBe(200);
|
|
150
|
+
const body = await res.json();
|
|
151
|
+
expect(body).toMatchObject({ success: true, changed: true });
|
|
152
|
+
expect(body.project).toMatchObject({ name: 'tilde', path: AGENT_DIR });
|
|
153
|
+
expect(path.isAbsolute(body.project.path)).toBe(true);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('a custom accent is stored in one canonical form', async () => {
|
|
157
|
+
const db = await getDb();
|
|
158
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['custom']);
|
|
159
|
+
const id = await folderId('custom');
|
|
160
|
+
|
|
161
|
+
// `#ABC` and `#aabbcc` are the same colour; the sidebar compares the stored
|
|
162
|
+
// string against the preset table, so one spelling has to win.
|
|
163
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, accentColor: '#0F8' } }));
|
|
164
|
+
expect(res.status).toBe(200);
|
|
165
|
+
expect((await res.json()).project).toMatchObject({ accentColor: '#00ff88' });
|
|
166
|
+
expect(
|
|
167
|
+
(await db.get<{ accent_color: string }>('SELECT accent_color FROM workspace_folders WHERE id = ?', [id]))?.accent_color,
|
|
168
|
+
).toBe('#00ff88');
|
|
169
|
+
|
|
170
|
+
// The paint the sidebar actually does: a six-digit hex reaches the loader.
|
|
171
|
+
const body = await (await call(projectsLoader, new Request(API))).json();
|
|
172
|
+
expect(body.projects.find((project: { folderId: number }) => project.folderId === id)).toMatchObject({
|
|
173
|
+
accentColor: '#00ff88',
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('an accent that is not a hex colour is refused before it reaches a style', async () => {
|
|
178
|
+
const db = await getDb();
|
|
179
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded, accent_color) VALUES (?, 1, ?)', ['plain', '#38bdf8']);
|
|
180
|
+
const id = await folderId('plain');
|
|
181
|
+
|
|
182
|
+
for (const accentColor of ['red;background:url(//evil)', 'rgb(1,2,3)', '#12345', 'url(#x)']) {
|
|
183
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, accentColor } }));
|
|
184
|
+
expect(res.status).toBe(400);
|
|
185
|
+
expect(await res.json()).toMatchObject({ code: 'invalid_accent' });
|
|
186
|
+
}
|
|
187
|
+
expect(
|
|
188
|
+
(await db.get<{ accent_color: string }>('SELECT accent_color FROM workspace_folders WHERE id = ?', [id]))?.accent_color,
|
|
189
|
+
).toBe('#38bdf8');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('an empty accent clears the mark instead of being refused', async () => {
|
|
193
|
+
const db = await getDb();
|
|
194
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded, accent_color) VALUES (?, 1, ?)', ['clearing', '#f43f5e']);
|
|
195
|
+
const id = await folderId('clearing');
|
|
196
|
+
|
|
197
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id, accentColor: '' } }));
|
|
198
|
+
expect(res.status).toBe(200);
|
|
199
|
+
expect((await res.json()).project).toMatchObject({ accentColor: '' });
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test('a body carrying no editable field answers success with changed:false', async () => {
|
|
203
|
+
const db = await getDb();
|
|
204
|
+
await db.run('INSERT INTO workspace_folders (name, is_expanded) VALUES (?, 1)', ['same']);
|
|
205
|
+
const id = await folderId('same');
|
|
206
|
+
|
|
207
|
+
// Only the id: nothing the store can write. That is an ANSWER, not a
|
|
208
|
+
// failure — the form may legitimately re-send an untouched row.
|
|
209
|
+
const res = await call(projectsAction, send(API, 'POST', { project: { folderId: id } }));
|
|
210
|
+
expect(res.status).toBe(200);
|
|
211
|
+
expect(await res.json()).toMatchObject({ success: true, changed: false });
|
|
212
|
+
expect((await db.get<{ name: string }>('SELECT name FROM workspace_folders WHERE id = ?', [id]))?.name).toBe('same');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The settings routes backed by Kabmo SQLite store: root, projects
|
|
8
|
-
* behavior
|
|
7
|
+
* The settings routes backed by Kabmo SQLite store: root, projects and
|
|
8
|
+
* behavior.
|
|
9
9
|
*
|
|
10
10
|
* Each of these modules owns a request contract that is easy to break from the
|
|
11
11
|
* client side and invisible from the server side, so every case here pins a
|
|
@@ -19,14 +19,11 @@
|
|
|
19
19
|
* missing workspace.
|
|
20
20
|
* - `behavior` refuses an unknown `file` and a non-string `rules`, and its
|
|
21
21
|
* reset restores the shipped AGENTS.md preset but clears RULES.md.
|
|
22
|
-
* - `agents` refuses every mutation of a native `omp-` agent with 403 and
|
|
23
|
-
* refuses native writes outright under MOCK.
|
|
24
|
-
* - `providers` reports a delete without an id as a 400 rather than silently
|
|
25
|
-
* removing the whole overlay.
|
|
26
22
|
*
|
|
27
|
-
* The DB is a fresh temp file (`KABMO_DB_PATH`, `SYNC_WORKSPACE=false`)
|
|
28
|
-
*
|
|
29
|
-
* `~/.
|
|
23
|
+
* The DB is a fresh temp file (`KABMO_DB_PATH`, `SYNC_WORKSPACE=false`) and the
|
|
24
|
+
* agent dir a temp tree, so no case can reach the developer's real `~/.omp` or
|
|
25
|
+
* `~/.kabmo`. The agents route writes FILES, so its cases live beside it in
|
|
26
|
+
* `agents.test.ts`. Tests run in real mode unless a case opts into
|
|
30
27
|
* MOCK for a mock-only branch; the db slot is primed in `beforeAll` so a later
|
|
31
28
|
* MOCK toggle cannot re-resolve the path to the repo's own `workspace.db`.
|
|
32
29
|
*/
|
|
@@ -36,12 +33,9 @@ import fs from 'fs';
|
|
|
36
33
|
import os from 'os';
|
|
37
34
|
import path from 'path';
|
|
38
35
|
import { getDb } from '@/server/db.server';
|
|
39
|
-
import { DEFAULT_AGENTS_LIST } from '@/client/data/agent-data';
|
|
40
36
|
import { DEFAULT_BEHAVIOR_RULES } from '@/client/data/settings/behavior';
|
|
41
|
-
import { action as agentsAction, loader as agentsLoader } from '@/server/routes/settings/agents';
|
|
42
37
|
import { action as behaviorAction, loader as behaviorLoader } from '@/server/routes/settings/behavior';
|
|
43
38
|
import { action as projectsAction, loader as projectsLoader } from '@/server/routes/settings/projects';
|
|
44
|
-
import { action as providersAction, loader as providersLoader } from '@/server/routes/settings/providers';
|
|
45
39
|
import { action as rootAction, loader as rootLoader } from '@/server/routes/settings/root';
|
|
46
40
|
import { removeDir } from '@/test-support/remove-dir';
|
|
47
41
|
|
|
@@ -121,11 +115,14 @@ describe('settings root', () => {
|
|
|
121
115
|
});
|
|
122
116
|
|
|
123
117
|
describe('settings projects', () => {
|
|
124
|
-
test('the loader reports the
|
|
118
|
+
test('the loader reports the accent options alongside the list', async () => {
|
|
125
119
|
const body = await (await call(projectsLoader, new Request(`${API}/projects`))).json();
|
|
126
120
|
expect(Array.isArray(body.projects)).toBe(true);
|
|
127
|
-
expect(Array.isArray(body.availableModels)).toBe(true);
|
|
128
121
|
expect(Array.isArray(body.accentColorOptions)).toBe(true);
|
|
122
|
+
expect(body.accentColorOptions[0]).toMatchObject({ label: 'None', value: '' });
|
|
123
|
+
// The default model comes from the live catalog, not from this route: a
|
|
124
|
+
// hardcoded list of display names here was never readable by a spawn.
|
|
125
|
+
expect(body.availableModels).toBeUndefined();
|
|
129
126
|
});
|
|
130
127
|
|
|
131
128
|
test('a delete without an id is refused before touching the store', async () => {
|
|
@@ -231,104 +228,3 @@ describe('settings behavior', () => {
|
|
|
231
228
|
expect(await res.json()).toEqual({ error: 'Method not allowed' });
|
|
232
229
|
});
|
|
233
230
|
});
|
|
234
|
-
|
|
235
|
-
describe('settings agents', () => {
|
|
236
|
-
test('native omp agents are read-only for delete and for write', async () => {
|
|
237
|
-
const del = await call(agentsAction, new Request(`${API}/agents?id=omp-reviewer`, { method: 'DELETE' }));
|
|
238
|
-
expect(del.status).toBe(403);
|
|
239
|
-
expect(await del.json()).toEqual({ error: 'Native omp agents are read-only in Kabmo' });
|
|
240
|
-
|
|
241
|
-
const write = await call(agentsAction, send(`${API}/agents`, 'POST', { agent: { id: 'omp-reviewer', name: 'x' } }));
|
|
242
|
-
expect(write.status).toBe(403);
|
|
243
|
-
expect(await write.json()).toEqual({ error: 'Native omp agents are read-only in Kabmo' });
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
test('a delete without an id is a 400', async () => {
|
|
247
|
-
const res = await call(agentsAction, new Request(`${API}/agents`, { method: 'DELETE' }));
|
|
248
|
-
expect(res.status).toBe(400);
|
|
249
|
-
expect(await res.json()).toEqual({ error: 'id is required' });
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
test('native write and delete round-trip in the temp agent dir', async () => {
|
|
253
|
-
const written = await call(agentsAction, send(`${API}/agents`, 'POST', {
|
|
254
|
-
type: 'write_native', fileName: 'helper', name: 'Helper', systemPrompt: 'You help.',
|
|
255
|
-
}));
|
|
256
|
-
expect(written.status).toBe(200);
|
|
257
|
-
expect((await written.json()).path).toEndWith('helper.md');
|
|
258
|
-
|
|
259
|
-
const deleted = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete_native', fileName: 'helper' }));
|
|
260
|
-
expect(deleted.status).toBe(200);
|
|
261
|
-
|
|
262
|
-
const missing = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete_native', fileName: 'gone' }));
|
|
263
|
-
expect(missing.status).toBe(404);
|
|
264
|
-
expect(await missing.json()).toEqual({ error: 'Native agent file not found' });
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
test('an invalid native file name and an empty prompt are refused', async () => {
|
|
268
|
-
const badName = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write_native', fileName: 'bad name', systemPrompt: 'x' }));
|
|
269
|
-
expect(badName.status).toBe(500);
|
|
270
|
-
|
|
271
|
-
const empty = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write_native', fileName: 'ok', systemPrompt: ' ' }));
|
|
272
|
-
expect(empty.status).toBe(500);
|
|
273
|
-
expect(await empty.json()).toEqual({ error: 'Agent system prompt cannot be empty' });
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
test('MOCK refuses native writes and serves the demo list', async () => {
|
|
277
|
-
Bun.env.MOCK = 'true';
|
|
278
|
-
const write = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'write_native', fileName: 'x' }));
|
|
279
|
-
expect(write.status).toBe(400);
|
|
280
|
-
expect(await write.json()).toEqual({ error: 'Native agent writes are unavailable in mock mode' });
|
|
281
|
-
|
|
282
|
-
const del = await call(agentsAction, send(`${API}/agents`, 'POST', { type: 'delete_native', fileName: 'x' }));
|
|
283
|
-
expect(del.status).toBe(400);
|
|
284
|
-
expect(await del.json()).toEqual({ error: 'Native agent deletes are unavailable in mock mode' });
|
|
285
|
-
|
|
286
|
-
const body = await (await call(agentsLoader, new Request(`${API}/agents`))).json();
|
|
287
|
-
expect(body.isMock).toBe(true);
|
|
288
|
-
expect(body.agents).toHaveLength(DEFAULT_AGENTS_LIST.length);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test('a wrong verb is the route-owned 405', async () => {
|
|
292
|
-
const res = await call(agentsAction, send(`${API}/agents`, 'PATCH'));
|
|
293
|
-
expect(res.status).toBe(405);
|
|
294
|
-
expect(await res.json()).toEqual({ error: 'Method not allowed' });
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
describe('settings providers', () => {
|
|
299
|
-
test('MOCK serves the preset list without probing the agent', async () => {
|
|
300
|
-
Bun.env.MOCK = 'true';
|
|
301
|
-
const body = await (await call(providersLoader, new Request(`${API}/providers`))).json();
|
|
302
|
-
expect(body.isMock).toBe(true);
|
|
303
|
-
expect(Array.isArray(body.providers)).toBe(true);
|
|
304
|
-
expect(Array.isArray(body.presetProviders)).toBe(true);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
test('MOCK connect and disconnect flip the overlay row', async () => {
|
|
308
|
-
Bun.env.MOCK = 'true';
|
|
309
|
-
const seeded = await call(providersAction, send(`${API}/providers`, 'POST', {
|
|
310
|
-
provider: { id: 'p-test', name: 'Test', slug: 'testp', icon: 'test', status: 'connected', configuredIn: 'chamber' },
|
|
311
|
-
}));
|
|
312
|
-
expect(seeded.status).toBe(200);
|
|
313
|
-
|
|
314
|
-
const off = await call(providersAction, send(`${API}/providers`, 'POST', { disableProvider: 'testp' }));
|
|
315
|
-
const offBody = await off.json();
|
|
316
|
-
expect(offBody.providers.find((p: { slug: string }) => p.slug === 'testp')).toMatchObject({ disabled: true, status: 'disconnected' });
|
|
317
|
-
|
|
318
|
-
const on = await call(providersAction, send(`${API}/providers`, 'POST', { enableProvider: 'testp' }));
|
|
319
|
-
const onBody = await on.json();
|
|
320
|
-
expect(onBody.providers.find((p: { slug: string }) => p.slug === 'testp')).toMatchObject({ disabled: false, status: 'connected' });
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
test('a delete without an id is refused before any registry probe', async () => {
|
|
324
|
-
const res = await call(providersAction, new Request(`${API}/providers`, { method: 'DELETE' }));
|
|
325
|
-
expect(res.status).toBe(400);
|
|
326
|
-
expect(await res.json()).toEqual({ error: 'id is required' });
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
test('a wrong verb is the route-owned 405', async () => {
|
|
330
|
-
const res = await call(providersAction, new Request(`${API}/providers`));
|
|
331
|
-
expect(res.status).toBe(405);
|
|
332
|
-
expect(await res.json()).toEqual({ error: 'Method not allowed' });
|
|
333
|
-
});
|
|
334
|
-
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Skills Catalog's git actions: sources, inspection and install.
|
|
8
|
+
*
|
|
9
|
+
* Split from the skill CRUD route (which is already the largest module in
|
|
10
|
+
* `settings/`) because these two families answer different questions. A CRUD
|
|
11
|
+
* request names a skill Kabmo already discovered; a catalog request names a
|
|
12
|
+
* repository Kabmo has never seen, and its answer is a LIST of skills plus what
|
|
13
|
+
* the server refuses to install.
|
|
14
|
+
*
|
|
15
|
+
* Three refusals are load-bearing:
|
|
16
|
+
*
|
|
17
|
+
* - **A duplicate repository is a 409, not a second card.** Two cards for one
|
|
18
|
+
* repository mean two `skillCount`s and two scan buttons that disagree.
|
|
19
|
+
* - **A project install with no workspace is refused**, never redirected to the
|
|
20
|
+
* user root: the user picked a scope, and landing the files elsewhere is how a
|
|
21
|
+
* skill "vanishes" from the list being viewed.
|
|
22
|
+
* - **A registry install is one `bunx skills add --skill <name>` per picked
|
|
23
|
+
* skill**, and a failure is reported per skill. The CLI has no batch form that
|
|
24
|
+
* names individual skills, and an unscoped add installs the whole repository
|
|
25
|
+
* (measured: 20 directories for one click).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { json } from '@/server/lib/remix-compat';
|
|
29
|
+
import { isMockMode } from '@/server/mock.server';
|
|
30
|
+
import type { DiscoveryScope } from '@/server/lib/omp/config/scope';
|
|
31
|
+
import type { SkillCatalogSource } from '@/shared/types';
|
|
32
|
+
import { DEFAULT_CATALOG_SKILLS } from '@/client/data/settings/skill';
|
|
33
|
+
import { searchSkillCatalog, toCatalogSkills, installCatalogSkill } from '@/server/lib/omp/config/skills-catalog';
|
|
34
|
+
import { inspectSkillRepo, toSkillRepoRef } from '@/server/lib/omp/config/skills-git-repo';
|
|
35
|
+
import { installSkillCopies } from '@/server/lib/omp/config/skills-git-install';
|
|
36
|
+
import { readCatalogSources, writeCatalogSources } from '@/server/lib/omp/config/skill-sources';
|
|
37
|
+
import type { DbClient } from '@/server/lib/db/client';
|
|
38
|
+
import { reloadLiveSessions } from '@/server/lib/omp/session/reload.server';
|
|
39
|
+
|
|
40
|
+
export interface CatalogDeps {
|
|
41
|
+
db: DbClient;
|
|
42
|
+
scope: DiscoveryScope;
|
|
43
|
+
/**
|
|
44
|
+
* True only when the request actually NAMED a workspace root.
|
|
45
|
+
*
|
|
46
|
+
* `resolveDiscoveryScope` answers the server's own cwd for a request with no
|
|
47
|
+
* `root` — which is correct for a read (omp is asked about the directory it
|
|
48
|
+
* would spawn in) and wrong for an install: the catalog pane sends no root, so
|
|
49
|
+
* a `project` default wrote the copied skill into the server's working
|
|
50
|
+
* directory. Measured: a UI install landed in `<repo>/.omp/skills/new-skill`
|
|
51
|
+
* while the user was looking at a user-scope list.
|
|
52
|
+
*/
|
|
53
|
+
hasWorkspace: boolean;
|
|
54
|
+
/** The live discovery list, re-read after a write. */
|
|
55
|
+
listSkills: (scope: DiscoveryScope) => Promise<{ name: string }[]>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function message(error: unknown): string {
|
|
59
|
+
return error instanceof Error ? error.message : String(error);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Handle one catalog action. Returns `null` when `type` is not a catalog action,
|
|
64
|
+
* so the caller can fall through to the skill CRUD branches.
|
|
65
|
+
*/
|
|
66
|
+
export async function runCatalogAction(body: Record<string, unknown>, deps: CatalogDeps): Promise<Response | null> {
|
|
67
|
+
const mock = isMockMode();
|
|
68
|
+
const { db, scope } = deps;
|
|
69
|
+
const type = typeof body.type === 'string' ? body.type : '';
|
|
70
|
+
|
|
71
|
+
if (type === 'add_source') {
|
|
72
|
+
const ref = toSkillRepoRef(typeof body.repo === 'string' ? body.repo : '');
|
|
73
|
+
if (!ref) return json({ error: 'Expected a git URL or an owner/repo pair' }, { status: 400 });
|
|
74
|
+
const sources = await readCatalogSources(db);
|
|
75
|
+
if (sources.some((source) => source.repo === ref.slug)) {
|
|
76
|
+
return json({ error: `${ref.slug} is already a source` }, { status: 409 });
|
|
77
|
+
}
|
|
78
|
+
const source: SkillCatalogSource = {
|
|
79
|
+
id: `custom-${Date.now().toString(36)}`,
|
|
80
|
+
name: typeof body.name === 'string' && body.name.trim() ? body.name.trim() : ref.slug,
|
|
81
|
+
repo: ref.slug,
|
|
82
|
+
skillCount: null,
|
|
83
|
+
scannedAt: null,
|
|
84
|
+
isCustom: true,
|
|
85
|
+
};
|
|
86
|
+
const updated = [...sources, source];
|
|
87
|
+
await writeCatalogSources(db, updated);
|
|
88
|
+
return json({ success: true, catalogSources: updated, source });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (type === 'remove_source') {
|
|
92
|
+
const id = typeof body.id === 'string' ? body.id : '';
|
|
93
|
+
if (!id) return json({ error: 'id is required' }, { status: 400 });
|
|
94
|
+
const sources = await readCatalogSources(db);
|
|
95
|
+
const updated = sources.filter((source) => source.id !== id);
|
|
96
|
+
if (updated.length === sources.length) return json({ error: 'Source not found' }, { status: 404 });
|
|
97
|
+
await writeCatalogSources(db, updated);
|
|
98
|
+
return json({ success: true, catalogSources: updated });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Real search over skills.sh. The Browse box used to filter the ~26 entries the
|
|
102
|
+
// loader had pre-fetched, so a query the catalog actually held answered "no
|
|
103
|
+
// skills found".
|
|
104
|
+
if (type === 'search_catalog') {
|
|
105
|
+
const query = typeof body.q === 'string' ? body.q.trim() : '';
|
|
106
|
+
if (!query) return json({ query, catalogSkills: [] });
|
|
107
|
+
if (mock) {
|
|
108
|
+
const needle = query.toLowerCase();
|
|
109
|
+
return json({
|
|
110
|
+
query,
|
|
111
|
+
catalogSkills: DEFAULT_CATALOG_SKILLS.filter((skill) =>
|
|
112
|
+
`${skill.name} ${skill.description} ${skill.repoTag}`.toLowerCase().includes(needle),
|
|
113
|
+
),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const seen = new Set<string>();
|
|
117
|
+
const catalogSkills = toCatalogSkills(await searchSkillCatalog(query, 24), 'skills-sh').filter((item) =>
|
|
118
|
+
seen.has(item.repoTag) ? false : (seen.add(item.repoTag), true),
|
|
119
|
+
);
|
|
120
|
+
return json({ query, catalogSkills });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (type === 'inspect_git_repo' || type === 'scan_source') {
|
|
124
|
+
if (mock) return json({ error: 'Repository inspection is unavailable in mock mode' }, { status: 409 });
|
|
125
|
+
|
|
126
|
+
let repo: string;
|
|
127
|
+
let previous: SkillCatalogSource[] = [];
|
|
128
|
+
let sourceId: string | null = null;
|
|
129
|
+
if (type === 'scan_source') {
|
|
130
|
+
const id = typeof body.id === 'string' ? body.id : '';
|
|
131
|
+
previous = await readCatalogSources(db);
|
|
132
|
+
const source = previous.find((candidate) => candidate.id === id);
|
|
133
|
+
if (!source) return json({ error: 'Source not found' }, { status: 404 });
|
|
134
|
+
repo = source.repo;
|
|
135
|
+
sourceId = id;
|
|
136
|
+
} else {
|
|
137
|
+
repo = typeof body.url === 'string' ? body.url : '';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const inspection = await inspectSkillRepo(repo);
|
|
141
|
+
const installed = new Set((await deps.listSkills(scope)).map((skill) => skill.name));
|
|
142
|
+
const skills = inspection.skills.map((skill) => ({ ...skill, installed: installed.has(skill.name) }));
|
|
143
|
+
if (!sourceId) return json({ ...inspection, skills });
|
|
144
|
+
|
|
145
|
+
// A stored count must come from a scan: this is the only place one is written.
|
|
146
|
+
const updated = previous.map((candidate) =>
|
|
147
|
+
candidate.id === sourceId
|
|
148
|
+
? { ...candidate, skillCount: skills.filter((skill) => skill.loadable).length, scannedAt: Date.now() }
|
|
149
|
+
: candidate,
|
|
150
|
+
);
|
|
151
|
+
await writeCatalogSources(db, updated);
|
|
152
|
+
return json({ ...inspection, skills, sourceId, catalogSources: updated });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (type === 'install_git_skills') {
|
|
156
|
+
if (mock) return json({ error: 'Skill install is unavailable in mock mode' }, { status: 409 });
|
|
157
|
+
const url = typeof body.url === 'string' ? body.url : '';
|
|
158
|
+
const paths = Array.isArray(body.paths) ? body.paths.filter((path): path is string => typeof path === 'string') : [];
|
|
159
|
+
if (paths.length === 0) return json({ error: 'Select at least one skill to install' }, { status: 400 });
|
|
160
|
+
|
|
161
|
+
if (body.mode === 'registry') {
|
|
162
|
+
const installed: string[] = [];
|
|
163
|
+
const skipped: Array<{ name: string; reason: string }> = [];
|
|
164
|
+
for (const path of paths) {
|
|
165
|
+
const name = path.split('/').pop() ?? '';
|
|
166
|
+
try {
|
|
167
|
+
// The CLI takes `owner/repo`; any accepted URL form maps to it.
|
|
168
|
+
await installCatalogSkill(toSkillRepoRef(url)?.slug ?? url.trim(), name);
|
|
169
|
+
installed.push(name);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
skipped.push({ name, reason: message(error) });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
await reloadLiveSessions();
|
|
175
|
+
return json({ repo: url, mode: 'registry', installed, skipped, skills: await deps.listSkills(scope) });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// USER by default: the catalog pane names no workspace, and a managed copy
|
|
179
|
+
// there is the skill the user owns globally. A `project` request needs a
|
|
180
|
+
// root the caller actually named.
|
|
181
|
+
const location = body.location === 'project' ? 'project' : 'user';
|
|
182
|
+
if (location === 'project' && !deps.hasWorkspace) {
|
|
183
|
+
return json({ error: 'Select a workspace to install a project skill' }, { status: 400 });
|
|
184
|
+
}
|
|
185
|
+
const outcome = await installSkillCopies(url, paths, {
|
|
186
|
+
scope: location,
|
|
187
|
+
projectDir: location === 'project' ? scope.workspace : null,
|
|
188
|
+
overwrite: body.overwrite === true,
|
|
189
|
+
});
|
|
190
|
+
if (outcome.installed.length > 0) await reloadLiveSessions();
|
|
191
|
+
return json({ repo: url, mode: 'managed_copy', ...outcome, skills: await deps.listSkills(scope) });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return null;
|
|
195
|
+
}
|