@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
|
@@ -4,58 +4,181 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Native OMP agent discovery
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Native OMP agent discovery and writing.
|
|
8
|
+
*
|
|
9
|
+
* An agent definition is a markdown file with frontmatter, and omp reads a
|
|
10
|
+
* FIXED set of keys out of it — measured against the installed
|
|
11
|
+
* `@oh-my-pi/pi-coding-agent` 18.16.0 (`discovery/helpers.ts` `parseAgentFields`):
|
|
12
|
+
*
|
|
13
|
+
* name, description, tools, spawns, model, output, thinkingLevel,
|
|
14
|
+
* blocking, structured, prewalk, advisor, autoloadSkills, readSummarize
|
|
15
|
+
*
|
|
16
|
+
* Anything else in the file is ignored by omp, so a panel that offered `mode`,
|
|
17
|
+
* `temperature` or `top_p` was offering three controls that changed a file omp
|
|
18
|
+
* never reads — the agent kept behaving exactly as before. Worse, a writer that
|
|
19
|
+
* emitted ONLY its own keys silently DELETED `tools`, `spawns` and the nested
|
|
20
|
+
* `output:` schema from a shipped agent the moment its prompt was edited.
|
|
21
|
+
*
|
|
22
|
+
* Two rules follow, and both are load-bearing:
|
|
23
|
+
*
|
|
24
|
+
* - discovery parses the keys omp honours, including `model` as a block list
|
|
25
|
+
* (`model:\n - "@smol"`, which the scalar-only parser read as empty);
|
|
26
|
+
* - writing edits the frontmatter IN PLACE: a key the file already has is
|
|
27
|
+
* replaced where it stands, a key it lacks is appended, and every line the
|
|
28
|
+
* panel does not own — including a multi-line `output:` block — survives
|
|
29
|
+
* byte for byte.
|
|
11
30
|
*/
|
|
12
31
|
|
|
13
32
|
import fs from 'fs';
|
|
14
33
|
import { basename, join } from 'path';
|
|
15
34
|
import { getAgentDir, pathExists } from '@/server/lib/omp/core/paths';
|
|
16
35
|
import { writeFileAtomic } from '@/server/lib/fs/atomic-write';
|
|
17
|
-
import { parseFrontmatter } from '@/server/lib/omp/config/yaml';
|
|
18
36
|
|
|
19
37
|
export interface DiscoveredAgent {
|
|
20
38
|
id: string;
|
|
21
39
|
name: string;
|
|
22
40
|
description: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
/** Tool allowlist; absent means omp's default set. */
|
|
42
|
+
tools?: string[];
|
|
43
|
+
/** `"*"` or a name list: which agents this one may spawn. */
|
|
44
|
+
spawns?: string;
|
|
45
|
+
/** `provider/model`, or a role selector such as `@smol`. */
|
|
46
|
+
model?: string;
|
|
47
|
+
/** `off` … `max`, or `auto`; absent means the session's level. */
|
|
48
|
+
thinkingLevel?: string;
|
|
28
49
|
systemPrompt: string;
|
|
29
|
-
/** Which disk root the agent was discovered from. */
|
|
30
50
|
sourceRoot: 'user' | 'project';
|
|
31
51
|
filePath: string;
|
|
32
52
|
}
|
|
33
53
|
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
/** A key the panel owns, so it may be rewritten. Everything else is preserved. */
|
|
55
|
+
export interface AgentFileInput {
|
|
56
|
+
fileName: string;
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
/** Cleared when empty — an absent key is how omp spells "use the default". */
|
|
60
|
+
model?: string;
|
|
61
|
+
thinkingLevel?: string;
|
|
62
|
+
/** `undefined` leaves the file's own tools line untouched. */
|
|
63
|
+
tools?: string[];
|
|
64
|
+
spawns?: string;
|
|
65
|
+
systemPrompt: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Frontmatter scalar keys the panel edits. */
|
|
69
|
+
const OWNED_KEYS = ['name', 'description', 'model', 'thinkingLevel', 'tools', 'spawns'] as const;
|
|
70
|
+
type OwnedKey = (typeof OWNED_KEYS)[number];
|
|
71
|
+
|
|
72
|
+
/** Unquote a frontmatter scalar the way omp writes it. */
|
|
73
|
+
function unquote(raw: string): string {
|
|
74
|
+
const trimmed = raw.trim();
|
|
75
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length >= 2) {
|
|
76
|
+
return trimmed.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
77
|
+
}
|
|
78
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'") && trimmed.length >= 2) {
|
|
79
|
+
return trimmed.slice(1, -1);
|
|
80
|
+
}
|
|
81
|
+
return trimmed;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Quote a value so a `:` or `#` in it cannot change the document's meaning. */
|
|
85
|
+
function quote(value: string): string {
|
|
86
|
+
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface FrontmatterBlock {
|
|
90
|
+
/** Lines between the fences (`[]` for a file with an empty block). */
|
|
91
|
+
lines: string[];
|
|
92
|
+
/** Everything after the closing fence, fence included in `body`'s own prefix. */
|
|
93
|
+
body: string;
|
|
94
|
+
/** True when the file has no frontmatter fences at all. */
|
|
95
|
+
missing: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Split a definition file into its frontmatter lines and its body. */
|
|
99
|
+
function splitDefinition(text: string): FrontmatterBlock {
|
|
100
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/.exec(text);
|
|
101
|
+
if (!match) return { lines: [], body: text, missing: true };
|
|
102
|
+
return {
|
|
103
|
+
lines: match[1].split(/\r?\n/),
|
|
104
|
+
body: text.slice(match[0].length),
|
|
105
|
+
missing: false,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Read the frontmatter of a definition into the keys omp actually parses.
|
|
111
|
+
*
|
|
112
|
+
* `parseFrontmatter` in `yaml.ts` is scalar-only and cannot see a block list —
|
|
113
|
+
* and `model` is written as one (`model:\n - "@smol"`), so probing it with that
|
|
114
|
+
* parser reported every shipped agent as having no model.
|
|
115
|
+
*/
|
|
116
|
+
export function parseAgentDefinition(text: string): {
|
|
117
|
+
name?: string;
|
|
118
|
+
description?: string;
|
|
119
|
+
model?: string;
|
|
120
|
+
thinkingLevel?: string;
|
|
121
|
+
tools?: string[];
|
|
122
|
+
spawns?: string;
|
|
123
|
+
body: string;
|
|
124
|
+
} {
|
|
125
|
+
const { lines, body } = splitDefinition(text);
|
|
126
|
+
const scalars = new Map<string, string>();
|
|
127
|
+
const lists = new Map<string, string[]>();
|
|
128
|
+
let current: string | null = null;
|
|
129
|
+
|
|
130
|
+
for (const line of lines) {
|
|
131
|
+
const listItem = /^\s*-\s+(.*)$/.exec(line);
|
|
132
|
+
if (listItem && current) {
|
|
133
|
+
const values = lists.get(current) ?? [];
|
|
134
|
+
values.push(unquote(listItem[1]));
|
|
135
|
+
lists.set(current, values);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const entry = /^([A-Za-z_][\w-]*)\s*:\s*(.*)$/.exec(line);
|
|
139
|
+
if (!entry) continue;
|
|
140
|
+
current = entry[1];
|
|
141
|
+
const value = unquote(entry[2]);
|
|
142
|
+
if (value) scalars.set(current, value);
|
|
143
|
+
else if (!lists.has(current)) lists.set(current, []);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const toolsRaw = scalars.get('tools') ?? lists.get('tools')?.join(',');
|
|
147
|
+
const tools = toolsRaw
|
|
148
|
+
? toolsRaw.split(',').map((item) => item.trim()).filter(Boolean)
|
|
149
|
+
: undefined;
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
...(scalars.has('name') ? { name: scalars.get('name') } : {}),
|
|
153
|
+
...(scalars.has('description') ? { description: scalars.get('description') } : {}),
|
|
154
|
+
// omp accepts either spelling; `thinkingLevel` is the one it writes.
|
|
155
|
+
...(scalars.has('thinkingLevel') ? { thinkingLevel: scalars.get('thinkingLevel') }
|
|
156
|
+
: scalars.has('thinking') ? { thinkingLevel: scalars.get('thinking') } : {}),
|
|
157
|
+
...(scalars.has('model') ? { model: scalars.get('model') }
|
|
158
|
+
: lists.get('model')?.length ? { model: lists.get('model')![0] } : {}),
|
|
159
|
+
...(tools ? { tools } : {}),
|
|
160
|
+
...(scalars.has('spawns') ? { spawns: scalars.get('spawns') } : {}),
|
|
161
|
+
body: body.trim(),
|
|
162
|
+
};
|
|
36
163
|
}
|
|
37
164
|
|
|
38
165
|
async function parseAgentFile(filePath: string, sourceRoot: 'user' | 'project'): Promise<DiscoveredAgent | undefined> {
|
|
39
166
|
try {
|
|
40
167
|
const file = Bun.file(filePath);
|
|
41
168
|
if ((await file.stat()).size > 512 * 1024) return undefined;
|
|
42
|
-
const
|
|
43
|
-
const { data, body } = parseFrontmatter(text);
|
|
169
|
+
const parsed = parseAgentDefinition(await file.text());
|
|
44
170
|
const base = basename(filePath).replace(/\.md$/, '') || filePath;
|
|
45
|
-
const name =
|
|
171
|
+
const name = parsed.name || base;
|
|
46
172
|
if (!name) return undefined;
|
|
47
|
-
const temperature = data.temperature !== undefined && data.temperature !== '' ? Number(data.temperature) : null;
|
|
48
|
-
const topP = data.top_p !== undefined && data.top_p !== '' ? Number(data.top_p) : null;
|
|
49
173
|
return {
|
|
50
174
|
id: `omp-${sourceRoot}-${base}`,
|
|
51
175
|
name,
|
|
52
|
-
description:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
systemPrompt: body.trim(),
|
|
176
|
+
description: parsed.description ?? '',
|
|
177
|
+
...(parsed.tools ? { tools: parsed.tools } : {}),
|
|
178
|
+
...(parsed.spawns ? { spawns: parsed.spawns } : {}),
|
|
179
|
+
...(parsed.model ? { model: parsed.model } : {}),
|
|
180
|
+
...(parsed.thinkingLevel ? { thinkingLevel: parsed.thinkingLevel } : {}),
|
|
181
|
+
systemPrompt: parsed.body,
|
|
59
182
|
sourceRoot,
|
|
60
183
|
filePath,
|
|
61
184
|
};
|
|
@@ -98,34 +221,49 @@ export async function discoverNativeAgents(projectDir?: string): Promise<Discove
|
|
|
98
221
|
return [...byBase.values()];
|
|
99
222
|
}
|
|
100
223
|
|
|
101
|
-
/**
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
function optionalFmLine(lines: string[], key: string, value: string | number | null | undefined): void {
|
|
107
|
-
if (value === null || value === undefined || value === '') return;
|
|
108
|
-
lines.push(`${key}: ${typeof value === 'number' ? value : fmValue(String(value))}`);
|
|
224
|
+
/** How many lines a top-level key occupies, continuation lines included. */
|
|
225
|
+
function blockLength(lines: string[], start: number): number {
|
|
226
|
+
let end = start + 1;
|
|
227
|
+
while (end < lines.length && /^\s+\S/.test(lines[end])) end++;
|
|
228
|
+
return end - start;
|
|
109
229
|
}
|
|
110
230
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
231
|
+
/**
|
|
232
|
+
* The YAML lines for one owned key.
|
|
233
|
+
*
|
|
234
|
+
* - `string[]` — write these lines;
|
|
235
|
+
* - `null` — REMOVE the key (that is how omp spells "use the default");
|
|
236
|
+
* - `undefined` — leave whatever the file already has alone.
|
|
237
|
+
*
|
|
238
|
+
* `tools: undefined` is the third case on purpose: the pane does not offer a
|
|
239
|
+
* tool allowlist, and re-serializing one would flatten a block list or, worse,
|
|
240
|
+
* delete a restriction the shipped agent depends on.
|
|
241
|
+
*/
|
|
242
|
+
function renderKey(key: OwnedKey, input: AgentFileInput): string[] | null | undefined {
|
|
243
|
+
if (key === 'tools') {
|
|
244
|
+
if (input.tools === undefined) return undefined;
|
|
245
|
+
return input.tools.length === 0 ? null : [`tools: ${input.tools.join(', ')}`];
|
|
246
|
+
}
|
|
247
|
+
const value = key === 'name' ? input.name
|
|
248
|
+
: key === 'description' ? input.description
|
|
249
|
+
: key === 'model' ? input.model
|
|
250
|
+
: input.spawns;
|
|
251
|
+
if (key === 'thinkingLevel') {
|
|
252
|
+
return input.thinkingLevel ? ['thinkingLevel: ' + input.thinkingLevel] : null;
|
|
253
|
+
}
|
|
254
|
+
if (!value || !value.trim()) return null;
|
|
255
|
+
// `spawns: *` is a YAML alias, so a bare star has to be quoted.
|
|
256
|
+
return [`${key}: ${key === 'spawns' ? quote(value.trim()) : quote(value)}`];
|
|
123
257
|
}
|
|
124
258
|
|
|
125
259
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
260
|
+
* Rewrite one definition file, preserving every line the panel does not own.
|
|
261
|
+
*
|
|
262
|
+
* The owned key is replaced WHERE IT STANDS (rather than the frontmatter being
|
|
263
|
+
* re-serialized from a record), so a shipped agent keeps its key order, its
|
|
264
|
+
* comments, its `tools` list style and its nested `output:` schema. Keys the
|
|
265
|
+
* file lacks are appended in a stable order, so re-saving an untouched file
|
|
266
|
+
* changes nothing but the key that was edited.
|
|
129
267
|
*/
|
|
130
268
|
export async function writeAgentDefinition(input: AgentFileInput): Promise<{ path: string }> {
|
|
131
269
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(input.fileName)) {
|
|
@@ -134,22 +272,54 @@ export async function writeAgentDefinition(input: AgentFileInput): Promise<{ pat
|
|
|
134
272
|
if (!input.systemPrompt.trim()) {
|
|
135
273
|
throw new Error('Agent system prompt cannot be empty');
|
|
136
274
|
}
|
|
275
|
+
|
|
137
276
|
const dir = join(getAgentDir(), 'agents');
|
|
138
277
|
const path = join(dir, `${input.fileName}.md`);
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
278
|
+
const existing = (await Bun.file(path).exists()) ? await Bun.file(path).text() : '';
|
|
279
|
+
const { lines, missing } = splitDefinition(existing);
|
|
280
|
+
|
|
281
|
+
/** Old spellings of keys the panel owns are dropped, so one file cannot carry two. */
|
|
282
|
+
const aliases = new Map<string, OwnedKey>([
|
|
283
|
+
['thinking', 'thinkingLevel'],
|
|
284
|
+
['thinking-level', 'thinkingLevel'],
|
|
285
|
+
]);
|
|
286
|
+
|
|
287
|
+
const output: string[] = [];
|
|
288
|
+
const handled = new Set<OwnedKey>();
|
|
289
|
+
|
|
290
|
+
for (let index = 0; index < lines.length;) {
|
|
291
|
+
const entry = /^([A-Za-z_][\w-]*)\s*:/.exec(lines[index]);
|
|
292
|
+
if (!entry) {
|
|
293
|
+
output.push(lines[index]);
|
|
294
|
+
index += 1;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const key = entry[1];
|
|
298
|
+
const length = blockLength(lines, index);
|
|
299
|
+
const ownedKey = OWNED_KEYS.includes(key as OwnedKey)
|
|
300
|
+
? (key as OwnedKey)
|
|
301
|
+
: aliases.get(key) ?? null;
|
|
302
|
+
const keepVerbatim = ownedKey === null || handled.has(ownedKey);
|
|
303
|
+
const rendered = ownedKey === null ? undefined : renderKey(ownedKey, input);
|
|
304
|
+
if (ownedKey !== null) handled.add(ownedKey);
|
|
305
|
+
if (keepVerbatim || rendered === undefined) {
|
|
306
|
+
for (let offset = 0; offset < length; offset++) output.push(lines[index + offset]);
|
|
307
|
+
} else if (rendered) {
|
|
308
|
+
output.push(...rendered);
|
|
309
|
+
}
|
|
310
|
+
index += length;
|
|
149
311
|
}
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
312
|
+
|
|
313
|
+
for (const key of OWNED_KEYS) {
|
|
314
|
+
if (handled.has(key)) continue;
|
|
315
|
+
const rendered = renderKey(key, input);
|
|
316
|
+
if (rendered) output.push(...rendered);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const prompt = input.systemPrompt.trim();
|
|
320
|
+
const block = `---\n${output.join('\n')}\n---\n\n${prompt}\n`;
|
|
321
|
+
// A file with no frontmatter fences gets one prepended; nothing it held is lost.
|
|
322
|
+
await writeFileAtomic(path, missing && existing.trim() ? `---\n${output.join('\n')}\n---\n\n${existing.trim()}\n` : block);
|
|
153
323
|
return { path };
|
|
154
324
|
}
|
|
155
325
|
|
|
@@ -4,17 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The definition files Kabmo owns
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* omp
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
* and `pluginCliError` prefers stderr. `PI_CODING_AGENT_DIR` points at a temp
|
|
17
|
-
* dir and `KABMO_OMP_BIN` at a stub recording its argv — no real process (the stub is a compiled executable, so it spawns on both platforms).
|
|
7
|
+
* The definition files Kabmo owns besides agent definitions (the instruction
|
|
8
|
+
* files) and the plugin CLI wrapper. Agent discovery and the agent-file writer
|
|
9
|
+
* have their own suite, `agent-definitions.test.ts`.
|
|
10
|
+
*
|
|
11
|
+
* An instruction file of only whitespace REMOVES the file, or an empty AGENTS.md
|
|
12
|
+
* would still claim the context scope; plugin wrappers pass `--scope` only where
|
|
13
|
+
* omp accepts it, and `pluginCliError` prefers stderr. `PI_CODING_AGENT_DIR`
|
|
14
|
+
* points at a temp dir and `KABMO_OMP_BIN` at a stub recording its argv — no real
|
|
15
|
+
* process (the stub is a compiled executable, so it spawns on both platforms).
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
@@ -23,7 +21,6 @@ import fs from 'node:fs';
|
|
|
23
21
|
import { tmpdir } from 'node:os';
|
|
24
22
|
import { join } from 'node:path';
|
|
25
23
|
|
|
26
|
-
import { deleteAgentDefinition, discoverNativeAgents, writeAgentDefinition } from '@/server/lib/omp/config/agents';
|
|
27
24
|
import { invalidateOmpCliCache } from '@/server/lib/omp/core/cli';
|
|
28
25
|
import {
|
|
29
26
|
clearInstructionFile,
|
|
@@ -111,99 +108,6 @@ afterAll(() => {
|
|
|
111
108
|
fs.rmSync(root, { recursive: true, force: true });
|
|
112
109
|
});
|
|
113
110
|
|
|
114
|
-
describe('discoverNativeAgents', () => {
|
|
115
|
-
test('shapes frontmatter, defaults malformed fields, and skips non-markdown entries', async () => {
|
|
116
|
-
write(join(userAgents, 'one.md'), [
|
|
117
|
-
'---',
|
|
118
|
-
'name: First',
|
|
119
|
-
'description: "a description"',
|
|
120
|
-
'mode: subagent',
|
|
121
|
-
'model: fast',
|
|
122
|
-
'thinking: high',
|
|
123
|
-
'temperature: 0.5',
|
|
124
|
-
'top_p: nope',
|
|
125
|
-
'---',
|
|
126
|
-
'',
|
|
127
|
-
' system prompt ',
|
|
128
|
-
'',
|
|
129
|
-
].join('\n'));
|
|
130
|
-
write(join(userAgents, 'two.md'), 'no frontmatter body\n');
|
|
131
|
-
write(join(userAgents, 'ignored.txt'), 'x');
|
|
132
|
-
fs.mkdirSync(join(userAgents, 'nested.md'), { recursive: true });
|
|
133
|
-
|
|
134
|
-
const found = await discoverNativeAgents();
|
|
135
|
-
expect(found.map((agent) => agent.id).sort()).toEqual(['omp-user-one', 'omp-user-two']);
|
|
136
|
-
// By id, never by index: `readdir` order is not guaranteed (Windows returned `two` first).
|
|
137
|
-
const byId = new Map(found.map((agent) => [agent.id, agent]));
|
|
138
|
-
expect(byId.get('omp-user-one')).toMatchObject({
|
|
139
|
-
name: 'First', description: 'a description', mode: 'subagent', overrideModel: 'fast', thinkingVariant: 'high',
|
|
140
|
-
temperature: 0.5, topP: null, systemPrompt: 'system prompt', sourceRoot: 'user', filePath: join(userAgents, 'one.md'),
|
|
141
|
-
});
|
|
142
|
-
expect(byId.get('omp-user-two')).toMatchObject({
|
|
143
|
-
name: 'two', description: '', mode: 'all', temperature: null, topP: null, systemPrompt: 'no frontmatter body',
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('an unrecognized mode and a non-numeric temperature degrade to defaults', async () => {
|
|
148
|
-
write(join(userAgents, 'weird.md'), '---\nmode: wizard\ntemperature: hot\n---\nbody\n');
|
|
149
|
-
const agent = (await discoverNativeAgents()).find((item) => item.id === 'omp-user-weird');
|
|
150
|
-
expect(agent).toMatchObject({ mode: 'all', temperature: null });
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('a user agent wins over a project agent with the same base name', async () => {
|
|
154
|
-
write(join(userAgents, 'shared.md'), '---\nname: FromUser\n---\nuser body\n');
|
|
155
|
-
write(join(projectAgents, 'shared.md'), '---\nname: FromProject\n---\nproject body\n');
|
|
156
|
-
write(join(projectAgents, 'project-only.md'), '---\nname: OnlyProject\n---\nbody\n');
|
|
157
|
-
|
|
158
|
-
const found = await discoverNativeAgents(projectAgents);
|
|
159
|
-
expect(found.find((agent) => agent.filePath === join(userAgents, 'shared.md'))?.name).toBe('FromUser');
|
|
160
|
-
expect(found.some((agent) => agent.filePath === join(projectAgents, 'shared.md'))).toBe(false);
|
|
161
|
-
expect(found.find((agent) => agent.id === 'omp-project-project-only')?.sourceRoot).toBe('project');
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test('an oversized definition is skipped and a missing directory is not an error', async () => {
|
|
165
|
-
write(join(userAgents, 'huge.md'), `---\nname: Huge\n---\n${'x'.repeat(512 * 1024 + 1)}\n`);
|
|
166
|
-
const found = await discoverNativeAgents();
|
|
167
|
-
expect(found.some((agent) => agent.name === 'Huge')).toBe(false);
|
|
168
|
-
expect(await discoverNativeAgents(join(root, 'no-such-dir'))).toEqual(found);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('writeAgentDefinition', () => {
|
|
173
|
-
test('refuses an unsafe file name and an empty system prompt', async () => {
|
|
174
|
-
await expect(writeAgentDefinition({ fileName: '../escape', systemPrompt: 'x' })).rejects.toThrow(/may contain letters/);
|
|
175
|
-
await expect(writeAgentDefinition({ fileName: 'ok', systemPrompt: ' ' })).rejects.toThrow(/cannot be empty/);
|
|
176
|
-
expect(fs.existsSync(join(userAgents, 'ok.md'))).toBe(false);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test('writes omp frontmatter keys, quoting scalars, then deletes on request', async () => {
|
|
180
|
-
const { path } = await writeAgentDefinition({
|
|
181
|
-
fileName: 'written',
|
|
182
|
-
description: 'has "quotes" and \\ slashes',
|
|
183
|
-
mode: 'primary',
|
|
184
|
-
thinking: 'low',
|
|
185
|
-
temperature: 0.2,
|
|
186
|
-
topP: 0.9,
|
|
187
|
-
tools: ['read', 'bash'],
|
|
188
|
-
systemPrompt: 'do the thing',
|
|
189
|
-
});
|
|
190
|
-
expect(path).toBe(join(userAgents, 'written.md'));
|
|
191
|
-
const text = fs.readFileSync(path, 'utf8');
|
|
192
|
-
expect(text).toContain('name: "written"');
|
|
193
|
-
expect(text).toContain('mode: "primary"');
|
|
194
|
-
expect(text).toContain('thinking-level: "low"');
|
|
195
|
-
expect(text).toContain('temperature: 0.2');
|
|
196
|
-
expect(text).toContain('top_p: 0.9');
|
|
197
|
-
expect(text).toContain('tools: "read", "bash"');
|
|
198
|
-
expect(text).toContain('has \\"quotes\\" and \\\\ slashes');
|
|
199
|
-
expect(text.endsWith('\n')).toBe(true);
|
|
200
|
-
|
|
201
|
-
expect(await deleteAgentDefinition('written')).toBe(true);
|
|
202
|
-
expect(await deleteAgentDefinition('written')).toBe(false);
|
|
203
|
-
await expect(deleteAgentDefinition('bad/name')).rejects.toThrow(/Invalid agent file name/);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
111
|
describe('instruction files', () => {
|
|
208
112
|
test('narrows the kind and resolves the two omp basenames', () => {
|
|
209
113
|
expect(isInstructionFileKind('agents')).toBe(true);
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { join } from 'path';
|
|
13
13
|
import { getAgentDir, pathExists } from '@/server/lib/omp/core/paths';
|
|
14
14
|
import { getOmpConfigPath } from '@/server/lib/omp/config/yaml';
|
|
15
|
-
import { withOmpYamlDocument } from '@/server/lib/omp/config/document';
|
|
15
|
+
import { seqAt, valueAt, withOmpYamlDocument } from '@/server/lib/omp/config/document';
|
|
16
16
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
17
17
|
|
|
18
18
|
export interface DiscoveredExtension {
|
|
@@ -75,17 +75,26 @@ export async function readDisabledExtensions(): Promise<Set<string>> {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Toggle one extension id in config.yml `disabledExtensions` atomically.
|
|
80
|
+
*
|
|
81
|
+
* The list is read through `valueAt`, which unwraps the YAML node: `doc.get()`
|
|
82
|
+
* returns a SEQ node, and `Array.isArray` on a node is `false` — so the whole
|
|
83
|
+
* list read as empty. Disabling then wrote a one-item list over the user's
|
|
84
|
+
* others, and ENABLING found the id absent from its own empty view, answered
|
|
85
|
+
* "nothing to do", and left the extension disabled forever.
|
|
86
|
+
*/
|
|
79
87
|
export async function setExtensionDisabled(id: string, disabled: boolean): Promise<boolean> {
|
|
80
88
|
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(id)) throw new Error('Invalid extension id');
|
|
81
89
|
const path = getOmpConfigPath();
|
|
82
90
|
return withOmpYamlDocument(path, (doc) => {
|
|
83
|
-
const
|
|
84
|
-
const list = Array.isArray(
|
|
85
|
-
? current.filter((item): item is string => typeof item === 'string')
|
|
86
|
-
: [];
|
|
91
|
+
const raw = valueAt(doc, ['disabledExtensions']);
|
|
92
|
+
const list = Array.isArray(raw) ? raw.filter((item): item is string => typeof item === 'string') : [];
|
|
87
93
|
if (disabled === list.includes(id)) return { result: false, changed: false };
|
|
88
|
-
|
|
94
|
+
const next = disabled ? [...list, id] : list.filter((item) => item !== id);
|
|
95
|
+
const seq = seqAt(doc, ['disabledExtensions']);
|
|
96
|
+
if (seq) seq.items = next;
|
|
97
|
+
else doc.set('disabledExtensions', next);
|
|
89
98
|
return { result: true, changed: true };
|
|
90
99
|
});
|
|
91
100
|
}
|
|
@@ -248,6 +248,33 @@ describe('extensions', () => {
|
|
|
248
248
|
expect(await setExtensionDisabled('skill:a', false)).toBe(false);
|
|
249
249
|
expect(await fs.promises.readFile(configPath, 'utf8')).toBe('theme: dark\n');
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The list was read with `doc.get()`, which returns a YAML SEQ node —
|
|
254
|
+
* `Array.isArray` on that is `false`, so the panel saw an empty list. Turning
|
|
255
|
+
* an extension back ON then found its id "absent" and answered "nothing to
|
|
256
|
+
* do", leaving it disabled forever; turning one OFF overwrote every other
|
|
257
|
+
* disabled id. Both directions are pinned here.
|
|
258
|
+
*/
|
|
259
|
+
test('disabling keeps the ids already in the list', async () => {
|
|
260
|
+
const agent = await freshAgentDir();
|
|
261
|
+
const configPath = join(agent, 'config.yml');
|
|
262
|
+
await Bun.write(configPath, 'disabledExtensions:\n - skill:a\n - skill:b\n');
|
|
263
|
+
expect(await setExtensionDisabled('extension-module:c', true)).toBe(true);
|
|
264
|
+
expect(Bun.YAML.parse(await fs.promises.readFile(configPath, 'utf8'))).toEqual({
|
|
265
|
+
disabledExtensions: ['skill:a', 'skill:b', 'extension-module:c'],
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test('enabling removes only its own id and reports the change', async () => {
|
|
270
|
+
const agent = await freshAgentDir();
|
|
271
|
+
const configPath = join(agent, 'config.yml');
|
|
272
|
+
await Bun.write(configPath, 'disabledExtensions:\n - skill:a\n - skill:b\n');
|
|
273
|
+
expect(await setExtensionDisabled('skill:a', false)).toBe(true);
|
|
274
|
+
expect(Bun.YAML.parse(await fs.promises.readFile(configPath, 'utf8'))).toEqual({
|
|
275
|
+
disabledExtensions: ['skill:b'],
|
|
276
|
+
});
|
|
277
|
+
});
|
|
251
278
|
});
|
|
252
279
|
|
|
253
280
|
describe('behavior rules', () => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The stored catalog sources — the git repositories the Skills Catalog offers.
|
|
8
|
+
*
|
|
9
|
+
* Its own module because two surfaces read it (the loader's payload and every
|
|
10
|
+
* source mutation) and a second reader is how the two shapes would drift. The
|
|
11
|
+
* normalisation is the whole job: a source written by the previous UI carried
|
|
12
|
+
* `stars` and `updatedAt` literals that no request had produced, and a count
|
|
13
|
+
* that was never measured. Reading through `toCatalogSource` drops the first two
|
|
14
|
+
* and turns a missing count into `null` — "not scanned" — which is what the card
|
|
15
|
+
* prints. A guessed number is indistinguishable from a measured one once it is on
|
|
16
|
+
* screen, so it is never stored.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { SkillCatalogSource } from '@/shared/types';
|
|
20
|
+
import { DEFAULT_CATALOG_SOURCES } from '@/client/data/settings/skill';
|
|
21
|
+
import { readSettingsJson, writeSettingsJson } from '@/server/lib/db/settings-store';
|
|
22
|
+
import type { DbClient } from '@/server/lib/db/client';
|
|
23
|
+
|
|
24
|
+
export const SOURCES_KEY = 'omp_catalog_sources';
|
|
25
|
+
|
|
26
|
+
/** One stored record, narrowed to the fields this build understands. */
|
|
27
|
+
export function toCatalogSource(source: Partial<SkillCatalogSource>): SkillCatalogSource {
|
|
28
|
+
return {
|
|
29
|
+
id: String(source.id ?? ''),
|
|
30
|
+
name: String(source.name ?? source.repo ?? 'source'),
|
|
31
|
+
repo: String(source.repo ?? ''),
|
|
32
|
+
skillCount: typeof source.skillCount === 'number' ? source.skillCount : null,
|
|
33
|
+
scannedAt: typeof source.scannedAt === 'number' ? source.scannedAt : null,
|
|
34
|
+
isCustom: source.isCustom === true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Every source, with the shipped defaults standing in when none is stored. */
|
|
39
|
+
export async function readCatalogSources(db: DbClient): Promise<SkillCatalogSource[]> {
|
|
40
|
+
const stored = await readSettingsJson<Partial<SkillCatalogSource>[]>(db, SOURCES_KEY, DEFAULT_CATALOG_SOURCES);
|
|
41
|
+
const list = Array.isArray(stored) && stored.length > 0 ? stored : DEFAULT_CATALOG_SOURCES;
|
|
42
|
+
// `toCatalogSource` with no id is a record this build cannot address; drop it
|
|
43
|
+
// rather than render a card every action would 404 on.
|
|
44
|
+
return list.map(toCatalogSource).filter((source) => source.id.length > 0 && source.repo.length > 0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function writeCatalogSources(db: DbClient, sources: SkillCatalogSource[]): Promise<void> {
|
|
48
|
+
await writeSettingsJson(db, SOURCES_KEY, sources);
|
|
49
|
+
}
|