@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.
Files changed (131) hide show
  1. package/README.md +2 -2
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +417 -417
  4. package/dist/client/static/js/index-3ve31rzx.css +1 -0
  5. package/dist/client/static/js/{index-cpydmygd.js → index-rerjq5th.js} +839 -837
  6. package/package.json +1 -1
  7. package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
  8. package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
  9. package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
  10. package/src/client/components/common/code-surface/extensions.ts +7 -4
  11. package/src/client/components/common/code-surface/theme.ts +34 -9
  12. package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
  13. package/src/client/components/common/code-surface/whitespace.ts +140 -0
  14. package/src/client/components/common/{server-switcher/index.tsx → server-control/Panel.tsx} +73 -35
  15. package/src/client/components/common/{server-switcher → server-control}/index.test.tsx +98 -37
  16. package/src/client/components/common/server-control/index.tsx +118 -0
  17. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
  18. package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
  19. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
  20. package/src/client/components/settings/Modal.tsx +9 -3
  21. package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
  22. package/src/client/components/settings/categories/AgentSettings.tsx +27 -6
  23. package/src/client/components/settings/categories/ProjectSettings.tsx +122 -156
  24. package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
  25. package/src/client/components/settings/categories/SkillSettings.tsx +6 -3
  26. package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +5 -0
  27. package/src/client/components/settings/categories/project-settings/AccentPalette.test.tsx +189 -0
  28. package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
  29. package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
  30. package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
  31. package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
  32. package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
  33. package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
  34. package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
  35. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
  36. package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
  37. package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
  38. package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
  39. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
  40. package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
  41. package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
  42. package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
  43. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +208 -0
  44. package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +137 -232
  45. package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
  46. package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +123 -87
  47. package/src/client/components/settings/categories/skill-settings/pane.test.tsx +179 -0
  48. package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
  49. package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
  50. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +46 -0
  51. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
  52. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +29 -0
  53. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
  54. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
  55. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
  56. package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +18 -2
  57. package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
  58. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
  59. package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
  60. package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
  61. package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
  62. package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
  63. package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
  64. package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
  65. package/src/client/components/workspace/file-explorer/index.tsx +21 -20
  66. package/src/client/data/settings/omp-schema.json +91 -4
  67. package/src/client/data/settings/project.ts +9 -28
  68. package/src/client/data/settings/skill.ts +6 -32
  69. package/src/client/hooks/chat/timeline/pending-model.ts +28 -0
  70. package/src/client/hooks/settings/projects/index.ts +294 -0
  71. package/src/client/hooks/settings/projects.test.ts +237 -0
  72. package/src/client/hooks/settings/skill-catalog.ts +101 -9
  73. package/src/client/hooks/settings/skill-git-import.ts +153 -0
  74. package/src/client/hooks/shell/servers.test.ts +166 -0
  75. package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
  76. package/src/client/hooks/ui/updates/shell-download.ts +1 -1
  77. package/src/client/hooks/ui/updates/shell-update.ts +2 -6
  78. package/src/client/hooks/workspace/file-row-drag.ts +41 -0
  79. package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
  80. package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
  81. package/src/client/hooks/workspace/root-drop-target.ts +77 -0
  82. package/src/client/hooks/workspace/unfolded-chains.ts +165 -0
  83. package/src/client/lib/desktop/dropped-paths.ts +1 -1
  84. package/src/client/lib/desktop/titlebar.test.ts +12 -3
  85. package/src/client/lib/desktop/titlebar.ts +1 -1
  86. package/src/client/lib/shell/desktop.ts +117 -0
  87. package/src/client/lib/shell/servers.ts +75 -0
  88. package/src/client/lib/shell/transport.ts +216 -0
  89. package/src/client/main.tsx +9 -0
  90. package/src/server/lib/fs/git-merge-conflict.test.ts +14 -1
  91. package/src/server/lib/omp/config/skill-sources.ts +49 -0
  92. package/src/server/lib/omp/config/skills-git-install.ts +155 -0
  93. package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
  94. package/src/server/lib/omp/config/skills-git.test.ts +220 -0
  95. package/src/server/lib/workspace/project-model.server.test.ts +102 -0
  96. package/src/server/lib/workspace/project-model.server.ts +47 -0
  97. package/src/server/lib/workspace/project-patch.server.ts +156 -0
  98. package/src/server/routes/agent/new.ts +8 -1
  99. package/src/server/routes/settings/agents.ts +19 -7
  100. package/src/server/routes/settings/projects.ts +53 -19
  101. package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
  102. package/src/server/routes/settings/settings-store-routes.test.ts +5 -2
  103. package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
  104. package/src/server/routes/settings/skills.test.ts +225 -0
  105. package/src/server/routes/settings/skills.ts +18 -15
  106. package/src/shared/lib/fs/folder-chain.test.ts +81 -1
  107. package/src/shared/lib/fs/folder-chain.ts +84 -0
  108. package/src/shared/lib/omp/config/schema.test.ts +35 -0
  109. package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
  110. package/src/shared/lib/omp/session/job-progress.ts +31 -0
  111. package/src/shared/lib/omp/session/proc.ts +5 -0
  112. package/src/shared/lib/omp/session/wait.ts +5 -0
  113. package/src/shared/lib/ui/mobile-overlay.ts +61 -0
  114. package/src/shared/lib/ui/svg-scope.test.ts +97 -0
  115. package/src/shared/lib/ui/svg-scope.ts +134 -0
  116. package/src/shared/lib/workspace/project-accent.test.ts +69 -0
  117. package/src/shared/lib/workspace/project-accent.ts +63 -0
  118. package/src/shared/lib/workspace/project-icon.ts +40 -0
  119. package/src/shared/lib/workspace/project-model.test.ts +79 -0
  120. package/src/shared/lib/workspace/project-model.ts +64 -0
  121. package/src/shared/types/settings/skill.ts +53 -3
  122. package/src/test-support/file-explorer-disk.test-util.ts +25 -1
  123. package/src/test-support/file-explorer-drag.test-util.ts +88 -0
  124. package/src/test-support/file-explorer.test-util.ts +47 -47
  125. package/dist/client/static/js/index-fjnq2z2d.css +0 -1
  126. package/src/client/components/common/code-surface/indent-guide.ts +0 -104
  127. package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
  128. package/src/client/hooks/desktop/servers.test.ts +0 -73
  129. package/src/client/lib/desktop/bridge.ts +0 -203
  130. package/src/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
  131. package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
@@ -1,97 +1,138 @@
1
1
  import type { LucideIcon } from 'lucide-preact';
2
- import { BookOpen, Briefcase, Camera, Code2, Database, FlaskConical, Folder, Gamepad2, Globe, Heart, Home, Leaf, Lightbulb, Music, Palette, Plus, Rocket, Server, Shield, Smartphone, Terminal } from 'lucide-preact';
3
- import type { ProjectConfigItem } from '@/shared/types';
2
+ import { Pin, PinOff, Plus } from 'lucide-preact';
3
+ import type { ProjectConfigItem, WorkspaceFolderData } from '@/shared/types';
4
+ import { getProjectIcon } from '@/shared/lib/workspace/project-icon';
5
+
6
+ /** The subset of a sidebar folder row this list borrows, when one exists. */
7
+ type FolderFacts = Pick<WorkspaceFolderData, 'id' | 'totalSessions'>;
4
8
 
5
9
  interface ProjectSidebarListProps {
6
10
  projects: ProjectConfigItem[];
7
11
  selectedProjectId: string;
8
12
  onSelectProject: (id: string) => void;
9
13
  onAddProject: () => void;
14
+ onTogglePin: (project: ProjectConfigItem) => void;
15
+ isAdding?: boolean;
16
+ /** Session counts by folder id, so a row says how much is in there. */
17
+ folderFacts?: FolderFacts[];
18
+ /** What the list is, when the read failed. */
19
+ loadError?: string | null;
10
20
  }
11
21
 
12
- const ICON_MAP: Record<string, LucideIcon> = {
13
- default: Folder,
14
- code: Code2,
15
- terminal: Terminal,
16
- rocket: Rocket,
17
- flask: FlaskConical,
18
- gamepad: Gamepad2,
19
- briefcase: Briefcase,
20
- home: Home,
21
- globe: Globe,
22
- leaf: Leaf,
23
- shield: Shield,
24
- palette: Palette,
25
- server: Server,
26
- smartphone: Smartphone,
27
- database: Database,
28
- lightbulb: Lightbulb,
29
- music: Music,
30
- camera: Camera,
31
- book: BookOpen,
32
- heart: Heart,
33
- };
34
-
22
+ /**
23
+ * The project list.
24
+ *
25
+ * A row carries the four things a reader chooses by: the project's mark, its
26
+ * name, how many chats it holds, and whether it is pinned — the same order the
27
+ * sidebar uses, so the two surfaces agree about what a project IS. Pinning is
28
+ * offered here because it reorders the sidebar and that is a project setting;
29
+ * hiding it behind the sidebar's own menu made it the one project fact this
30
+ * pane could not set.
31
+ */
35
32
  export function ProjectSidebarList({
36
33
  projects,
37
34
  selectedProjectId,
38
35
  onSelectProject,
39
36
  onAddProject,
37
+ onTogglePin,
38
+ isAdding = false,
39
+ folderFacts = [],
40
+ loadError = null,
40
41
  }: ProjectSidebarListProps) {
42
+ const counts = new Map(folderFacts.map((folder) => [folder.id, folder.totalSessions]));
43
+
41
44
  return (
42
45
  <div className="w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0">
43
- {/* List Header */}
44
- <div className="px-3.5 py-3 border-b border-ink/10 flex items-center justify-between">
46
+ <div className="px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between">
45
47
  <span className="text-xs font-semibold text-ink">
46
- Total {projects.length}
48
+ {projects.length} project{projects.length === 1 ? '' : 's'}
47
49
  </span>
48
50
  <button
49
51
  type="button"
50
52
  onClick={onAddProject}
51
- title="Add New Project"
52
- className="p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer"
53
+ disabled={isAdding}
54
+ aria-label="Add project"
55
+ title="Add project"
56
+ className="p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50"
53
57
  >
54
58
  <Plus size={15} strokeWidth={2.2} />
55
59
  </button>
56
60
  </div>
57
61
 
58
- {/* Projects List */}
59
62
  <div className="flex-1 scrollbar-overlay-container p-1.5 space-y-0.5">
63
+ {loadError && (
64
+ <p className="px-2 py-2 text-[11px] text-error" title={loadError}>
65
+ Projects could not be read: {loadError}
66
+ </p>
67
+ )}
68
+
69
+ {!loadError && projects.length === 0 && (
70
+ <div className="px-2 py-3 space-y-1.5">
71
+ <p className="text-[11.5px] text-ink/60">No projects yet.</p>
72
+ <button
73
+ type="button"
74
+ onClick={onAddProject}
75
+ className="text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer"
76
+ >
77
+ Add the first one
78
+ </button>
79
+ </div>
80
+ )}
81
+
60
82
  {projects.map((proj) => {
61
83
  const isSelected = proj.id === selectedProjectId;
62
- const IconComp = ICON_MAP[proj.icon] || Folder;
84
+ const IconComp: LucideIcon = getProjectIcon(proj.icon);
85
+ const count = proj.folderId === undefined ? undefined : counts.get(proj.folderId);
63
86
 
64
87
  return (
65
- <button
88
+ <div
66
89
  key={proj.id}
67
- type="button"
68
- onClick={() => onSelectProject(proj.id)}
69
- className={`w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left transition-colors cursor-pointer group ${
70
- isSelected
71
- ? 'bg-ink/10 text-ink font-medium shadow-2xs'
72
- : 'text-ink/80 hover:bg-ink/5 hover:text-ink'
90
+ className={`group flex items-center rounded-md transition-colors ${
91
+ isSelected ? 'bg-ink/10 shadow-2xs' : 'hover:bg-ink/5'
73
92
  }`}
74
93
  >
75
- {proj.customIconUrl ? (
76
- <img
77
- src={proj.customIconUrl}
78
- alt=""
79
- className="w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0"
80
- referrerPolicy="no-referrer"
81
- />
82
- ) : (
83
- <IconComp
84
- size={14}
85
- className="flex-shrink-0"
86
- style={{
87
- color: proj.accentColor || 'currentColor',
88
- }}
89
- />
90
- )}
91
- <span className="text-[11.5px] truncate flex-1">
92
- {proj.name}
93
- </span>
94
- </button>
94
+ <button
95
+ type="button"
96
+ onClick={() => onSelectProject(proj.id)}
97
+ aria-current={isSelected ? 'true' : undefined}
98
+ className="flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer"
99
+ >
100
+ {proj.customIconUrl ? (
101
+ <img
102
+ src={proj.customIconUrl}
103
+ alt=""
104
+ className="w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0"
105
+ referrerPolicy="no-referrer"
106
+ />
107
+ ) : (
108
+ <IconComp
109
+ size={14}
110
+ className="flex-shrink-0"
111
+ style={{ color: proj.accentColor || 'currentColor' }}
112
+ />
113
+ )}
114
+ <span className={`text-[11.5px] truncate flex-1 ${isSelected ? 'font-medium text-ink' : 'text-ink/80'}`}>
115
+ {proj.name}
116
+ </span>
117
+ {typeof count === 'number' && count > 0 && (
118
+ <span className="shrink-0 font-mono text-[10px] text-ink/40">{count}</span>
119
+ )}
120
+ </button>
121
+
122
+ <button
123
+ type="button"
124
+ onClick={() => onTogglePin(proj)}
125
+ aria-label={proj.isPinned ? `Unpin ${proj.name}` : `Pin ${proj.name}`}
126
+ title={proj.isPinned ? 'Unpin (stop sorting first)' : 'Pin (sort first in the sidebar)'}
127
+ className={`shrink-0 mr-1 p-1 rounded transition-colors cursor-pointer ${
128
+ proj.isPinned
129
+ ? 'text-ink/70 hover:text-ink hover:bg-ink/10'
130
+ : 'text-ink/30 hover:text-ink/70 hover:bg-ink/10 opacity-0 group-hover:opacity-100 focus-visible:opacity-100'
131
+ }`}
132
+ >
133
+ {proj.isPinned ? <Pin size={12} /> : <PinOff size={12} />}
134
+ </button>
135
+ </div>
95
136
  );
96
137
  })}
97
138
  </div>
@@ -0,0 +1,253 @@
1
+ import { useEffect, useState } from 'preact/hooks';
2
+ import type { ComponentChildren } from 'preact';
3
+ import { AlertCircle, Check, GitBranch, Loader2, Search } from 'lucide-preact';
4
+ import type { GitImportController } from '@/client/hooks/settings/skill-git-import';
5
+
6
+ interface GitImportPanelProps {
7
+ controller: GitImportController;
8
+ /** Called after a successful install so the pane can adopt the new list. */
9
+ onInstalled: () => void;
10
+ }
11
+
12
+ function Field({ label, children }: { label: string; children: ComponentChildren }) {
13
+ return (
14
+ <div className="space-y-1">
15
+ <div className="text-[11px] font-semibold uppercase tracking-wider text-ink/60">{label}</div>
16
+ {children}
17
+ </div>
18
+ );
19
+ }
20
+
21
+ /**
22
+ * The From Git tab: paste a repository, list its SKILL.md files, pick, install.
23
+ *
24
+ * The listing step is the point. `bunx skills add <repo>` installs without ever
25
+ * saying what is inside, and a repository can hold twenty skills — so the choice,
26
+ * the install target and the overwrite decision all happen before a single file
27
+ * is written. The outcome stays on screen afterwards: the server reports a skip
28
+ * per row with its reason, and a toast would have thrown that away.
29
+ */
30
+ export function GitImportPanel({ controller, onInstalled }: GitImportPanelProps) {
31
+ const [url, setUrl] = useState(controller.url);
32
+ const { skills, selected, mode, overwrite } = controller;
33
+
34
+ // A source card's Import button inspects without touching this field, so the
35
+ // input follows the repository the controller actually used — otherwise the
36
+ // list below would describe a repository the field does not name.
37
+ useEffect(() => {
38
+ if (controller.url) setUrl(controller.url);
39
+ }, [controller.url]);
40
+
41
+ const usable = skills.filter((skill) => skill.loadable && !skill.installed);
42
+
43
+ return (
44
+ <div className="space-y-4">
45
+ <div className="space-y-2">
46
+ <Field label="Repository">
47
+ <div className="flex items-center gap-2">
48
+ <div className="relative flex-1">
49
+ <GitBranch size={14} className="absolute left-3 top-2.5 text-ink/40 pointer-events-none" />
50
+ <input
51
+ type="text"
52
+ value={url}
53
+ onInput={(event) => setUrl(event.currentTarget.value)}
54
+ onKeyDown={(event) => {
55
+ if (event.key === 'Enter') void controller.inspect(url);
56
+ }}
57
+ placeholder="https://github.com/owner/repo · owner/repo · a local path"
58
+ className="w-full pl-9 pr-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-xs font-mono text-ink transition-colors"
59
+ />
60
+ </div>
61
+ <button
62
+ type="button"
63
+ onClick={() => void controller.inspect(url)}
64
+ disabled={controller.inspecting || !url.trim()}
65
+ className="flex items-center gap-1.5 px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer flex-shrink-0"
66
+ >
67
+ {controller.inspecting ? <Loader2 size={13} className="animate-spin" /> : <Search size={13} />}
68
+ <span>{controller.inspecting ? 'Cloning…' : 'Inspect'}</span>
69
+ </button>
70
+ </div>
71
+ </Field>
72
+ <p className="text-[11px] text-ink/50 leading-relaxed">
73
+ Kabmo clones the repository into a temporary directory, reads every SKILL.md, and removes the clone when it is
74
+ done. Nothing is written to your skills until you press Install.
75
+ </p>
76
+ </div>
77
+
78
+ {controller.error ? (
79
+ <div className="flex items-start gap-2 rounded-lg border border-error/40 bg-error/5 px-3 py-2 text-[11px] text-error">
80
+ <AlertCircle size={13} className="mt-0.5 flex-shrink-0" />
81
+ <span className="leading-relaxed">{controller.error}</span>
82
+ </div>
83
+ ) : null}
84
+
85
+ {skills.length > 0 ? (
86
+ <div className="space-y-2">
87
+ <div className="flex items-center justify-between">
88
+ <span className="text-xs font-bold uppercase tracking-wider text-ink">
89
+ {controller.repo} · {skills.length} SKILL.md
90
+ </span>
91
+ <div className="flex items-center gap-2 text-[11px]">
92
+ <button
93
+ type="button"
94
+ onClick={() => controller.toggleAll(true)}
95
+ className="text-ink/60 hover:text-ink cursor-pointer"
96
+ >
97
+ Select all
98
+ </button>
99
+ <span className="text-ink/25">·</span>
100
+ <button
101
+ type="button"
102
+ onClick={() => controller.toggleAll(false)}
103
+ className="text-ink/60 hover:text-ink cursor-pointer"
104
+ >
105
+ None
106
+ </button>
107
+ </div>
108
+ </div>
109
+
110
+ <div className="rounded-xl border border-ink/15 divide-y divide-ink/10 max-h-72 overflow-auto scrollbar-overlay-container">
111
+ {skills.map((skill) => {
112
+ const isSelected = selected.includes(skill.path);
113
+ const blocked = !skill.loadable ? 'no description — omp will not load it' : skill.installed ? 'already installed' : '';
114
+ return (
115
+ <label
116
+ key={skill.path}
117
+ className={`flex items-start gap-2.5 p-3 transition-colors ${
118
+ blocked ? 'opacity-55' : 'cursor-pointer hover:bg-ink/[0.03]'
119
+ }`}
120
+ >
121
+ <input
122
+ type="checkbox"
123
+ checked={isSelected}
124
+ disabled={Boolean(blocked)}
125
+ onChange={() => controller.toggle(skill.path)}
126
+ className="mt-0.5 accent-ink cursor-pointer disabled:cursor-not-allowed"
127
+ />
128
+ <div className="min-w-0 flex-1">
129
+ <div className="flex items-center gap-2 min-w-0">
130
+ <span className="text-xs font-semibold font-mono text-ink truncate">{skill.name}</span>
131
+ {blocked ? <span className="text-[10px] text-ink/50 flex-shrink-0">{blocked}</span> : null}
132
+ </div>
133
+ <p className="text-[11px] text-ink/65 leading-relaxed line-clamp-2">
134
+ {skill.description || 'No description in the frontmatter.'}
135
+ </p>
136
+ <div className="text-[10px] text-ink/40 font-mono truncate mt-0.5">{skill.path}/SKILL.md</div>
137
+ </div>
138
+ </label>
139
+ );
140
+ })}
141
+ </div>
142
+
143
+ {controller.notes.length > 0 ? (
144
+ <ul className="text-[11px] text-ink/55 space-y-0.5 list-disc list-inside">
145
+ {controller.notes.map((note) => (
146
+ <li key={note}>{note}</li>
147
+ ))}
148
+ </ul>
149
+ ) : null}
150
+
151
+ <div className="rounded-lg border border-ink/15 p-3 space-y-2.5">
152
+ <Field label="Install into">
153
+ <div className="flex flex-col sm:flex-row gap-2">
154
+ {(
155
+ [
156
+ {
157
+ id: 'managed_copy' as const,
158
+ title: 'Managed copy',
159
+ detail: 'Kabmo owns the files — editable and deletable here.',
160
+ },
161
+ {
162
+ id: 'registry' as const,
163
+ title: 'Registry install',
164
+ detail: 'Through the skills CLI into ~/.agents/skills — updateable, read-only here.',
165
+ },
166
+ ]
167
+ ).map((option) => (
168
+ <button
169
+ key={option.id}
170
+ type="button"
171
+ onClick={() => controller.setMode(option.id)}
172
+ className={`flex-1 text-left px-2.5 py-2 rounded-lg border transition-colors cursor-pointer ${
173
+ mode === option.id ? 'border-ink bg-ink/5' : 'border-ink/20 hover:border-ink/40'
174
+ }`}
175
+ >
176
+ <div className="flex items-center gap-1.5">
177
+ <span
178
+ className={`w-2 h-2 rounded-full ${mode === option.id ? 'bg-ink' : 'border border-ink/40'}`}
179
+ />
180
+ <span className="text-xs font-semibold text-ink">{option.title}</span>
181
+ </div>
182
+ <div className="text-[10px] text-ink/55 leading-relaxed mt-0.5">{option.detail}</div>
183
+ </button>
184
+ ))}
185
+ </div>
186
+ </Field>
187
+
188
+ <label className="flex items-start gap-2 cursor-pointer select-none">
189
+ <input
190
+ type="checkbox"
191
+ checked={overwrite}
192
+ onChange={(event) => controller.setOverwrite(event.currentTarget.checked)}
193
+ className="mt-0.5 accent-ink cursor-pointer"
194
+ />
195
+ <span className="text-[11px] text-ink/70 leading-relaxed">
196
+ Replace skills that already have the same name
197
+ <span className="block text-[10px] text-ink/45">
198
+ Off by default: an existing directory may hold your own edits.
199
+ </span>
200
+ </span>
201
+ </label>
202
+ </div>
203
+ </div>
204
+ ) : null}
205
+
206
+ {controller.result ? (
207
+ <div className="rounded-lg border border-ink/20 bg-ink/[0.03] p-3 space-y-1.5">
208
+ <div className="flex items-center gap-1.5 text-xs font-semibold text-ink">
209
+ <Check size={13} />
210
+ <span>
211
+ {controller.result.installed.length} installed
212
+ {controller.result.skipped.length > 0 ? ` · ${controller.result.skipped.length} skipped` : ''}
213
+ </span>
214
+ </div>
215
+ {controller.result.installed.length > 0 ? (
216
+ <div className="text-[11px] text-ink/70 font-mono">{controller.result.installed.join(', ')}</div>
217
+ ) : null}
218
+ <ul className="text-[11px] text-ink/60 space-y-0.5">
219
+ {controller.result.skipped.map((entry) => (
220
+ <li key={`${entry.name}-${entry.reason}`}>
221
+ <span className="font-mono text-ink/80">{entry.name}</span> — {entry.reason}
222
+ </li>
223
+ ))}
224
+ </ul>
225
+ </div>
226
+ ) : null}
227
+
228
+ {skills.length > 0 ? (
229
+ <div className="flex items-center justify-between pt-1">
230
+ <span className="text-[11px] text-ink/55">
231
+ {selected.length} of {usable.length} installable selected
232
+ </span>
233
+ <button
234
+ type="button"
235
+ onClick={async () => {
236
+ const result = await controller.install();
237
+ if (result && result.installed.length > 0) onInstalled();
238
+ }}
239
+ disabled={selected.length === 0 || controller.installing}
240
+ className="flex items-center gap-1.5 px-3.5 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 disabled:opacity-40 transition-colors cursor-pointer"
241
+ >
242
+ {controller.installing ? <Loader2 size={13} className="animate-spin" /> : null}
243
+ <span>
244
+ {controller.installing
245
+ ? 'Installing…'
246
+ : `Install ${selected.length} skill${selected.length === 1 ? '' : 's'}`}
247
+ </span>
248
+ </button>
249
+ </div>
250
+ ) : null}
251
+ </div>
252
+ );
253
+ }
@@ -0,0 +1,89 @@
1
+ import { Check, Download, ExternalLink, Loader2 } from 'lucide-preact';
2
+ import type { CatalogSkillItem } from '@/shared/types';
3
+
4
+ interface SkillCardProps {
5
+ skill: CatalogSkillItem;
6
+ installed: boolean;
7
+ /** This row's own request is in flight — other rows stay clickable. */
8
+ busy: boolean;
9
+ onInstallToggle: (skill: CatalogSkillItem) => void;
10
+ }
11
+
12
+ function compactCount(value: number): string {
13
+ if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`;
14
+ if (value >= 1_000) return `${Math.round(value / 1_000)}K`;
15
+ return String(value);
16
+ }
17
+
18
+ /**
19
+ * One catalog row.
20
+ *
21
+ * The install button carries three states and they are deliberately different:
22
+ * a spinner while THIS row's request runs (so a second click cannot start a
23
+ * second install), the installed state and a download state. The previous single
24
+ * button flipped its label only after the whole list reloaded, so a slow install
25
+ * looked like a dead click and a double-click ran the CLI twice.
26
+ */
27
+ export function SkillCard({ skill, installed, busy, onInstallToggle }: SkillCardProps) {
28
+ return (
29
+ <div className="p-4 rounded-xl border border-ink/15 hover:border-ink/30 bg-paper transition-colors flex flex-col sm:flex-row sm:items-start justify-between gap-3">
30
+ <div className="space-y-1.5 flex-1 min-w-0">
31
+ <div className="flex items-center gap-2 min-w-0">
32
+ <span className="text-xs font-bold text-ink tracking-tight font-mono truncate">{skill.name}</span>
33
+ {skill.installs ? (
34
+ <span className="text-[10px] text-ink/45 font-mono flex-shrink-0">{compactCount(skill.installs)} installs</span>
35
+ ) : null}
36
+ </div>
37
+
38
+ {skill.description ? (
39
+ <p className="text-xs text-ink/75 leading-relaxed line-clamp-2">{skill.description}</p>
40
+ ) : null}
41
+
42
+ <div className="text-[11px] text-ink/50 font-mono truncate pt-1">{skill.repoTag}</div>
43
+ </div>
44
+
45
+ <div className="flex items-center gap-2 flex-shrink-0 self-end sm:self-center">
46
+ {skill.githubUrl ? (
47
+ <a
48
+ href={skill.githubUrl}
49
+ target="_blank"
50
+ rel="noreferrer"
51
+ className="p-1.5 rounded-lg text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer"
52
+ title="Open the repository"
53
+ aria-label={`Open the repository for ${skill.name}`}
54
+ >
55
+ <ExternalLink size={14} />
56
+ </a>
57
+ ) : null}
58
+
59
+ <button
60
+ type="button"
61
+ onClick={() => onInstallToggle(skill)}
62
+ disabled={busy}
63
+ className={`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors flex items-center gap-1.5 cursor-pointer disabled:cursor-default disabled:opacity-60 ${
64
+ installed
65
+ ? 'border border-ink/20 text-ink/80 hover:border-error hover:text-error hover:bg-error/5'
66
+ : 'bg-ink text-paper hover:bg-ink/90 shadow-xs'
67
+ }`}
68
+ >
69
+ {busy ? (
70
+ <>
71
+ <Loader2 size={12} className="animate-spin" />
72
+ <span>{installed ? 'Removing…' : 'Installing…'}</span>
73
+ </>
74
+ ) : installed ? (
75
+ <>
76
+ <Check size={12} />
77
+ <span>Installed</span>
78
+ </>
79
+ ) : (
80
+ <>
81
+ <Download size={12} />
82
+ <span>Install</span>
83
+ </>
84
+ )}
85
+ </button>
86
+ </div>
87
+ </div>
88
+ );
89
+ }
@@ -0,0 +1,122 @@
1
+ import { GitBranch, Loader2, Plus, RefreshCw, Trash2 } from 'lucide-preact';
2
+ import type { SkillCatalogSource } from '@/shared/types';
3
+
4
+ interface SourceRailProps {
5
+ sources: SkillCatalogSource[];
6
+ onScan: (id: string) => void;
7
+ onImportFrom: (repo: string) => void;
8
+ onRemove: (id: string) => void;
9
+ onAdd: () => void;
10
+ scanningId: string | null;
11
+ busy: boolean;
12
+ }
13
+
14
+ /** "Scanned 2m ago" from the stored timestamp, or the honest "Not scanned". */
15
+ export function describeScan(source: SkillCatalogSource): string {
16
+ if (source.skillCount === null) return 'Not scanned';
17
+ const count = `${source.skillCount} skill${source.skillCount === 1 ? '' : 's'}`;
18
+ if (!source.scannedAt) return count;
19
+ const minutes = Math.floor((Date.now() - source.scannedAt) / 60_000);
20
+ if (minutes < 1) return `${count} · just scanned`;
21
+ if (minutes < 60) return `${count} · scanned ${minutes}m ago`;
22
+ const hours = Math.floor(minutes / 60);
23
+ if (hours < 24) return `${count} · scanned ${hours}h ago`;
24
+ return `${count} · scanned ${Math.floor(hours / 24)}d ago`;
25
+ }
26
+
27
+ /**
28
+ * The Sources tab: every git repository Kabmo offers as a skill source.
29
+ *
30
+ * A source used to be a card with a star count and an "updated" line that no
31
+ * request produced, and its "Add your own source" button posted a body the server
32
+ * did not understand. This list only shows what is stored, its count is the
33
+ * number the last scan actually found, and every action here has a route behind
34
+ * it.
35
+ */
36
+ export function SourceRail({
37
+ sources,
38
+ onScan,
39
+ onImportFrom,
40
+ onRemove,
41
+ onAdd,
42
+ scanningId,
43
+ busy,
44
+ }: SourceRailProps) {
45
+ return (
46
+ <div className="space-y-3">
47
+ <div className="flex items-start justify-between gap-3">
48
+ <p className="text-xs text-ink/60 leading-relaxed max-w-xl">
49
+ A source is a git repository. Kabmo clones it only when you scan or import, so adding one costs nothing
50
+ until you use it.
51
+ </p>
52
+ <button
53
+ type="button"
54
+ onClick={onAdd}
55
+ className="flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0"
56
+ >
57
+ <Plus size={13} />
58
+ <span>Add source</span>
59
+ </button>
60
+ </div>
61
+
62
+ <div className="rounded-xl border border-ink/15 divide-y divide-ink/10 overflow-hidden">
63
+ {sources.length === 0 ? (
64
+ <p className="p-6 text-xs text-ink/60 text-center">
65
+ No sources yet. Add a repository, or paste one into <span className="font-semibold">From Git</span>.
66
+ </p>
67
+ ) : (
68
+ sources.map((source) => {
69
+ const isScanning = scanningId === source.id;
70
+ return (
71
+ <div key={source.id} className="p-3.5 flex flex-col sm:flex-row sm:items-center gap-3 bg-paper">
72
+ <div className="flex-1 min-w-0">
73
+ <div className="flex items-center gap-2 min-w-0">
74
+ <span className="text-xs font-bold text-ink truncate">{source.name}</span>
75
+ {source.isCustom ? (
76
+ <span className="text-[10px] px-1.5 py-0.5 rounded bg-ink/8 text-ink/60 flex-shrink-0">custom</span>
77
+ ) : null}
78
+ </div>
79
+ <div className="flex items-center gap-1.5 mt-0.5 text-[11px] text-ink/55 font-mono truncate">
80
+ <GitBranch size={11} className="flex-shrink-0" />
81
+ <span className="truncate">{source.repo}</span>
82
+ </div>
83
+ <div className="text-[11px] text-ink/50 mt-0.5">{describeScan(source)}</div>
84
+ </div>
85
+
86
+ <div className="flex items-center gap-1.5 flex-shrink-0 self-end sm:self-center">
87
+ <button
88
+ type="button"
89
+ onClick={() => onScan(source.id)}
90
+ disabled={busy || isScanning}
91
+ className="flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer"
92
+ >
93
+ {isScanning ? <Loader2 size={12} className="animate-spin" /> : <RefreshCw size={12} />}
94
+ <span>{isScanning ? 'Scanning…' : 'Scan'}</span>
95
+ </button>
96
+ <button
97
+ type="button"
98
+ onClick={() => onImportFrom(source.repo)}
99
+ disabled={busy}
100
+ className="px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink hover:bg-ink/5 disabled:opacity-50 transition-colors cursor-pointer"
101
+ >
102
+ Import
103
+ </button>
104
+ <button
105
+ type="button"
106
+ onClick={() => onRemove(source.id)}
107
+ disabled={busy}
108
+ title={`Remove ${source.name} from the source list`}
109
+ aria-label={`Remove ${source.name}`}
110
+ className="p-1 rounded-md text-ink/40 hover:text-error hover:bg-error/10 disabled:opacity-40 transition-colors cursor-pointer"
111
+ >
112
+ <Trash2 size={13} />
113
+ </button>
114
+ </div>
115
+ </div>
116
+ );
117
+ })
118
+ )}
119
+ </div>
120
+ </div>
121
+ );
122
+ }