iskills 0.2.49 → 0.2.51

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 (190) hide show
  1. package/README.md +7 -2
  2. package/README.zh-CN.md +7 -2
  3. package/dist/src/cli.js +4 -0
  4. package/dist/src/cli.js.map +1 -1
  5. package/dist/src/commands/browser-actions.d.ts +2 -0
  6. package/dist/src/commands/browser-actions.js +44 -10
  7. package/dist/src/commands/browser-actions.js.map +1 -1
  8. package/dist/src/commands/config.d.ts +3 -2
  9. package/dist/src/commands/config.js +19 -2
  10. package/dist/src/commands/config.js.map +1 -1
  11. package/dist/src/commands/index.js +1 -0
  12. package/dist/src/commands/index.js.map +1 -1
  13. package/dist/src/commands/library.d.ts +5 -0
  14. package/dist/src/commands/library.js +45 -7
  15. package/dist/src/commands/library.js.map +1 -1
  16. package/dist/src/commands/mcp.d.ts +4 -0
  17. package/dist/src/commands/mcp.js +244 -0
  18. package/dist/src/commands/mcp.js.map +1 -0
  19. package/dist/src/domain/collection-write.js +6 -5
  20. package/dist/src/domain/collection-write.js.map +1 -1
  21. package/dist/src/domain/core.d.ts +6 -0
  22. package/dist/src/domain/core.js +64 -19
  23. package/dist/src/domain/core.js.map +1 -1
  24. package/dist/src/domain/git.d.ts +8 -0
  25. package/dist/src/domain/git.js +51 -12
  26. package/dist/src/domain/git.js.map +1 -1
  27. package/dist/src/domain/mcp/collection.d.ts +10 -0
  28. package/dist/src/domain/mcp/collection.js +107 -0
  29. package/dist/src/domain/mcp/collection.js.map +1 -0
  30. package/dist/src/domain/mcp/dialects.d.ts +23 -0
  31. package/dist/src/domain/mcp/dialects.js +536 -0
  32. package/dist/src/domain/mcp/dialects.js.map +1 -0
  33. package/dist/src/domain/mcp/headers.d.ts +9 -0
  34. package/dist/src/domain/mcp/headers.js +50 -0
  35. package/dist/src/domain/mcp/headers.js.map +1 -0
  36. package/dist/src/domain/mcp/identity.d.ts +13 -0
  37. package/dist/src/domain/mcp/identity.js +121 -0
  38. package/dist/src/domain/mcp/identity.js.map +1 -0
  39. package/dist/src/domain/mcp/index.d.ts +8 -0
  40. package/dist/src/domain/mcp/index.js +8 -0
  41. package/dist/src/domain/mcp/index.js.map +1 -0
  42. package/dist/src/domain/mcp/io.d.ts +7 -0
  43. package/dist/src/domain/mcp/io.js +55 -0
  44. package/dist/src/domain/mcp/io.js.map +1 -0
  45. package/dist/src/domain/mcp/probe.d.ts +7 -0
  46. package/dist/src/domain/mcp/probe.js +35 -0
  47. package/dist/src/domain/mcp/probe.js.map +1 -0
  48. package/dist/src/domain/mcp/recipe.d.ts +12 -0
  49. package/dist/src/domain/mcp/recipe.js +172 -0
  50. package/dist/src/domain/mcp/recipe.js.map +1 -0
  51. package/dist/src/domain/mcp/secrets.d.ts +12 -0
  52. package/dist/src/domain/mcp/secrets.js +133 -0
  53. package/dist/src/domain/mcp/secrets.js.map +1 -0
  54. package/dist/src/domain/mcp/types.d.ts +82 -0
  55. package/dist/src/domain/mcp/types.js +2 -0
  56. package/dist/src/domain/mcp/types.js.map +1 -0
  57. package/dist/src/domain/mcp/write.d.ts +30 -0
  58. package/dist/src/domain/mcp/write.js +229 -0
  59. package/dist/src/domain/mcp/write.js.map +1 -0
  60. package/dist/src/domain/user-config.d.ts +2 -0
  61. package/dist/src/domain/user-config.js +5 -2
  62. package/dist/src/domain/user-config.js.map +1 -1
  63. package/dist/src/i18n/en.js +109 -12
  64. package/dist/src/i18n/en.js.map +1 -1
  65. package/dist/src/i18n/zh.d.ts +105 -8
  66. package/dist/src/i18n/zh.js +106 -9
  67. package/dist/src/i18n/zh.js.map +1 -1
  68. package/dist/src/ui/browser/browse-capabilities.d.ts +2 -2
  69. package/dist/src/ui/browser/browse-capabilities.js +10 -14
  70. package/dist/src/ui/browser/browse-capabilities.js.map +1 -1
  71. package/dist/src/ui/browser/browse-nav.d.ts +42 -0
  72. package/dist/src/ui/browser/browse-nav.js +106 -0
  73. package/dist/src/ui/browser/browse-nav.js.map +1 -0
  74. package/dist/src/ui/browser/browse-session.d.ts +94 -0
  75. package/dist/src/ui/browser/browse-session.js +310 -0
  76. package/dist/src/ui/browser/browse-session.js.map +1 -0
  77. package/dist/src/ui/browser/browser.js +194 -446
  78. package/dist/src/ui/browser/browser.js.map +1 -1
  79. package/dist/src/ui/browser/detail.d.ts +1 -1
  80. package/dist/src/ui/browser/detail.js +13 -2
  81. package/dist/src/ui/browser/detail.js.map +1 -1
  82. package/dist/src/ui/browser/footer.d.ts +1 -1
  83. package/dist/src/ui/browser/footer.js +20 -7
  84. package/dist/src/ui/browser/footer.js.map +1 -1
  85. package/dist/src/ui/browser/format.d.ts +47 -12
  86. package/dist/src/ui/browser/format.js +191 -49
  87. package/dist/src/ui/browser/format.js.map +1 -1
  88. package/dist/src/ui/browser/index.d.ts +1 -1
  89. package/dist/src/ui/browser/index.js +13 -3
  90. package/dist/src/ui/browser/index.js.map +1 -1
  91. package/dist/src/ui/browser/layout.d.ts +7 -0
  92. package/dist/src/ui/browser/layout.js +16 -2
  93. package/dist/src/ui/browser/layout.js.map +1 -1
  94. package/dist/src/ui/browser/panes.d.ts +108 -0
  95. package/dist/src/ui/browser/panes.js +221 -0
  96. package/dist/src/ui/browser/panes.js.map +1 -0
  97. package/dist/src/ui/browser/shortcut-help.d.ts +3 -1
  98. package/dist/src/ui/browser/shortcut-help.js +6 -6
  99. package/dist/src/ui/browser/shortcut-help.js.map +1 -1
  100. package/dist/src/ui/browser/store.d.ts +5 -1
  101. package/dist/src/ui/browser/store.js +2 -0
  102. package/dist/src/ui/browser/store.js.map +1 -1
  103. package/dist/src/ui/browser/types.d.ts +9 -4
  104. package/dist/src/ui/components/colors.d.ts +9 -9
  105. package/dist/src/ui/components/colors.js +14 -14
  106. package/dist/src/ui/components/colors.js.map +1 -1
  107. package/dist/src/ui/components/framed-panel.js +6 -6
  108. package/dist/src/ui/components/framed-panel.js.map +1 -1
  109. package/dist/src/ui/components/modal-panel.d.ts +1 -1
  110. package/dist/src/ui/components/modal-panel.js +3 -3
  111. package/dist/src/ui/components/modal-panel.js.map +1 -1
  112. package/dist/src/ui/components/mouse/clickable.js +3 -3
  113. package/dist/src/ui/components/mouse/clickable.js.map +1 -1
  114. package/dist/src/ui/components/mouse/provider.d.ts +3 -3
  115. package/dist/src/ui/components/mouse/provider.js +3 -3
  116. package/dist/src/ui/components/mouse/provider.js.map +1 -1
  117. package/dist/src/ui/components/multi-select.js +6 -6
  118. package/dist/src/ui/components/multi-select.js.map +1 -1
  119. package/dist/src/ui/components/options.d.ts +2 -0
  120. package/dist/src/ui/components/options.js +6 -0
  121. package/dist/src/ui/components/options.js.map +1 -1
  122. package/dist/src/ui/components/select.js +4 -4
  123. package/dist/src/ui/components/select.js.map +1 -1
  124. package/dist/src/ui/components/tag-editor.js +5 -5
  125. package/dist/src/ui/components/tag-editor.js.map +1 -1
  126. package/dist/src/ui/components/termcn.d.ts +1 -1
  127. package/dist/src/ui/components/termcn.js +1 -1
  128. package/dist/src/ui/components/terminal-layout.d.ts +2 -0
  129. package/dist/src/ui/components/terminal-layout.js +10 -0
  130. package/dist/src/ui/components/terminal-layout.js.map +1 -1
  131. package/dist/src/ui/components/text-input-ctrl-c.d.ts +21 -0
  132. package/dist/src/ui/components/text-input-ctrl-c.js +61 -0
  133. package/dist/src/ui/components/text-input-ctrl-c.js.map +1 -0
  134. package/dist/src/ui/components/text-input.d.ts +8 -1
  135. package/dist/src/ui/components/text-input.js +35 -12
  136. package/dist/src/ui/components/text-input.js.map +1 -1
  137. package/dist/src/ui/components/use-input.d.ts +3 -1
  138. package/dist/src/ui/components/use-input.js +2 -1
  139. package/dist/src/ui/components/use-input.js.map +1 -1
  140. package/dist/src/ui/config/index.d.ts +4 -0
  141. package/dist/src/ui/config/index.js +6 -3
  142. package/dist/src/ui/config/index.js.map +1 -1
  143. package/dist/src/ui/config/settings.d.ts +8 -4
  144. package/dist/src/ui/config/settings.js +115 -30
  145. package/dist/src/ui/config/settings.js.map +1 -1
  146. package/dist/src/ui/footer/resolve-footer.d.ts +2 -0
  147. package/dist/src/ui/footer/resolve-footer.js +52 -25
  148. package/dist/src/ui/footer/resolve-footer.js.map +1 -1
  149. package/dist/src/ui/footer/types.d.ts +7 -5
  150. package/dist/src/ui/import/review.js +7 -7
  151. package/dist/src/ui/import/review.js.map +1 -1
  152. package/dist/src/ui/import/skill-select.js +34 -14
  153. package/dist/src/ui/import/skill-select.js.map +1 -1
  154. package/dist/src/ui/install/review.js +4 -4
  155. package/dist/src/ui/install/review.js.map +1 -1
  156. package/dist/src/ui/mcp/browse-capabilities.d.ts +22 -0
  157. package/dist/src/ui/mcp/browse-capabilities.js +36 -0
  158. package/dist/src/ui/mcp/browse-capabilities.js.map +1 -0
  159. package/dist/src/ui/mcp/browser.d.ts +25 -0
  160. package/dist/src/ui/mcp/browser.js +311 -0
  161. package/dist/src/ui/mcp/browser.js.map +1 -0
  162. package/dist/src/ui/mcp/footer.d.ts +16 -0
  163. package/dist/src/ui/mcp/footer.js +30 -0
  164. package/dist/src/ui/mcp/footer.js.map +1 -0
  165. package/dist/src/ui/mcp/format.d.ts +24 -0
  166. package/dist/src/ui/mcp/format.js +218 -0
  167. package/dist/src/ui/mcp/format.js.map +1 -0
  168. package/dist/src/ui/mcp/index.d.ts +8 -0
  169. package/dist/src/ui/mcp/index.js +212 -0
  170. package/dist/src/ui/mcp/index.js.map +1 -0
  171. package/dist/src/ui/overlay/host.d.ts +3 -3
  172. package/dist/src/ui/overlay/host.js +4 -4
  173. package/dist/src/ui/overlay/host.js.map +1 -1
  174. package/dist/src/ui/prompts/present.d.ts +6 -2
  175. package/dist/src/ui/prompts/present.js +7 -3
  176. package/dist/src/ui/prompts/present.js.map +1 -1
  177. package/dist/src/ui/search/index.js +4 -4
  178. package/dist/src/ui/search/index.js.map +1 -1
  179. package/dist/src/ui/shell/app-shell.d.ts +7 -6
  180. package/dist/src/ui/shell/app-shell.js +35 -8
  181. package/dist/src/ui/shell/app-shell.js.map +1 -1
  182. package/dist/src/ui/shell/footer.js +4 -4
  183. package/dist/src/ui/shell/footer.js.map +1 -1
  184. package/dist/src/ui/shell/run.js +3 -0
  185. package/dist/src/ui/shell/run.js.map +1 -1
  186. package/dist/src/ui/tui/hooks.d.ts +2 -2
  187. package/dist/src/ui/tui/hooks.js +3 -3
  188. package/dist/src/ui/tui/index.d.ts +1 -1
  189. package/dist/src/ui/tui/index.js +1 -1
  190. package/package.json +3 -2
@@ -1,21 +1,33 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
- import { Text, useStdout } from '../tui/index.js';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
+ import { useStdout } from '../tui/index.js';
3
3
  import { useInput } from '../components/use-input.js';
4
- import { useAtom, useAtomValue, useStore } from 'jotai';
5
- import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
4
+ import { useAtom, useSetAtom, useStore } from 'jotai';
5
+ import { useEffect, useMemo, useRef, useState, } from 'react';
6
6
  import { presentHealthAlerts } from './health.js';
7
- import { browserFilterAtom, browserGroupJumpAtom, browserHealthAtom, browserNavigationAtom, browserSelectionAtom, browserTagFilterAtom, browserUpdateCheckAtom, } from './store.js';
8
- import { browserFrameDimensions, masterDetailLayout, masterDetailSeparator, masterDetailViewportHeight, masterDetailWidths, } from './layout.js';
7
+ import { browserDetailFieldAtom, browserFilterAtom, browserGroupJumpAtom, browserHealthAtom, browserNavigationAtom, browserSelectionAtom, browserTagFilterAtom, browserUpdateCheckAtom, } from './store.js';
8
+ import { browserFrameDimensions, compactLayout, masterDetailLayout, masterDetailViewportHeight, masterDetailWidths, } from './layout.js';
9
9
  import { isCrossAgentInstallable } from '../../domain/cross-agent-install.js';
10
10
  import { browseSelectionSets, projectActionSkills, } from './browse-capabilities.js';
11
- import { TAG_FILTER_ALL, browseDetailRows, collectionCategoryLines, collectionListColumnLines, detailEditableFields, detailLabelWidth, flatRows, focusAfterDownFromAgents, focusAfterDownFromTabs, focusAfterUpFromList, focusAfterUpFromTags, groupedRows, listSkillSummary, nextAgent, nextMainTab, selectableSkills, skillsForTagFilter, tagFilterOptions, visibleAgentGroups, } from './format.js';
11
+ import { browseDetailRows, collectionListColumnLines, detailEditableFields, detailEntryFieldIndex, flatRows, groupedRows, selectableSkills, skillsForTagFilter, tagFilterOptions, visibleAgentGroups, } from './format.js';
12
12
  import { t } from '../../i18n/index.js';
13
13
  import { useModal, useOverlayBusy } from '../overlay/host.js';
14
14
  import { FramedPanel } from '../components/framed-panel.js';
15
- import { Select, Tabs, termcnColors, WorkingSpinner, useSpinnerFrame, } from '../components/termcn.js';
16
- import { Clickable } from '../components/mouse/clickable.js';
17
- import { padColumns, sliceColumns } from '../components/terminal-layout.js';
15
+ import { Select, Tabs, useSpinnerFrame, } from '../components/termcn.js';
18
16
  import { ShortcutHelpPanel } from './shortcut-help.js';
17
+ import { AgentTabs, BrowseHomePane, SkillPane } from './panes.js';
18
+ import { applyBrowseSessionPatch, browseSessionClickDetail, browseSessionClickList, browseSessionClickTag, browseSessionScrollList, reduceBrowseSessionKey, useBrowseSessionEffects, } from './browse-session.js';
19
+ const EMPTY_SKILLS = [];
20
+ function sameNavigation(left, right) {
21
+ if (left === right)
22
+ return true;
23
+ if (!left || !right)
24
+ return false;
25
+ return (left.tab === right.tab &&
26
+ left.focus === right.focus &&
27
+ left.agent === right.agent &&
28
+ left.cursor === right.cursor &&
29
+ left.query === right.query);
30
+ }
19
31
  /** Framed more-actions picker when multiple m-actions are available. */
20
32
  function MoreActionsPanel({ scope, items, onSelect, onCancel, }) {
21
33
  const [cursor, setCursor] = useState(0);
@@ -42,160 +54,6 @@ function MoreActionsPanel({ scope, items, onSelect, onCancel, }) {
42
54
  }
43
55
  } }));
44
56
  }
45
- function masterDetailBlankRow(tagWidth, listWidth, peekWidth) {
46
- const divider = '│';
47
- return (_jsxs("box", { flexDirection: "row", children: [_jsxs("box", { width: tagWidth + 1, flexDirection: "row", children: [_jsx(Text, { wrap: "truncate-end", children: padColumns('', tagWidth) }), _jsx(Text, { color: termcnColors.border, children: divider })] }), _jsxs("box", { width: listWidth + 1, flexDirection: "row", children: [_jsx(Text, { wrap: "truncate-end", children: padColumns('', listWidth) }), _jsx(Text, { color: termcnColors.border, children: divider })] }), _jsx("box", { flexDirection: "row", width: peekWidth, children: _jsx(Text, { wrap: "truncate-end", children: padColumns('', peekWidth) }) })] }));
48
- }
49
- function SkillPane({ rows, cursor, isActive, preferNote = false, compact = false, layout = 'default', columnWidth, showPagination = true, showSource = false, showReferences = false, showGroup = false, updates = new Set(), updatingSkillName, viewportHeight, onRowClick, onCursorDelta, }) {
50
- const { stdout } = useStdout();
51
- const selected = useAtomValue(browserSelectionAtom);
52
- const paneHeight = viewportHeight ?? Math.max(3, (stdout.rows ?? 24) - 8);
53
- const height = rows.length > paneHeight ? Math.max(3, paneHeight - (showPagination ? 1 : 0)) : paneHeight;
54
- const active = Math.max(0, Math.min(cursor, rows.length - 1));
55
- const offset = Math.max(0, Math.min(active - Math.floor(height / 2), rows.length - height));
56
- const visible = rows.slice(offset, offset + height);
57
- const paneWidth = columnWidth ?? Math.max(20, (stdout.columns ?? 80) - 4);
58
- const summaryWidth = Math.max(8, paneWidth - 4);
59
- const onMouseScroll = useCallback((event) => {
60
- const info = event.scroll;
61
- if (!info || !onCursorDelta)
62
- return;
63
- const steps = Math.max(1, Math.abs(info.delta) || 1);
64
- if (info.direction === 'up')
65
- onCursorDelta(-steps);
66
- else if (info.direction === 'down')
67
- onCursorDelta(steps);
68
- event.stopPropagation();
69
- }, [onCursorDelta]);
70
- const renderRow = (row, index) => {
71
- if (row.type === 'group') {
72
- const groupSkills = row.skills;
73
- const count = groupSkills.filter((skill) => selected.has(skill.path)).length;
74
- const marker = count === 0 ? '○' : count === groupSkills.length && groupSkills.length ? '●' : '◐';
75
- const body = (_jsx(Text, { bold: true, ...(isActive && index === active ? { color: termcnColors.primary } : {}), children: `${isActive && index === active ? '›' : ' '} ${marker} ${row.name} (${row.skills.length})` }));
76
- if (!onRowClick)
77
- return _jsx("box", { flexDirection: "row", children: body }, `group:${row.name}:${index}`);
78
- return (_jsx(Clickable, { onClick: () => onRowClick(index), children: body }, `group:${row.name}:${index}`));
79
- }
80
- const skill = row.skill;
81
- const current = isActive && index === active;
82
- const summary = compact || layout === 'master'
83
- ? ''
84
- : listSkillSummary(skill, preferNote, summaryWidth);
85
- const inlineSummary = summary;
86
- const selectionMarker = selected.has(skill.path) ? '●' : '○';
87
- const nameLine = (_jsxs(_Fragment, { children: [` ${current ? '›' : ' '} ${selectionMarker} `, showGroup && row.group && (_jsxs(Text, { color: termcnColors.muted, children: [row.group, " / "] })), showReferences && skill.isReference ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: termcnColors.muted, children: t('browser.referencePrefix') }), _jsx(Text, { bold: current, children: skill.name })] })) : showSource && !skill.fromCollection ? (t('browser.localSkill', { name: skill.name })) : (_jsx(Text, { bold: current, children: skill.name })), updatingSkillName === skill.name ? (_jsx(WorkingSpinner, {})) : updates.has(skill.name) ? (_jsx(Text, { color: termcnColors.primary, children: " \u2191" })) : null, inlineSummary && (_jsxs(Text, { color: termcnColors.muted, children: [" \u2014 ", inlineSummary] }))] }));
88
- const body = (_jsx(Text, { wrap: "truncate-end", ...(current
89
- ? {
90
- color: termcnColors.selectionFg,
91
- backgroundColor: termcnColors.selectionBg,
92
- bold: true,
93
- }
94
- : {}), children: nameLine }));
95
- if (!onRowClick) {
96
- return (_jsx("box", { flexDirection: "row", children: body }, `${row.group}:${skill.path}:${index}`));
97
- }
98
- return (_jsx(Clickable, { onClick: () => onRowClick(index), children: body }, `${row.group}:${skill.path}:${index}`));
99
- };
100
- return (_jsxs("box", { flexDirection: "column", minHeight: 3, onMouseScroll: onMouseScroll, children: [rows.length ? (visible.map((row, visibleIndex) => renderRow(row, offset + visibleIndex))) : (_jsx(Text, { color: termcnColors.muted, children: t('browser.noMatchingSkills') })), showPagination && rows.length > height && (_jsxs(Text, { color: termcnColors.muted, children: [offset + 1, "\u2013", Math.min(offset + height, rows.length), " / ", rows.length] }))] }));
101
- }
102
- function AgentTabs({ groups, agent, focused, onSelect, }) {
103
- return (_jsx("box", { flexDirection: "row", paddingLeft: 1, gap: 2, children: groups.map((group) => {
104
- const active = group.agent === agent;
105
- // Current agent always uses primary (visible after mouse click without
106
- // forcing keyboard focus onto the agents row). Keyboard-on-agents adds
107
- // selection chrome so the focus ladder is still obvious.
108
- const keyboardHere = focused && active;
109
- return (_jsx(Clickable, { onClick: () => onSelect(group.agent), children: _jsx(Text, { color: keyboardHere
110
- ? termcnColors.selectionFg
111
- : active
112
- ? termcnColors.primary
113
- : termcnColors.muted, ...(keyboardHere
114
- ? { backgroundColor: termcnColors.selectionBg, bold: true }
115
- : active
116
- ? { bold: true, underline: true }
117
- : {}), children: `${group.agent} ${group.skills.length}` }) }, group.agent));
118
- }) }));
119
- }
120
- function masterDetailColumnText(line, width, options = {}) {
121
- const padded = padColumns(sliceColumns(line, 0, width), width);
122
- if (options.selected) {
123
- return (_jsx(Text, { wrap: "truncate-end", color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, bold: true, children: padded }));
124
- }
125
- return (_jsx(Text, { wrap: "truncate-end", ...(options.muted
126
- ? { color: termcnColors.muted }
127
- : options.color
128
- ? { color: options.color }
129
- : {}), ...(options.bold ? { bold: true } : {}), children: padded }));
130
- }
131
- /** Right-pane detail row: muted labels, normal/muted values, optional bold title. */
132
- function DetailColumnRow({ row, width, selected = false, }) {
133
- if (selected) {
134
- return (_jsx(Text, { wrap: "truncate-end", color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, bold: true, children: padColumns(sliceColumns(row.label !== undefined
135
- ? `${padColumns(row.label, detailLabelWidth())}${row.text}`
136
- : row.text, 0, width), width) }));
137
- }
138
- if (row.label !== undefined) {
139
- const valueWidth = Math.max(1, width - detailLabelWidth());
140
- return (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: termcnColors.muted, children: padColumns(row.label, detailLabelWidth()) }), _jsx(Text, { ...(row.muted ? { color: termcnColors.muted } : {}), ...(row.bold ? { bold: true } : {}), ...(row.primary ? { color: termcnColors.primary } : {}), children: padColumns(sliceColumns(row.text, 0, valueWidth), valueWidth) })] }));
141
- }
142
- return (_jsx(Text, { wrap: "truncate-end", ...(row.primary ? { color: termcnColors.primary } : {}), ...(row.muted ? { color: termcnColors.muted } : {}), ...(row.bold ? { bold: true } : {}), children: padColumns(sliceColumns(row.text, 0, width), width) }));
143
- }
144
- function MasterDetailBody({ tagLines, listLines, peekLines, tagWidth, listWidth, peekWidth, tagActive, listActive, detailActive = false, detailActiveField, collectionHome = false, listActiveLineIndexes, listSelectedLineIndexes, detailRows, onTagLineClick, onListLineClick, onDetailLineClick, onListScroll, }) {
145
- const rows = Math.max(tagLines.length, listLines.length, peekLines.length, detailRows?.length ?? 0);
146
- const divided = collectionHome;
147
- const divider = divided ? '│' : '';
148
- const tagColumnWidth = tagWidth + (divider ? 1 : 0);
149
- const listColumnWidth = listWidth + (divider ? 1 : 0);
150
- // Only the skill column (2nd) owns list wheel scrolling. Detail (3rd) must not
151
- // move the list when the pointer is over it — attach scroll handler only there.
152
- const onListColumnScroll = useCallback((event) => {
153
- const info = event.scroll;
154
- if (!info || !onListScroll)
155
- return;
156
- const steps = Math.max(1, Math.abs(info.delta) || 1);
157
- if (info.direction === 'up')
158
- onListScroll(-steps);
159
- else if (info.direction === 'down')
160
- onListScroll(steps);
161
- event.stopPropagation();
162
- }, [onListScroll]);
163
- const swallowScroll = useCallback((event) => {
164
- // Keep wheel over detail/tag from bubbling to a parent list scroller.
165
- if (event.scroll)
166
- event.stopPropagation();
167
- }, []);
168
- return (_jsx("box", { flexDirection: "column", children: Array.from({ length: rows }, (_, index) => {
169
- const tagCell = masterDetailColumnText(tagLines[index] ?? '', tagWidth, {
170
- ...(tagActive && tagLines[index]?.startsWith('›')
171
- ? collectionHome
172
- ? { selected: true }
173
- : { color: termcnColors.primary, bold: true }
174
- : {}),
175
- });
176
- const listCell = masterDetailColumnText(listLines[index] ?? '', listWidth, {
177
- ...(listActiveLineIndexes?.has(index)
178
- ? { selected: true }
179
- : listSelectedLineIndexes?.has(index)
180
- ? { color: termcnColors.primary, bold: true }
181
- : listActive && listLines[index]?.startsWith('›')
182
- ? { color: termcnColors.primary, bold: true }
183
- : index % 2 === 1 && listLines[index]?.trim()
184
- ? { muted: true }
185
- : {}),
186
- });
187
- const tagInteractive = onTagLineClick && (tagLines[index] ?? '').trim().length > 0;
188
- const listInteractive = onListLineClick && (listLines[index] ?? '').trim().length > 0;
189
- return (_jsxs("box", { flexDirection: "row", children: [_jsxs("box", { width: tagColumnWidth, flexDirection: "row", onMouseScroll: swallowScroll, children: [tagInteractive ? (_jsx(Clickable, { onClick: () => onTagLineClick(index), children: tagCell })) : (tagCell), divider ? _jsx(Text, { color: termcnColors.border, children: divider }) : null] }), _jsxs("box", { width: listColumnWidth, flexDirection: "row", onMouseScroll: onListColumnScroll, children: [listInteractive ? (_jsx(Clickable, { onClick: () => onListLineClick(index), children: listCell })) : (listCell), divider ? _jsx(Text, { color: termcnColors.border, children: divider }) : null] }), _jsx("box", { flexDirection: "row", width: peekWidth, onMouseScroll: swallowScroll, children: detailRows?.[index] ? ((() => {
190
- const detailRow = detailRows[index];
191
- const fieldSelected = detailActive &&
192
- detailRow.field !== undefined &&
193
- detailRow.field === detailActiveField;
194
- const cell = (_jsx(DetailColumnRow, { row: detailRow, width: peekWidth, selected: fieldSelected }));
195
- return onDetailLineClick && detailRow.field ? (_jsx(Clickable, { onClick: () => onDetailLineClick(index), children: cell })) : (cell);
196
- })()) : (_jsx(Text, { wrap: "truncate-end", color: index === 0 && peekLines[index] !== t('browser.selectSkillToView') ? termcnColors.primary : termcnColors.muted, bold: index === 0 && peekLines[index] !== t('browser.selectSkillToView'), children: padColumns(sliceColumns(peekLines[index] ?? '', 0, peekWidth), peekWidth) })) })] }, `master-detail-row:${index}`));
197
- }) }));
198
- }
199
57
  /**
200
58
  * Browser list view. Navigation/selection live in the parent Jotai Provider
201
59
  * (BrowserApp store). Does not create a nested store.
@@ -206,17 +64,20 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
206
64
  const shellBusy = useOverlayBusy();
207
65
  const store = useStore();
208
66
  // Block list input while a long action runs (update/materialize skill row or collection sync).
209
- const actionBusy = Boolean(updatingSkillName) || workingAction === 'sync';
67
+ const actionBusy = Boolean(updatingSkillName) || Boolean(workingAction);
210
68
  // Local braille spinner only while a skill is updating (not a global busy overlay).
211
69
  const updatingFrame = useSpinnerFrame(Boolean(updatingSkillName));
212
70
  const [navigation, setNavigationState] = useAtom(browserNavigationAtom);
213
71
  const [selected, setSelected] = useAtom(browserSelectionAtom);
72
+ const setDetailField = useSetAtom(browserDetailFieldAtom);
214
73
  const navigationRef = useRef(navigation);
215
74
  navigationRef.current = navigation;
216
75
  /** Keep ref in lockstep so multi-key stdin never reads a stale focus/tab. */
217
76
  const setNavigation = (value) => {
218
77
  setNavigationState((current) => {
219
78
  const next = typeof value === 'function' ? value(current) : value;
79
+ if (sameNavigation(current, next))
80
+ return current;
220
81
  navigationRef.current = next;
221
82
  return next;
222
83
  });
@@ -249,22 +110,24 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
249
110
  const cursorRef = useRef(cursor);
250
111
  cursorRef.current = cursor;
251
112
  const setTab = (value) => {
252
- setNavigation((current) => (current ? { ...current, tab: value } : current));
113
+ setNavigation((current) => (current && current.tab !== value ? { ...current, tab: value } : current));
253
114
  };
254
115
  const setQuery = (value) => {
255
- setNavigation((current) => (current ? { ...current, query: value } : current));
116
+ setNavigation((current) => current && current.query !== value ? { ...current, query: value } : current);
256
117
  };
257
118
  const setAgent = (value) => {
258
- setNavigation((current) => (current ? { ...current, agent: value } : current));
119
+ setNavigation((current) => current && current.agent !== value ? { ...current, agent: value } : current);
259
120
  };
260
121
  const setFocus = (value) => {
261
- setNavigation((current) => (current ? { ...current, focus: value } : current));
122
+ setNavigation((current) => current && current.focus !== value ? { ...current, focus: value } : current);
262
123
  };
263
124
  const setCursor = (value) => {
264
125
  setNavigation((current) => {
265
126
  if (!current)
266
127
  return current;
267
128
  const nextCursor = typeof value === 'function' ? value(current.cursor) : value;
129
+ if (nextCursor === current.cursor)
130
+ return current;
268
131
  cursorRef.current = nextCursor;
269
132
  return { ...current, cursor: nextCursor };
270
133
  });
@@ -276,23 +139,36 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
276
139
  const { selectedCollection, selectedProject, selectedGlobal, selectedProjectLocal, selectedGlobalLocal, } = browseSelectionSets(selected, { collection, projectGroups, globalGroups });
277
140
  const selectedUpdates = selectedCollection.filter((skill) => updateCheck.updates.has(skill.name));
278
141
  const { stdout } = useStdout();
279
- // Wide terminals keep the 3-column master-detail chrome even while filtering;
142
+ // Wide terminals keep the 3-column master-detail panes even while filtering;
280
143
  // list rows still apply `query` inside the skill column.
281
144
  const useBrowseHome = masterDetailLayout(stdout.columns, stdout.rows);
282
145
  const useMasterDetail = useBrowseHome;
146
+ const useCompact = compactLayout(stdout.columns, stdout.rows);
283
147
  // Scope for list + tag sidebar + g-jump: current agent (or full collection),
284
148
  // never the whole project/global flat list.
285
149
  const tabSkills = tab === 'collection'
286
150
  ? collection
287
151
  : tab === 'project'
288
- ? projectGroup?.skills ?? []
152
+ ? projectGroup?.skills ?? EMPTY_SKILLS
289
153
  : tab === 'global'
290
- ? globalGroup?.skills ?? []
291
- : [];
154
+ ? globalGroup?.skills ?? EMPTY_SKILLS
155
+ : EMPTY_SKILLS;
292
156
  const groupRows = useMemo(() => groupedRows(tabSkills, ''), [tabSkills]);
293
- const groups = groupRows.filter((row) => row.type === 'group');
157
+ const groups = useMemo(() => groupRows.filter((row) => row.type === 'group'), [groupRows]);
294
158
  const tagOptions = useMemo(() => tagFilterOptions(tabSkills, groups), [groups, tabSkills]);
295
- const [tagFilter, setTagFilter] = useAtom(browserTagFilterAtom);
159
+ const [tagFilter, setTagFilterState] = useAtom(browserTagFilterAtom);
160
+ const setTagFilter = (value) => {
161
+ setTagFilterState((current) => (current === value ? current : value));
162
+ };
163
+ const setSelectedIfChanged = (next) => {
164
+ setSelected((current) => {
165
+ if (current === next)
166
+ return current;
167
+ if (current.size === next.size && [...next].every((id) => current.has(id)))
168
+ return current;
169
+ return next;
170
+ });
171
+ };
296
172
  const [tagCursor, setTagCursor] = useState(0);
297
173
  const tagCursorRef = useRef(tagCursor);
298
174
  tagCursorRef.current = tagCursor;
@@ -316,29 +192,34 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
316
192
  actionSkills.length > 0 &&
317
193
  actionSkills.every((skill) => isCrossAgentInstallable(skill));
318
194
  const canOpenActions = canMaterialize || canInstallToAgents;
319
- const previousTab = useRef(tab);
320
- useEffect(() => {
321
- if (previousTab.current !== tab) {
322
- setCursor(0);
323
- setSelected(new Set());
324
- setTagFilter(TAG_FILTER_ALL);
325
- setTagCursor(0);
326
- previousTab.current = tab;
327
- }
328
- }, [tab]);
329
- const previousAgent = useRef(agent);
330
- useEffect(() => {
331
- if (previousAgent.current !== agent) {
332
- setCursor(0);
333
- setTagFilter(TAG_FILTER_ALL);
334
- setTagCursor(0);
335
- previousAgent.current = agent;
336
- }
337
- }, [agent]);
338
- useEffect(() => {
339
- if (focus === 'agents' && !hasAgentTabs)
340
- setFocus(useMasterDetail ? 'tags' : 'list');
341
- }, [focus, hasAgentTabs, useMasterDetail]);
195
+ useBrowseSessionEffects({
196
+ tab,
197
+ agent,
198
+ focus,
199
+ cursor,
200
+ listLength: listRows.length,
201
+ hasAgents: hasAgentTabs,
202
+ masterDetail: useMasterDetail,
203
+ currentIsItem: currentRow?.type === 'skill',
204
+ setFocus,
205
+ setCursor,
206
+ setSelected: setSelectedIfChanged,
207
+ setTagFilter,
208
+ setTagCursor,
209
+ });
210
+ const applySession = (patch) => {
211
+ applyBrowseSessionPatch(patch, {
212
+ setNav: (nav) => setNavigation(nav),
213
+ setTagFilter,
214
+ setTagCursor,
215
+ setSelected: setSelectedIfChanged,
216
+ setDetailFieldIndex,
217
+ setChoosingGroup,
218
+ tagCursorRef,
219
+ detailFieldIndexRef,
220
+ cursorRef,
221
+ });
222
+ };
342
223
  useEffect(() => {
343
224
  if (tab !== 'collection')
344
225
  return;
@@ -375,7 +256,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
375
256
  hasGlobalAgents: visibleGlobalGroups.length > 0,
376
257
  });
377
258
  const openDetail = (skill, collection) => {
378
- // Master-detail chrome fills the terminal; browserFrameDimensions still
259
+ // Master-detail panes fills the terminal; browserFrameDimensions still
379
260
  // sizes by list row count and can be only a few lines on a short list.
380
261
  // Full-screen detail must use the terminal viewport, not that stub height.
381
262
  const frameHeight = useBrowseHome
@@ -389,8 +270,9 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
389
270
  frameWidth: frame.frameWidth,
390
271
  });
391
272
  };
392
- const agentPaneViewportHeight = Math.max(3, frame.frameHeight - 3);
393
- const collectionPaneViewportHeight = Math.max(3, frame.frameHeight - 2);
273
+ const listFloor = useCompact ? 1 : 3;
274
+ const agentPaneViewportHeight = Math.max(listFloor, frame.frameHeight - 3);
275
+ const collectionPaneViewportHeight = Math.max(listFloor, frame.frameHeight - 2);
394
276
  const masterDetailInnerWidth = Math.max(40, frame.frameWidth - 2);
395
277
  const masterDetailColumns = masterDetailWidths(masterDetailInnerWidth, useBrowseHome);
396
278
  const masterDetailBrowseHeight = (withAgents) => masterDetailViewportHeight(stdout.rows, 1 + 2 + 3 + (withAgents ? 1 : 0));
@@ -399,6 +281,9 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
399
281
  : withAgents
400
282
  ? agentPaneViewportHeight
401
283
  : collectionPaneViewportHeight;
284
+ const tabBodyMinHeight = useMasterDetail
285
+ ? Math.max(8, (stdout.rows ?? 24) - 2)
286
+ : frame.frameHeight - 1;
402
287
  const masterListVisibleHeight = Math.max(1, Math.floor(masterDetailBrowseHeight(false) / 2));
403
288
  const masterListOffset = useMasterDetail
404
289
  ? Math.max(0, Math.min(cursor - Math.floor(masterListVisibleHeight / 2), Math.max(0, listRows.length - masterListVisibleHeight)))
@@ -406,10 +291,14 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
406
291
  const peekSkill = (focus === 'list' || focus === 'detail') && currentRow?.type === 'skill'
407
292
  ? currentRow.skill
408
293
  : undefined;
409
- const detailFields = detailEditableFields(tab === 'collection');
294
+ const detailSkill = currentRow?.type === 'skill' ? currentRow.skill : undefined;
295
+ const detailFields = detailEditableFields(tab === 'collection', detailSkill);
410
296
  const activeDetailField = focus === 'detail' && detailFields.length
411
297
  ? detailFields[Math.max(0, Math.min(detailFieldIndex, detailFields.length - 1))]
412
298
  : undefined;
299
+ useEffect(() => {
300
+ setDetailField(focus === 'detail' ? activeDetailField : undefined);
301
+ }, [focus, activeDetailField, setDetailField]);
413
302
  useEffect(() => {
414
303
  if ((focus === 'detail' || focus === 'tags') && !useMasterDetail)
415
304
  setFocus('list');
@@ -459,160 +348,60 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
459
348
  });
460
349
  return;
461
350
  }
462
- // Jump tags: wide master-detail already has a tag column — focus it (no popup).
463
- // Narrow layout still uses a full-content Select over group headers.
464
- if (input === 'g') {
465
- if (useMasterDetail && tagOptions.length > 0) {
466
- const index = Math.max(0, tagOptions.findIndex((option) => option.key === tagFilter));
467
- setTagCursor(index);
468
- tagCursorRef.current = index;
469
- setFocus('tags');
470
- return;
471
- }
472
- if (groups.length) {
473
- setChoosingGroup(true);
474
- }
475
- return;
476
- }
477
351
  if (input === 's' && liveTab === 'collection' && canSync) {
478
352
  return finish({ type: 'sync' });
479
353
  }
480
- // Focus ladder + tab/agent switching: always branch on the live ref so
481
- // multi-key stdin batches each advance from the latest navigation.
482
- if (key.downArrow || key.upArrow || key.leftArrow || key.rightArrow) {
483
- if (liveFocus === 'tabs' || liveFocus === 'agents' || liveFocus === 'tags') {
484
- const direction = key.leftArrow ? -1 : key.rightArrow ? 1 : 0;
485
- setNavigation((current) => {
486
- if (!current)
487
- return current;
488
- const groups = current.tab === 'project'
489
- ? visibleProjectGroups
490
- : current.tab === 'global'
491
- ? visibleGlobalGroups
492
- : [];
493
- const hasAgents = groups.length > 0;
494
- const names = groups.map((group) => group.agent);
495
- if (current.focus === 'tabs') {
496
- if (key.downArrow) {
497
- return {
498
- ...current,
499
- focus: focusAfterDownFromTabs(hasAgents, useMasterDetail),
500
- };
501
- }
502
- if (key.leftArrow || key.rightArrow) {
503
- const next = nextMainTab(current.tab, direction);
504
- return next ? { ...current, tab: next } : current;
505
- }
506
- return current;
507
- }
508
- if (current.focus === 'agents') {
509
- if (key.upArrow)
510
- return { ...current, focus: 'tabs' };
511
- if (key.downArrow) {
512
- return {
513
- ...current,
514
- focus: focusAfterDownFromAgents(useMasterDetail),
515
- };
516
- }
517
- if (key.leftArrow || key.rightArrow) {
518
- const next = nextAgent(names, current.agent || names[0] || '', direction);
519
- return next ? { ...current, agent: next } : current;
520
- }
521
- return current;
522
- }
523
- if (current.focus === 'tags') {
524
- // ↑/↓ move among tag rows (handled below). Only ←/→ change the focus ladder here.
525
- if (key.leftArrow)
526
- return { ...current, focus: focusAfterUpFromTags(hasAgents) };
527
- if (key.rightArrow)
528
- return { ...current, focus: 'list' };
529
- return current;
530
- }
531
- return current;
532
- });
533
- // Tag index moves stay on the tags-local path below when still on tags.
534
- if (liveFocus !== 'tags' || key.leftArrow || key.rightArrow)
535
- return;
536
- }
537
- }
538
- if (liveFocus === 'tabs' || liveFocus === 'agents') {
539
- return;
354
+ if ((key.return || input.includes('\r') || input.includes('\n')) &&
355
+ liveFocus === 'list' &&
356
+ liveTab === 'collection' &&
357
+ selectedCollection.length) {
358
+ return finish({ type: 'add', skills: selectedCollection });
540
359
  }
541
- if (liveFocus === 'tags' || focus === 'tags') {
542
- const selectTag = (index) => {
543
- const option = tagOptions[index];
544
- if (!option)
545
- return;
546
- setTagFilter(option.key);
547
- tagCursorRef.current = index;
548
- setTagCursor(index);
549
- setCursor(0);
550
- };
551
- const liveTagCursor = tagCursorRef.current;
552
- if (key.upArrow) {
553
- if (liveTagCursor === 0)
554
- return setFocus(focusAfterUpFromTags(hasAgentTabs));
555
- selectTag(liveTagCursor - 1);
556
- return;
557
- }
558
- if (key.downArrow) {
559
- if (liveTagCursor >= tagOptions.length - 1)
560
- return setFocus('list');
561
- selectTag(liveTagCursor + 1);
562
- return;
563
- }
564
- if (key.leftArrow)
565
- return setFocus(focusAfterUpFromTags(hasAgentTabs));
566
- if (key.rightArrow) {
567
- selectTag(liveTagCursor);
568
- return setFocus('list');
569
- }
570
- const tagOption = tagOptions[liveTagCursor];
571
- if (input === ' ' && tagOption) {
572
- const paths = tagOption.skills.map((skill) => skill.path);
573
- return setSelected((previous) => {
574
- const next = new Set(previous);
575
- const allSelected = paths.every((path) => previous.has(path));
576
- for (const path of paths)
577
- allSelected ? next.delete(path) : next.add(path);
578
- return next;
579
- });
580
- }
581
- if (key.return || input.includes('\r') || input.includes('\n')) {
582
- selectTag(liveTagCursor);
583
- return setFocus('list');
584
- }
360
+ const liveNav = live ?? {
361
+ tab: liveTab,
362
+ focus: liveFocus,
363
+ agent,
364
+ cursor: cursorRef.current,
365
+ query,
366
+ };
367
+ const liveRow = listRows[liveNav.cursor];
368
+ const session = reduceBrowseSessionKey({
369
+ nav: liveNav,
370
+ tagFilter,
371
+ tagCursor: tagCursorRef.current,
372
+ selected,
373
+ detailFieldIndex: detailFieldIndexRef.current,
374
+ }, input, key, {
375
+ hasAgents: hasAgentTabs,
376
+ masterDetail: useMasterDetail,
377
+ projectAgentNames: visibleProjectGroups.map((group) => group.agent),
378
+ globalAgentNames: visibleGlobalGroups.map((group) => group.agent),
379
+ tagOptions,
380
+ listLength: listRows.length,
381
+ currentItemIds: liveRow ? selectableSkills(liveRow).map((skill) => skill.path) : [],
382
+ currentIsItem: liveRow?.type === 'skill',
383
+ allowNarrowGroupJump: groups.length > 0,
384
+ detailFieldCount: detailEditableFields(liveNav.tab === 'collection', liveRow?.type === 'skill' ? liveRow.skill : undefined).length,
385
+ detailEntryFieldIndex: detailEntryFieldIndex(detailEditableFields(liveNav.tab === 'collection', liveRow?.type === 'skill' ? liveRow.skill : undefined)),
386
+ });
387
+ if (session.handled) {
388
+ applySession(session.patch);
585
389
  return;
586
390
  }
587
- // Right column: move among editable fields (标签 / 备注); Enter opens editor.
588
- if (liveFocus === 'detail' || focus === 'detail') {
391
+ if (liveNav.focus === 'detail') {
589
392
  const detailRow = listRows[cursorRef.current];
590
393
  const skill = detailRow?.type === 'skill' ? detailRow.skill : undefined;
591
- const fields = detailEditableFields(tab === 'collection');
592
- if (key.leftArrow)
593
- return setFocus('list');
594
- if (key.upArrow) {
595
- if (!fields.length)
596
- return;
597
- setDetailFieldIndex((index) => Math.max(0, index - 1));
598
- return;
599
- }
600
- if (key.downArrow) {
601
- if (!fields.length)
602
- return;
603
- setDetailFieldIndex((index) => Math.min(fields.length - 1, index + 1));
604
- return;
605
- }
606
- if (key.rightArrow)
607
- return;
394
+ const fields = detailEditableFields(liveNav.tab === 'collection', skill);
608
395
  const field = fields[detailFieldIndexRef.current] ?? fields[0];
609
396
  if (skill && field && (key.return || input.includes('\r') || input.includes('\n'))) {
397
+ if (field === 'source')
398
+ return finish({ type: 'openSource', skill });
610
399
  if (field === 'tags')
611
400
  return finish({ type: 'editTags', skill });
612
401
  if (field === 'note')
613
402
  return finish({ type: 'editNote', skill });
614
403
  }
615
- if (skill && tab === 'collection') {
404
+ if (skill && liveNav.tab === 'collection') {
616
405
  if (input === 't')
617
406
  return finish({ type: 'editTags', skill });
618
407
  if (input === 'n')
@@ -620,7 +409,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
620
409
  }
621
410
  return;
622
411
  }
623
- if ((navigationRef.current?.focus ?? focus) !== 'list')
412
+ if (liveNav.focus !== 'list')
624
413
  return;
625
414
  const row = listRows[cursorRef.current];
626
415
  if (input === 'm' && canOpenActions) {
@@ -756,58 +545,15 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
756
545
  });
757
546
  return;
758
547
  }
759
- if (key.leftArrow && useMasterDetail)
760
- return setFocus('tags');
761
- if (key.upArrow) {
762
- if (cursorRef.current === 0) {
763
- return setFocus(focusAfterUpFromList(useMasterDetail, hasAgentTabs));
764
- }
765
- return setCursor((index) => index - 1);
766
- }
767
- if (key.downArrow) {
768
- return setCursor((index) => Math.min(Math.max(0, listRows.length - 1), index + 1));
769
- }
770
- if (input === ' ' && row) {
771
- const paths = selectableSkills(row).map((skill) => skill.path);
772
- if (!paths.length)
773
- return;
774
- return setSelected((previous) => {
775
- const next = new Set(previous);
776
- const allSelected = paths.every((path) => previous.has(path));
777
- for (const path of paths)
778
- allSelected ? next.delete(path) : next.add(path);
779
- return next;
780
- });
781
- }
782
- // Collection only: wide → focuses detail column; narrow → opens fullscreen detail.
783
- // Project / global: right pane is preview only — no → focus/open detail.
784
- if (key.rightArrow && row?.type === 'skill' && tab === 'collection') {
785
- if (useMasterDetail) {
786
- setDetailFieldIndex(0);
787
- return setFocus('detail');
788
- }
789
- if (!useBrowseHome) {
790
- return openDetail(row.skill, true);
791
- }
548
+ if (key.rightArrow && row?.type === 'skill' && tab === 'collection' && !useMasterDetail) {
549
+ return openDetail(row.skill, true);
792
550
  }
793
551
  if (key.return || input.includes('\r') || input.includes('\n')) {
794
552
  if (tab === 'collection' && selectedCollection.length) {
795
553
  return finish({ type: 'add', skills: selectedCollection });
796
554
  }
797
- // Master-detail collection: Enter focuses detail column (never silent no-op).
798
- // Project/global master-detail: peek-only — no Enter open.
799
- if (useMasterDetail) {
800
- if (tab === 'collection' && row?.type === 'skill') {
801
- setDetailFieldIndex(0);
802
- return setFocus('detail');
803
- }
804
- return;
805
- }
806
- if (tab === 'collection' && row?.type === 'skill') {
807
- return openDetail(row.skill, true);
808
- }
809
- if (tab !== 'collection' && row?.type === 'skill') {
810
- return openDetail(row.skill, false);
555
+ if (row?.type === 'skill') {
556
+ return openDetail(row.skill, tab === 'collection');
811
557
  }
812
558
  }
813
559
  }, {
@@ -840,47 +586,43 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
840
586
  const renderBrowsePane = (paneRows, viewportHeight, options = {}) => {
841
587
  if (useBrowseHome) {
842
588
  const { tagWidth, listWidth, peekWidth } = masterDetailColumns;
843
- const selectedPaths = selected;
844
- const tagActiveIndex = Math.max(0, Math.min(tagCursor, tagOptions.length - 1));
845
- const tagOffset = Math.max(0, Math.min(tagActiveIndex - Math.floor(viewportHeight / 2), Math.max(0, tagOptions.length - viewportHeight)));
846
- const tagLines = collectionCategoryLines(tagOptions, tagCursor, focus === 'tags', tagWidth, viewportHeight);
847
- const { lines: listLines, skillOffset, activeLineIndexes: listActiveLineIndexes, selectedLineIndexes: listSelectedLineIndexes, } = collectionListColumnLines(paneRows, cursor, focus === 'list', options.preferNote ?? false, listWidth, viewportHeight, selectedPaths, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
589
+ const { lines: listLines, skillOffset, activeLineIndexes: listActiveLineIndexes, selectedLineIndexes: listSelectedLineIndexes, } = collectionListColumnLines(paneRows, cursor, focus === 'list', options.preferNote ?? false, listWidth, viewportHeight, selected, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
848
590
  const detailRows = browseDetailRows(peekSkill, peekWidth, viewportHeight, options.collection ?? false, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
849
- const headerLine = (left, middle, right) => (_jsxs("box", { flexDirection: "row", children: [_jsxs("box", { width: tagWidth + 1, flexDirection: "row", children: [_jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(left, tagWidth) }), _jsx(Text, { color: termcnColors.border, children: "\u2502" })] }), _jsxs("box", { width: listWidth + 1, flexDirection: "row", children: [_jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(middle, listWidth) }), _jsx(Text, { color: termcnColors.border, children: "\u2502" })] }), _jsx("box", { flexDirection: "row", width: peekWidth, children: _jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(right, peekWidth) }) })] }));
850
- return (_jsxs("box", { flexDirection: "column", children: [_jsx(Text, { color: termcnColors.border, wrap: "truncate-end", children: masterDetailSeparator(tagWidth, listWidth, peekWidth, 'top', true) }), headerLine(t('common.tags'), t('common.skill'), t('common.detail')), masterDetailBlankRow(tagWidth, listWidth, peekWidth), _jsx(MasterDetailBody, { tagLines: tagLines, listLines: listLines, peekLines: [], tagWidth: tagWidth, listWidth: listWidth, peekWidth: peekWidth, tagActive: focus === 'tags', listActive: focus === 'list', detailActive: focus === 'detail', ...(activeDetailField ? { detailActiveField: activeDetailField } : {}), collectionHome: true, ...(listActiveLineIndexes ? { listActiveLineIndexes } : {}), ...(listSelectedLineIndexes ? { listSelectedLineIndexes } : {}), detailRows: detailRows, onTagLineClick: (visibleIndex) => {
851
- const absolute = tagOffset + visibleIndex;
852
- if (absolute < 0 || absolute >= tagOptions.length)
853
- return;
854
- const option = tagOptions[absolute];
855
- if (!option)
856
- return;
857
- setTagFilter(option.key);
858
- setTagCursor(absolute);
859
- setCursor(0);
860
- setFocus('tags');
861
- }, onListLineClick: (visibleIndex) => {
862
- // Paired name/summary lines → skill index.
863
- // Click focuses the row only; Space toggles multi-select.
864
- const skillIndex = skillOffset + Math.floor(visibleIndex / 2);
865
- if (skillIndex < 0 || skillIndex >= paneRows.length)
866
- return;
867
- setCursor(skillIndex);
868
- setFocus('list');
869
- }, onDetailLineClick: (visibleIndex) => {
870
- const row = detailRows[visibleIndex];
871
- if (!row?.field)
872
- return;
873
- const index = detailFields.indexOf(row.field);
874
- if (index < 0)
875
- return;
876
- setDetailFieldIndex(index);
877
- setFocus('detail');
878
- }, onListScroll: (delta) => {
879
- setFocus('list');
880
- setCursor((index) => Math.max(0, Math.min(Math.max(0, paneRows.length - 1), index + delta)));
881
- } }), _jsx(Text, { color: termcnColors.border, wrap: "truncate-end", children: masterDetailSeparator(tagWidth, listWidth, peekWidth, 'bottom', true) })] }));
591
+ return (_jsx(BrowseHomePane, { tagOptions: tagOptions, tagCursor: tagCursor, listLines: listLines, skillOffset: skillOffset, listLength: paneRows.length, ...(listActiveLineIndexes ? { listActiveLineIndexes } : {}), ...(listSelectedLineIndexes ? { listSelectedLineIndexes } : {}), detailRows: detailRows, ...(activeDetailField ? { detailActiveField: activeDetailField } : {}), tagWidth: tagWidth, listWidth: listWidth, peekWidth: peekWidth, viewportHeight: viewportHeight, tagActive: focus === 'tags', listActive: focus === 'list', detailActive: focus === 'detail', onTagIndex: (index) => {
592
+ const liveNav = navigationRef.current;
593
+ if (!liveNav)
594
+ return;
595
+ const patch = browseSessionClickTag(liveNav, tagOptions, index);
596
+ if (patch)
597
+ applySession(patch);
598
+ }, onListIndex: (index) => {
599
+ const liveNav = navigationRef.current;
600
+ if (!liveNav)
601
+ return;
602
+ applySession(browseSessionClickList(liveNav, index));
603
+ }, onDetailLine: (visibleIndex) => {
604
+ const row = detailRows[visibleIndex];
605
+ if (!row?.field)
606
+ return;
607
+ const index = detailFields.indexOf(row.field);
608
+ if (index < 0)
609
+ return;
610
+ if (row.field === 'source' && peekSkill) {
611
+ finish({ type: 'openSource', skill: peekSkill });
612
+ return;
613
+ }
614
+ const liveNav = navigationRef.current;
615
+ if (!liveNav)
616
+ return;
617
+ applySession(browseSessionClickDetail(liveNav, index));
618
+ }, onListScroll: (delta) => {
619
+ const liveNav = navigationRef.current;
620
+ if (!liveNav)
621
+ return;
622
+ applySession(browseSessionScrollList(liveNav, delta, paneRows.length));
623
+ } }));
882
624
  }
883
- return (_jsx(SkillPane, { rows: paneRows, cursor: cursor, isActive: focus === 'list', viewportHeight: viewportHeight, onRowClick: (index) => {
625
+ return (_jsx(SkillPane, { rows: paneRows, cursor: cursor, isActive: focus === 'list', selected: selected, compact: useCompact, showPagination: !useCompact, viewportHeight: viewportHeight, onRowClick: (index) => {
884
626
  // Click focuses the row only; Space toggles multi-select.
885
627
  setCursor(index);
886
628
  setFocus('list');
@@ -889,40 +631,46 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
889
631
  setCursor((index) => Math.max(0, Math.min(Math.max(0, paneRows.length - 1), index + delta)));
890
632
  }, ...options }));
891
633
  };
634
+ const activeBrowsePane = tab === 'collection'
635
+ ? renderBrowsePane(listRows, browseViewportHeight(false), {
636
+ preferNote: true,
637
+ collection: true,
638
+ showGroup: Boolean(query.trim()),
639
+ updates: updateCheck.updates,
640
+ updatingSkillName,
641
+ })
642
+ : renderBrowsePane(listRows, browseViewportHeight(true), {
643
+ showSource: true,
644
+ showReferences: tab === 'project',
645
+ showGroup: Boolean(query.trim()),
646
+ });
892
647
  const tabs = [
893
648
  {
894
649
  key: 'project',
895
650
  label: t('browser.tabProject', { count: project.length }),
896
- content: (_jsxs("box", { flexDirection: "column", minHeight: frame.frameHeight - 1, children: [_jsx(AgentTabs, { groups: visibleProjectGroups, agent: activeProjectAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
651
+ content: tab === 'project' ? (_jsxs("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: [_jsx(AgentTabs, { groups: visibleProjectGroups.map((group) => ({
652
+ agent: group.agent,
653
+ count: group.skills.length,
654
+ })), agent: activeProjectAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
897
655
  setAgent(name);
898
656
  setCursor(0);
899
- } }), renderBrowsePane(listRows, browseViewportHeight(true), {
900
- showSource: true,
901
- showReferences: true,
902
- showGroup: Boolean(query.trim()),
903
- })] })),
657
+ } }), activeBrowsePane] })) : null,
904
658
  },
905
659
  {
906
660
  key: 'global',
907
661
  label: t('browser.tabGlobal', { count: globalGroups.reduce((count, group) => count + group.skills.length, 0) }),
908
- content: (_jsxs("box", { flexDirection: "column", minHeight: frame.frameHeight - 1, children: [_jsx(AgentTabs, { groups: visibleGlobalGroups, agent: activeGlobalAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
662
+ content: tab === 'global' ? (_jsxs("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: [_jsx(AgentTabs, { groups: visibleGlobalGroups.map((group) => ({
663
+ agent: group.agent,
664
+ count: group.skills.length,
665
+ })), agent: activeGlobalAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
909
666
  setAgent(name);
910
667
  setCursor(0);
911
- } }), renderBrowsePane(listRows, browseViewportHeight(true), {
912
- showSource: true,
913
- showGroup: Boolean(query.trim()),
914
- })] })),
668
+ } }), activeBrowsePane] })) : null,
915
669
  },
916
670
  {
917
671
  key: 'collection',
918
672
  label: t('browser.tabCollection', { count: collection.length }),
919
- content: (_jsx("box", { flexDirection: "column", minHeight: frame.frameHeight - 1, children: renderBrowsePane(listRows, browseViewportHeight(false), {
920
- preferNote: true,
921
- collection: true,
922
- showGroup: Boolean(query.trim()),
923
- updates: updateCheck.updates,
924
- updatingSkillName,
925
- }) })),
673
+ content: tab === 'collection' ? (_jsx("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: activeBrowsePane })) : null,
926
674
  },
927
675
  ];
928
676
  // Narrow layout only — wide layout focuses the tag column instead of this Select.