@kabmo-labs/kabmo 0.16.0 → 0.17.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 +417 -417
- package/dist/client/static/js/index-3ve31rzx.css +1 -0
- package/dist/client/static/js/{index-cpydmygd.js → index-rerjq5th.js} +839 -837
- package/package.json +1 -1
- 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/{server-switcher/index.tsx → server-control/Panel.tsx} +73 -35
- package/src/client/components/common/{server-switcher → server-control}/index.test.tsx +98 -37
- package/src/client/components/common/server-control/index.tsx +118 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
- package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
- package/src/client/components/settings/Modal.tsx +9 -3
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
- package/src/client/components/settings/categories/AgentSettings.tsx +27 -6
- 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 +6 -3
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +5 -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 +208 -0
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +137 -232
- package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +123 -87
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -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/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/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/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/data/settings/omp-schema.json +91 -4
- package/src/client/data/settings/project.ts +9 -28
- package/src/client/data/settings/skill.ts +6 -32
- package/src/client/hooks/chat/timeline/pending-model.ts +28 -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/shell/servers.test.ts +166 -0
- package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
- 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/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/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/server/lib/fs/git-merge-conflict.test.ts +14 -1
- 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/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/settings/agents.ts +19 -7
- 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 +5 -2
- 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/shared/lib/fs/folder-chain.test.ts +81 -1
- package/src/shared/lib/fs/folder-chain.ts +84 -0
- package/src/shared/lib/omp/config/schema.test.ts +35 -0
- 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/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/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/settings/skill.ts +53 -3
- 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/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/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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The accent palette a workspace may be marked with, in ONE table.
|
|
8
|
+
*
|
|
9
|
+
* The server serves it and the settings palette falls back to it, so the two
|
|
10
|
+
* cannot disagree about which swatches exist — they were duplicated before, and
|
|
11
|
+
* a colour added on one side was simply missing on the other.
|
|
12
|
+
*
|
|
13
|
+
* These are DATA, not theme tokens: an accent is a per-project mark, and every
|
|
14
|
+
* value here is drawn as a swatch (never as component chrome), which is why they
|
|
15
|
+
* are allowed literal hex. This table is the PRESETS — a user may also store any
|
|
16
|
+
* other hex through the custom picker, so nothing may treat membership here as
|
|
17
|
+
* the set of valid accents.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { AccentColorOption } from '@/shared/types';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
The accent the custom picker starts on: a violet that is deliberately NOT one of
|
|
24
|
+
the swatches, so the custom control is visibly its own choice rather than an
|
|
25
|
+
eleventh preset.
|
|
26
|
+
*/
|
|
27
|
+
export const DEFAULT_CUSTOM_ACCENT = '#7c3aed';
|
|
28
|
+
|
|
29
|
+
/** An accent may be empty (no mark) or `#rgb` / `#rrggbb`, nothing else. */
|
|
30
|
+
const HEX_ACCENT = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
The stored form of a hex accent: lowercase, always six digits.
|
|
34
|
+
|
|
35
|
+
Returns `null` for anything that is not a hex colour, so the caller decides
|
|
36
|
+
whether to refuse it or fall back — this module does not guess. The accent ends
|
|
37
|
+
up in a CSS `color`, and a free-form string there is a style injection: `red;
|
|
38
|
+
background:url(…)` paints the sidebar.
|
|
39
|
+
*/
|
|
40
|
+
export function normalizeHexAccent(value: string): string | null {
|
|
41
|
+
if (!HEX_ACCENT.test(value)) return null;
|
|
42
|
+
const lower = value.toLowerCase();
|
|
43
|
+
if (lower.length === 7) return lower;
|
|
44
|
+
return `#${lower[1]}${lower[1]}${lower[2]}${lower[2]}${lower[3]}${lower[3]}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** True when the value is a stored-form hex accent, i.e. what the server keeps. */
|
|
48
|
+
export function isHexAccent(value: string): boolean {
|
|
49
|
+
return normalizeHexAccent(value) === value && value !== '';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const PROJECT_ACCENT_OPTIONS: AccentColorOption[] = [
|
|
53
|
+
{ label: 'None', value: '', bgHex: 'transparent' },
|
|
54
|
+
{ label: 'Sky Blue', value: '#38bdf8', bgHex: '#38bdf8' },
|
|
55
|
+
{ label: 'Light Green', value: '#a3e635', bgHex: '#a3e635' },
|
|
56
|
+
{ label: 'Coral', value: '#f87171', bgHex: '#f87171' },
|
|
57
|
+
{ label: 'Amber', value: '#fbbf24', bgHex: '#fbbf24' },
|
|
58
|
+
{ label: 'Teal', value: '#2dd4bf', bgHex: '#2dd4bf' },
|
|
59
|
+
{ label: 'Slate', value: '#94a3b8', bgHex: '#94a3b8' },
|
|
60
|
+
{ label: 'Rose', value: '#f43f5e', bgHex: '#f43f5e' },
|
|
61
|
+
{ label: 'Vivid Blue', value: '#3b82f6', bgHex: '#3b82f6' },
|
|
62
|
+
{ label: 'Lime Green', value: '#84cc16', bgHex: '#84cc16' },
|
|
63
|
+
];
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { BookOpen, Briefcase, Camera, Code2, Database, FlaskConical, Folder, Gamepad2, Globe, Heart, Home, Leaf, Lightbulb, Music, Palette, Rocket, Server, Shield, Smartphone, Terminal } from 'lucide-preact';
|
|
2
2
|
import type { LucideIcon } from 'lucide-preact';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The workspace icon set, in ONE table.
|
|
6
|
+
*
|
|
7
|
+
* Three surfaces draw a project's mark — the settings grid, the settings list
|
|
8
|
+
* and every sidebar/mobile row — and each used to carry its own map. They had
|
|
9
|
+
* already drifted (`default` was a folder in the sidebar and an ✕ in the
|
|
10
|
+
* settings grid, which reads as "clear the icon"), so the ids, their labels and
|
|
11
|
+
* the glyphs live here and the pickers iterate {@link PROJECT_ICON_OPTIONS}.
|
|
12
|
+
*/
|
|
4
13
|
const PROJECT_ICON_MAP: Record<string, LucideIcon> = {
|
|
5
14
|
default: Folder,
|
|
6
15
|
code: Code2,
|
|
@@ -24,6 +33,37 @@ const PROJECT_ICON_MAP: Record<string, LucideIcon> = {
|
|
|
24
33
|
heart: Heart,
|
|
25
34
|
};
|
|
26
35
|
|
|
36
|
+
export interface ProjectIconOption {
|
|
37
|
+
id: string;
|
|
38
|
+
label: string;
|
|
39
|
+
icon: LucideIcon;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Every pickable icon, in the grid's display order. */
|
|
43
|
+
export const PROJECT_ICON_OPTIONS: ProjectIconOption[] = [
|
|
44
|
+
{ id: 'default', label: 'Default folder', icon: Folder },
|
|
45
|
+
{ id: 'code', label: 'Code', icon: Code2 },
|
|
46
|
+
{ id: 'terminal', label: 'Terminal', icon: Terminal },
|
|
47
|
+
{ id: 'rocket', label: 'Rocket', icon: Rocket },
|
|
48
|
+
{ id: 'flask', label: 'Flask', icon: FlaskConical },
|
|
49
|
+
{ id: 'gamepad', label: 'Gamepad', icon: Gamepad2 },
|
|
50
|
+
{ id: 'briefcase', label: 'Briefcase', icon: Briefcase },
|
|
51
|
+
{ id: 'home', label: 'Home', icon: Home },
|
|
52
|
+
{ id: 'globe', label: 'Globe', icon: Globe },
|
|
53
|
+
{ id: 'leaf', label: 'Leaf', icon: Leaf },
|
|
54
|
+
{ id: 'shield', label: 'Shield', icon: Shield },
|
|
55
|
+
{ id: 'palette', label: 'Palette', icon: Palette },
|
|
56
|
+
{ id: 'server', label: 'Server', icon: Server },
|
|
57
|
+
{ id: 'smartphone', label: 'Smartphone', icon: Smartphone },
|
|
58
|
+
{ id: 'database', label: 'Database', icon: Database },
|
|
59
|
+
{ id: 'lightbulb', label: 'Lightbulb', icon: Lightbulb },
|
|
60
|
+
{ id: 'music', label: 'Music', icon: Music },
|
|
61
|
+
{ id: 'camera', label: 'Camera', icon: Camera },
|
|
62
|
+
{ id: 'book', label: 'Book', icon: BookOpen },
|
|
63
|
+
{ id: 'heart', label: 'Heart', icon: Heart },
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/** The glyph for a stored icon id, falling back to the plain folder. */
|
|
27
67
|
export function getProjectIcon(icon: string | undefined): LucideIcon {
|
|
28
68
|
return PROJECT_ICON_MAP[icon || 'default'] || Folder;
|
|
29
69
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The project default-model value.
|
|
8
|
+
*
|
|
9
|
+
* The failure this guards is silent: a bare display name or an id without its
|
|
10
|
+
* provider parses to a "model" that either no provider serves or that resolves
|
|
11
|
+
* to whichever provider happens to come first, and the chat then starts on a
|
|
12
|
+
* model the project never asked for.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
NO_PROJECT_MODEL,
|
|
19
|
+
parseProjectModel,
|
|
20
|
+
projectModelLabel,
|
|
21
|
+
projectModelValue,
|
|
22
|
+
} from '@/shared/lib/workspace/project-model';
|
|
23
|
+
|
|
24
|
+
describe('parseProjectModel', () => {
|
|
25
|
+
test('reads a composite provider:model value', () => {
|
|
26
|
+
expect(parseProjectModel('kenari:deepseek-v4-flash')).toEqual({
|
|
27
|
+
provider: 'kenari',
|
|
28
|
+
modelId: 'deepseek-v4-flash',
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('trims both halves and keeps an id that carries a colon', () => {
|
|
33
|
+
expect(parseProjectModel(' openrouter : vendor/model:x ')).toEqual({
|
|
34
|
+
provider: 'openrouter',
|
|
35
|
+
modelId: 'vendor/model:x',
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('the schema default and a legacy display name both read as "inherit"', () => {
|
|
40
|
+
expect(parseProjectModel(NO_PROJECT_MODEL)).toBeNull();
|
|
41
|
+
expect(parseProjectModel('GPT-4o')).toBeNull();
|
|
42
|
+
expect(parseProjectModel('DeepSeek-V3')).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('malformed values never become a half-named model', () => {
|
|
46
|
+
expect(parseProjectModel('')).toBeNull();
|
|
47
|
+
expect(parseProjectModel(' ')).toBeNull();
|
|
48
|
+
expect(parseProjectModel(':gpt')).toBeNull();
|
|
49
|
+
expect(parseProjectModel('gpt:')).toBeNull();
|
|
50
|
+
expect(parseProjectModel(null)).toBeNull();
|
|
51
|
+
expect(parseProjectModel(42)).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('projectModelValue / projectModelLabel', () => {
|
|
56
|
+
test('round-trips through the composite value', () => {
|
|
57
|
+
const value = projectModelValue({ provider: 'kenari', modelId: 'deepseek-v4-flash' });
|
|
58
|
+
expect(value).toBe('kenari:deepseek-v4-flash');
|
|
59
|
+
expect(parseProjectModel(value)).toEqual({ provider: 'kenari', modelId: 'deepseek-v4-flash' });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('a stored model the catalog still serves is labelled with its display name', () => {
|
|
63
|
+
expect(
|
|
64
|
+
projectModelLabel('kenari:deepseek-v4-flash', [
|
|
65
|
+
{ id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash', provider: 'kenari' },
|
|
66
|
+
{ id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash (direct)', provider: 'deepseek' },
|
|
67
|
+
]),
|
|
68
|
+
).toBe('kenari · DeepSeek V4 Flash');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('a stale stored model is still named, so it does not read as "inherit"', () => {
|
|
72
|
+
expect(projectModelLabel('kenari:gone', [])).toBe('kenari · gone');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('an unset value has no label', () => {
|
|
76
|
+
expect(projectModelLabel(NO_PROJECT_MODEL, [])).toBeNull();
|
|
77
|
+
expect(projectModelLabel('', [])).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The default model a workspace folder can carry for its new chats.
|
|
8
|
+
*
|
|
9
|
+
* Stored as the COMPOSITE `provider:modelId` identity, the same one
|
|
10
|
+
* `modelKey` uses, because a model id alone is not unique — the omp registry
|
|
11
|
+
* serves the same id from several providers, and a value keyed on the id alone
|
|
12
|
+
* would silently mean "whichever provider came first".
|
|
13
|
+
*
|
|
14
|
+
* `Not selected` is the historical default written by the schema, and legacy
|
|
15
|
+
* rows also hold bare display names from the retired hardcoded list. Neither
|
|
16
|
+
* resolves to a model, so they read as "inherit Kabmo's default" rather than as
|
|
17
|
+
* a model nobody can start a chat on.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { SelectedModel } from '@/shared/types';
|
|
21
|
+
|
|
22
|
+
/** The stored spelling of "no project default". */
|
|
23
|
+
export const NO_PROJECT_MODEL = 'Not selected';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Read a stored project-model value. Anything that is not a non-empty
|
|
27
|
+
* `provider:modelId` pair — including the legacy display names — yields null.
|
|
28
|
+
*/
|
|
29
|
+
export function parseProjectModel(value: unknown): SelectedModel | null {
|
|
30
|
+
if (typeof value !== 'string') return null;
|
|
31
|
+
const trimmed = value.trim();
|
|
32
|
+
if (!trimmed || trimmed === NO_PROJECT_MODEL) return null;
|
|
33
|
+
|
|
34
|
+
const separator = trimmed.indexOf(':');
|
|
35
|
+
if (separator <= 0 || separator === trimmed.length - 1) return null;
|
|
36
|
+
|
|
37
|
+
const provider = trimmed.slice(0, separator).trim();
|
|
38
|
+
const modelId = trimmed.slice(separator + 1).trim();
|
|
39
|
+
if (!provider || !modelId) return null;
|
|
40
|
+
|
|
41
|
+
return { provider, modelId };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The stored spelling of a picked model. */
|
|
45
|
+
export function projectModelValue(model: { provider: string; modelId: string }): string {
|
|
46
|
+
return `${model.provider}:${model.modelId}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The label a stored value gets in a picker: the live catalog's display name
|
|
51
|
+
* when the catalog still serves it, else the raw stored string so a stale pick
|
|
52
|
+
* is visible instead of looking like "inherit".
|
|
53
|
+
*/
|
|
54
|
+
export function projectModelLabel(
|
|
55
|
+
value: string,
|
|
56
|
+
entries: readonly { id: string; name: string; provider: string }[],
|
|
57
|
+
): string | null {
|
|
58
|
+
const parsed = parseProjectModel(value);
|
|
59
|
+
if (!parsed) return null;
|
|
60
|
+
const match = entries.find(
|
|
61
|
+
(entry) => entry.id === parsed.modelId && entry.provider === parsed.provider,
|
|
62
|
+
);
|
|
63
|
+
return match ? `${match.provider} · ${match.name || match.id}` : `${parsed.provider} · ${parsed.modelId}`;
|
|
64
|
+
}
|
|
@@ -26,13 +26,23 @@ export interface SkillItem {
|
|
|
26
26
|
catalogSource?: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A git repository offered as a skill source.
|
|
31
|
+
*
|
|
32
|
+
* There is deliberately no star count and no "last updated" here: Kabmo never
|
|
33
|
+
* fetched either one, and the two used to be rendered from literals (`'1.2K'`,
|
|
34
|
+
* `'Just now'`) — a panel stating a number no request produced. `skillCount` is
|
|
35
|
+
* `null` until a scan of that repository reports a real one, and the card says
|
|
36
|
+
* "Not scanned" rather than inventing a number.
|
|
37
|
+
*/
|
|
29
38
|
export interface SkillCatalogSource {
|
|
30
39
|
id: string;
|
|
31
40
|
name: string;
|
|
32
41
|
repo: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
/** SKILL.md files found by the last scan, or null when never scanned. */
|
|
43
|
+
skillCount: number | null;
|
|
44
|
+
/** Epoch ms of the last successful scan, or null. */
|
|
45
|
+
scannedAt?: number | null;
|
|
36
46
|
isCustom?: boolean;
|
|
37
47
|
}
|
|
38
48
|
|
|
@@ -45,4 +55,44 @@ export interface CatalogSkillItem {
|
|
|
45
55
|
githubUrl?: string;
|
|
46
56
|
instructions?: string;
|
|
47
57
|
installed?: boolean;
|
|
58
|
+
/** Install count reported by skills.sh; absent for a git-repo entry. */
|
|
59
|
+
installs?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** One SKILL.md found inside a cloned repository. */
|
|
63
|
+
export interface GitSkillEntry {
|
|
64
|
+
/** Repo-relative directory holding the SKILL.md, e.g. `skills/review-pr`. */
|
|
65
|
+
path: string;
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
/** False when omp would refuse to load it (no `description` in frontmatter). */
|
|
69
|
+
loadable: boolean;
|
|
70
|
+
/** A skill with this name is already installed, so a plain install skips it. */
|
|
71
|
+
installed?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** What `inspect_git_repo` answers: the repository and the skills inside it. */
|
|
75
|
+
export interface GitRepoInspection {
|
|
76
|
+
repo: string;
|
|
77
|
+
/** Branch/tag the clone resolved, when git reported one. */
|
|
78
|
+
ref?: string | null;
|
|
79
|
+
skills: GitSkillEntry[];
|
|
80
|
+
/** Notes worth showing (a scan hit its cap, a subtree was skipped, …). */
|
|
81
|
+
notes: string[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** How an imported skill is installed. */
|
|
85
|
+
export type GitSkillInstallMode =
|
|
86
|
+
/** Copy the SKILL.md directory into a root Kabmo owns; editable here. */
|
|
87
|
+
| 'managed_copy'
|
|
88
|
+
/** `bunx skills add` into `~/.agents/skills`; read-only here, updatable. */
|
|
89
|
+
| 'registry';
|
|
90
|
+
|
|
91
|
+
export interface GitSkillInstallResult {
|
|
92
|
+
repo: string;
|
|
93
|
+
mode: GitSkillInstallMode;
|
|
94
|
+
installed: string[];
|
|
95
|
+
skipped: Array<{ name: string; reason: string }>;
|
|
96
|
+
/** The refreshed discovery list, so the pane needs no second round trip. */
|
|
97
|
+
skills: SkillItem[];
|
|
48
98
|
}
|
|
@@ -48,13 +48,37 @@ function splitPath(path: string): { dir: string; name: string } {
|
|
|
48
48
|
return cut === -1 ? { dir: '.', name: path } : { dir: path.slice(0, cut), name: path.slice(cut + 1) };
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Apply a rename: remove the old entry, write the new one, kind preserved.
|
|
53
|
+
*
|
|
54
|
+
* A FOLDER takes its subtree with it — `fs.rename` moves the directory and
|
|
55
|
+
* everything under it, and a double that moved only the top entry would let a
|
|
56
|
+
* spec assert a tree the real route never produces (the reported rename of a
|
|
57
|
+
* collapsed chain left the levels beneath it behind for exactly that reason).
|
|
58
|
+
* Every directory the old path owned is rekeyed, and the entry is then placed
|
|
59
|
+
* the way a create places one.
|
|
60
|
+
*/
|
|
52
61
|
export function moveOnDisk(disk: Disk, fromPath: string, toPath: string): void {
|
|
53
62
|
const from = splitPath(fromPath);
|
|
54
63
|
const source = disk[from.dir];
|
|
55
64
|
const kind = source?.[from.name] === null ? 'folder' : 'file';
|
|
56
65
|
if (source) delete source[from.name];
|
|
66
|
+
if (kind === 'folder') {
|
|
67
|
+
const children = Object.keys(disk)
|
|
68
|
+
.filter((key) => key === fromPath || key.startsWith(`${fromPath}/`))
|
|
69
|
+
.map((key) => [key, disk[key]!] as const);
|
|
70
|
+
for (const [key] of children) delete disk[key];
|
|
71
|
+
for (const [key, listing] of children) disk[`${toPath}${key.slice(fromPath.length)}`] = listing;
|
|
72
|
+
}
|
|
57
73
|
const to = splitPath(toPath);
|
|
74
|
+
// The real route creates the destination's parents (`mkdir -p`), which is
|
|
75
|
+
// what makes a rename INTO a new nested folder work.
|
|
76
|
+
let parent = '';
|
|
77
|
+
for (const segment of to.dir === '.' ? [] : to.dir.split('/')) {
|
|
78
|
+
listingOf(disk, parent || '.')[segment] = null;
|
|
79
|
+
parent = parent ? `${parent}/${segment}` : segment;
|
|
80
|
+
listingOf(disk, parent);
|
|
81
|
+
}
|
|
58
82
|
writeToDisk(disk, to.dir, to.name, kind);
|
|
59
83
|
}
|
|
60
84
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel harness's drag gestures, as a sequence of real DOM events.
|
|
8
|
+
*
|
|
9
|
+
* Split from `file-explorer.test-util.ts` (which is at the repository's line
|
|
10
|
+
* ceiling) and kept beside the disk double because the two answer the same
|
|
11
|
+
* question: a drag is only meaningful against a directory model that can move
|
|
12
|
+
* an entry. Three gestures are what the panel's specs drive it with:
|
|
13
|
+
*
|
|
14
|
+
* - **`dragRow`** — start on a row, drop on a row or the background.
|
|
15
|
+
* - **`hoverRow`** — start, hover an accepting row, and STOP. A hovered
|
|
16
|
+
* collapsed chain UNFOLDS, so the level it exposes is a row only afterwards;
|
|
17
|
+
* a spec that drags straight to that level would be aiming at a row that did
|
|
18
|
+
* not exist when the gesture began.
|
|
19
|
+
* - **`releaseDrag`** — let go without dropping anywhere.
|
|
20
|
+
*
|
|
21
|
+
* A real `DataTransfer` does not exist in happy-dom, and the handlers read only
|
|
22
|
+
* `setData`/`getData`/`dropEffect`, so a minimal stand-in is what the event
|
|
23
|
+
* carries — without it the row's `dragstart` handler would throw on `setData`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { act } from 'preact/test-utils';
|
|
27
|
+
|
|
28
|
+
/** The shape the row handlers read off `event.dataTransfer`. */
|
|
29
|
+
export interface StubTransfer {
|
|
30
|
+
data: Record<string, string>;
|
|
31
|
+
effectAllowed: string;
|
|
32
|
+
dropEffect: string;
|
|
33
|
+
types: string[];
|
|
34
|
+
setData: (type: string, value: string) => void;
|
|
35
|
+
getData: (type: string) => string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The transfer object the drag handlers read (happy-dom has no `DataTransfer`). */
|
|
39
|
+
export function transferOf(): StubTransfer {
|
|
40
|
+
return {
|
|
41
|
+
data: {} as Record<string, string>,
|
|
42
|
+
effectAllowed: '',
|
|
43
|
+
dropEffect: '',
|
|
44
|
+
types: [] as string[],
|
|
45
|
+
setData(type: string, value: string) {
|
|
46
|
+
this.data[type] = value;
|
|
47
|
+
},
|
|
48
|
+
getData(type: string) {
|
|
49
|
+
return this.data[type] ?? '';
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Dispatch one drag action inside `act`, then let the render it queued settle.
|
|
56
|
+
*
|
|
57
|
+
* `passes` is how many empty turns the caller needs afterwards — the panel's own
|
|
58
|
+
* drag path is synchronous, so this is a flush, not a wait.
|
|
59
|
+
*/
|
|
60
|
+
export async function settleDrag(dispatch: () => void, passes: number): Promise<void> {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
dispatch();
|
|
63
|
+
});
|
|
64
|
+
for (let i = 0; i < passes; i += 1) await act(async () => {});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Dispatch one drag event carrying the stub transfer. */
|
|
68
|
+
export function fireDrag(element: HTMLElement, type: string, transfer: StubTransfer): Event {
|
|
69
|
+
const event = new window.Event(type, { bubbles: true, cancelable: true });
|
|
70
|
+
Object.defineProperty(event, 'dataTransfer', { value: transfer });
|
|
71
|
+
element.dispatchEvent(event);
|
|
72
|
+
return event;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The element carrying a row's handlers, found by the row's visible text.
|
|
77
|
+
*
|
|
78
|
+
* The deepest `div` whose own text is exactly the name is the row's inner
|
|
79
|
+
* content, and the element that CLOSES over `[draggable]` is the handler row —
|
|
80
|
+
* dispatching on the wrapper would bubble past the row into the panel
|
|
81
|
+
* background, which is a different drop target.
|
|
82
|
+
*/
|
|
83
|
+
export function rowElementFor(container: HTMLElement, name: string): HTMLElement {
|
|
84
|
+
const matches = [...container.querySelectorAll('div')].filter((el) => el.textContent?.trim() === name);
|
|
85
|
+
const inner = matches[matches.length - 1];
|
|
86
|
+
if (!inner) throw new Error(`no row named ${name}`);
|
|
87
|
+
return (inner.closest('[draggable]') as HTMLElement | null) ?? (inner.parentElement as HTMLElement);
|
|
88
|
+
}
|
|
@@ -27,6 +27,7 @@ import { installDomGlobals, pristineWebSocket, restoreDomGlobals } from '@/test-
|
|
|
27
27
|
import type { TopicResolver } from '@/server/lib/realtime/hub.server';
|
|
28
28
|
import type { GitStatusPayload } from '@/server/lib/fs/git-status-read';
|
|
29
29
|
import { diskHas, entriesOf, moveOnDisk, writeToDisk, type Disk } from '@/test-support/file-explorer-disk.test-util';
|
|
30
|
+
import { fireDrag, rowElementFor, settleDrag, transferOf } from '@/test-support/file-explorer-drag.test-util';
|
|
30
31
|
|
|
31
32
|
export type { Disk } from '@/test-support/file-explorer-disk.test-util';
|
|
32
33
|
|
|
@@ -80,12 +81,30 @@ export interface FileExplorerHarness {
|
|
|
80
81
|
clickMenuRow: (label: string) => Promise<void>;
|
|
81
82
|
/** Drag `from` onto `to` (or the background when null): dragstart, dragover, drop. */
|
|
82
83
|
dragRow: (from: string, to: string | null) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Hover `over` with `from` in flight and stop there.
|
|
86
|
+
*
|
|
87
|
+
* A drop is not always the whole story: a hovered collapsed chain UNFOLDS, and
|
|
88
|
+
* the level it exposed is a row only once that has happened — which is what a
|
|
89
|
+
* drag to `dev/src/main` inside the row labelled `dev/src/main/code` needs.
|
|
90
|
+
*/
|
|
91
|
+
hoverRow: (from: string, over: string) => Promise<void>;
|
|
92
|
+
/** Let go of a drag started by `hoverRow`, without dropping it anywhere. */
|
|
93
|
+
releaseDrag: (from: string) => Promise<void>;
|
|
94
|
+
/** Start a drag and leave it in flight over nothing. */
|
|
95
|
+
startDrag: (from: string) => Promise<void>;
|
|
96
|
+
/** Drop the drag in flight on the panel background — the listing root. */
|
|
97
|
+
dropOnBackground: () => Promise<void>;
|
|
98
|
+
/** The element carrying a row's drag handlers, by the row's visible text. */
|
|
99
|
+
rowFor: (name: string) => HTMLElement;
|
|
83
100
|
/** DOM globals for the whole file (call from beforeAll / afterAll). */
|
|
84
101
|
install: () => void;
|
|
85
102
|
restore: () => void;
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
export function createFileExplorerHarness(): FileExplorerHarness {
|
|
106
|
+
/** The transfer of a drag left in flight by `startDrag`. */
|
|
107
|
+
let inFlight = transferOf();
|
|
89
108
|
const harness: FileExplorerHarness = {
|
|
90
109
|
disk: {},
|
|
91
110
|
dirReads: [],
|
|
@@ -295,53 +314,34 @@ export function createFileExplorerHarness(): FileExplorerHarness {
|
|
|
295
314
|
for (let i = 0; i < 5; i += 1) await act(async () => {});
|
|
296
315
|
},
|
|
297
316
|
async dragRow(from, to) {
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Object.defineProperty(event, 'dataTransfer', { value: transfer });
|
|
327
|
-
element.dispatchEvent(event);
|
|
328
|
-
return event;
|
|
329
|
-
};
|
|
330
|
-
await act(async () => {
|
|
331
|
-
fire(source, 'dragstart');
|
|
332
|
-
});
|
|
333
|
-
for (let i = 0; i < 3; i += 1) await act(async () => {});
|
|
334
|
-
await act(async () => {
|
|
335
|
-
fire(target, 'dragover');
|
|
336
|
-
});
|
|
337
|
-
for (let i = 0; i < 3; i += 1) await act(async () => {});
|
|
338
|
-
await act(async () => {
|
|
339
|
-
fire(target, 'drop');
|
|
340
|
-
});
|
|
341
|
-
await act(async () => {
|
|
342
|
-
fire(source, 'dragend');
|
|
343
|
-
});
|
|
344
|
-
for (let i = 0; i < 20; i += 1) await act(async () => {});
|
|
317
|
+
const source = harness.rowFor(from);
|
|
318
|
+
const target = to === null ? harness.panelBackground() : harness.rowFor(to);
|
|
319
|
+
const transfer = transferOf();
|
|
320
|
+
await settleDrag(() => fireDrag(source, 'dragstart', transfer), 3);
|
|
321
|
+
await settleDrag(() => fireDrag(target, 'dragover', transfer), 3);
|
|
322
|
+
await settleDrag(() => fireDrag(target, 'drop', transfer), 0);
|
|
323
|
+
await settleDrag(() => fireDrag(source, 'dragend', transfer), 20);
|
|
324
|
+
},
|
|
325
|
+
async hoverRow(from, over) {
|
|
326
|
+
inFlight = transferOf();
|
|
327
|
+
await settleDrag(() => fireDrag(harness.rowFor(from), 'dragstart', inFlight), 3);
|
|
328
|
+
await settleDrag(() => fireDrag(harness.rowFor(over), 'dragover', inFlight), 5);
|
|
329
|
+
},
|
|
330
|
+
async releaseDrag(from) {
|
|
331
|
+
await settleDrag(() => fireDrag(harness.rowFor(from), 'dragend', inFlight), 20);
|
|
332
|
+
},
|
|
333
|
+
async startDrag(from) {
|
|
334
|
+
inFlight = transferOf();
|
|
335
|
+
await settleDrag(() => fireDrag(harness.rowFor(from), 'dragstart', inFlight), 3);
|
|
336
|
+
},
|
|
337
|
+
async dropOnBackground() {
|
|
338
|
+
const background = harness.panelBackground();
|
|
339
|
+
await settleDrag(() => fireDrag(background, 'dragenter', inFlight), 3);
|
|
340
|
+
await settleDrag(() => fireDrag(background, 'dragover', inFlight), 3);
|
|
341
|
+
await settleDrag(() => fireDrag(background, 'drop', inFlight), 20);
|
|
342
|
+
},
|
|
343
|
+
rowFor(name: string) {
|
|
344
|
+
return rowElementFor(harness.container, name);
|
|
345
345
|
},
|
|
346
346
|
};
|
|
347
347
|
return harness;
|