iskills 0.2.27 → 0.2.40

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 (220) hide show
  1. package/README.md +8 -13
  2. package/bin/iskills.js +9 -0
  3. package/dist/src/cli.js +16 -17
  4. package/dist/src/cli.js.map +1 -1
  5. package/dist/src/commands/browser-actions.d.ts +5 -0
  6. package/dist/src/commands/browser-actions.js +345 -0
  7. package/dist/src/commands/browser-actions.js.map +1 -0
  8. package/dist/src/commands/index.d.ts +3 -6
  9. package/dist/src/commands/index.js +18 -131
  10. package/dist/src/commands/index.js.map +1 -1
  11. package/dist/src/commands/library.d.ts +0 -1
  12. package/dist/src/commands/library.js +40 -216
  13. package/dist/src/commands/library.js.map +1 -1
  14. package/dist/src/commands/search.js +32 -47
  15. package/dist/src/commands/search.js.map +1 -1
  16. package/dist/src/domain/collection-write.d.ts +22 -0
  17. package/dist/src/domain/collection-write.js +411 -0
  18. package/dist/src/domain/collection-write.js.map +1 -0
  19. package/dist/src/domain/core.d.ts +2 -10
  20. package/dist/src/domain/core.js +18 -261
  21. package/dist/src/domain/core.js.map +1 -1
  22. package/dist/src/domain/git.js +15 -25
  23. package/dist/src/domain/git.js.map +1 -1
  24. package/dist/src/domain/types.d.ts +7 -1
  25. package/dist/src/ui/browser/browser.d.ts +11 -0
  26. package/dist/src/ui/browser/browser.js +657 -0
  27. package/dist/src/ui/browser/browser.js.map +1 -0
  28. package/dist/src/ui/browser/detail.d.ts +12 -0
  29. package/dist/src/ui/browser/detail.js +47 -0
  30. package/dist/src/ui/browser/detail.js.map +1 -0
  31. package/dist/src/ui/browser/footer.d.ts +6 -0
  32. package/dist/src/ui/browser/footer.js +199 -0
  33. package/dist/src/ui/browser/footer.js.map +1 -0
  34. package/dist/src/ui/browser/format.d.ts +105 -0
  35. package/dist/src/ui/browser/format.js +421 -0
  36. package/dist/src/ui/browser/format.js.map +1 -0
  37. package/dist/src/ui/browser/index.d.ts +16 -0
  38. package/dist/src/ui/browser/index.js +176 -0
  39. package/dist/src/ui/browser/index.js.map +1 -0
  40. package/dist/src/ui/browser/layout.d.ts +31 -0
  41. package/dist/src/ui/browser/layout.js +55 -0
  42. package/dist/src/ui/browser/layout.js.map +1 -0
  43. package/dist/src/ui/browser/shortcut-help.d.ts +10 -0
  44. package/dist/src/ui/browser/shortcut-help.js +124 -0
  45. package/dist/src/ui/browser/shortcut-help.js.map +1 -0
  46. package/dist/src/ui/browser/store.d.ts +59 -0
  47. package/dist/src/ui/browser/store.js +81 -0
  48. package/dist/src/ui/browser/store.js.map +1 -0
  49. package/dist/src/ui/browser/types.d.ts +134 -0
  50. package/dist/src/ui/browser/types.js +2 -0
  51. package/dist/src/ui/browser/types.js.map +1 -0
  52. package/dist/src/ui/collection-match.d.ts +7 -0
  53. package/dist/src/ui/collection-match.js +15 -0
  54. package/dist/src/ui/collection-match.js.map +1 -0
  55. package/dist/src/ui/components/colors.d.ts +7 -0
  56. package/dist/src/ui/components/colors.js +10 -0
  57. package/dist/src/ui/components/colors.js.map +1 -0
  58. package/dist/src/ui/components/confirm.d.ts +6 -0
  59. package/dist/src/ui/components/confirm.js +22 -0
  60. package/dist/src/ui/components/confirm.js.map +1 -0
  61. package/dist/src/ui/components/framed-panel.d.ts +21 -0
  62. package/dist/src/ui/components/framed-panel.js +66 -0
  63. package/dist/src/ui/components/framed-panel.js.map +1 -0
  64. package/dist/src/ui/components/link.d.ts +7 -0
  65. package/dist/src/ui/components/link.js +12 -0
  66. package/dist/src/ui/components/link.js.map +1 -0
  67. package/dist/src/ui/components/modal.d.ts +16 -0
  68. package/dist/src/ui/components/modal.js +58 -0
  69. package/dist/src/ui/components/modal.js.map +1 -0
  70. package/dist/src/ui/components/mouse/bounds.d.ts +13 -0
  71. package/dist/src/ui/components/mouse/bounds.js +29 -0
  72. package/dist/src/ui/components/mouse/bounds.js.map +1 -0
  73. package/dist/src/ui/components/mouse/clickable.d.ts +10 -0
  74. package/dist/src/ui/components/mouse/clickable.js +14 -0
  75. package/dist/src/ui/components/mouse/clickable.js.map +1 -0
  76. package/dist/src/ui/components/mouse/index.d.ts +4 -0
  77. package/dist/src/ui/components/mouse/index.js +5 -0
  78. package/dist/src/ui/components/mouse/index.js.map +1 -0
  79. package/dist/src/ui/components/mouse/parse.d.ts +13 -0
  80. package/dist/src/ui/components/mouse/parse.js +54 -0
  81. package/dist/src/ui/components/mouse/parse.js.map +1 -0
  82. package/dist/src/ui/components/mouse/provider.d.ts +31 -0
  83. package/dist/src/ui/components/mouse/provider.js +114 -0
  84. package/dist/src/ui/components/mouse/provider.js.map +1 -0
  85. package/dist/src/ui/components/multi-select.d.ts +9 -0
  86. package/dist/src/ui/components/multi-select.js +49 -0
  87. package/dist/src/ui/components/multi-select.js.map +1 -0
  88. package/dist/src/ui/components/options.d.ts +20 -0
  89. package/dist/src/ui/components/options.js +47 -0
  90. package/dist/src/ui/components/options.js.map +1 -0
  91. package/dist/src/ui/components/select.d.ts +9 -0
  92. package/dist/src/ui/components/select.js +47 -0
  93. package/dist/src/ui/components/select.js.map +1 -0
  94. package/dist/src/ui/components/tabs.d.ts +18 -0
  95. package/dist/src/ui/components/tabs.js +38 -0
  96. package/dist/src/ui/components/tabs.js.map +1 -0
  97. package/dist/src/ui/components/tag-editor.d.ts +8 -0
  98. package/dist/src/ui/components/tag-editor.js +56 -0
  99. package/dist/src/ui/components/tag-editor.js.map +1 -0
  100. package/dist/src/ui/components/termcn.d.ts +12 -0
  101. package/dist/src/ui/components/termcn.js +12 -0
  102. package/dist/src/ui/components/termcn.js.map +1 -0
  103. package/dist/src/ui/components/terminal-layout.d.ts +4 -0
  104. package/dist/src/ui/components/terminal-layout.js +43 -0
  105. package/dist/src/ui/components/terminal-layout.js.map +1 -0
  106. package/dist/src/ui/components/text-input.d.ts +10 -0
  107. package/dist/src/ui/components/text-input.js +78 -0
  108. package/dist/src/ui/components/text-input.js.map +1 -0
  109. package/dist/src/ui/components/text.d.ts +2 -0
  110. package/dist/src/ui/components/text.js +8 -0
  111. package/dist/src/ui/components/text.js.map +1 -0
  112. package/dist/src/ui/components/use-input.d.ts +12 -0
  113. package/dist/src/ui/components/use-input.js +21 -0
  114. package/dist/src/ui/components/use-input.js.map +1 -0
  115. package/dist/src/ui/footer/resolve-footer.d.ts +8 -0
  116. package/dist/src/ui/footer/resolve-footer.js +178 -0
  117. package/dist/src/ui/footer/resolve-footer.js.map +1 -0
  118. package/dist/src/ui/footer/types.d.ts +63 -0
  119. package/dist/src/ui/footer/types.js +2 -0
  120. package/dist/src/ui/footer/types.js.map +1 -0
  121. package/dist/src/ui/import/index.d.ts +7 -0
  122. package/dist/src/ui/import/index.js +7 -0
  123. package/dist/src/ui/import/index.js.map +1 -0
  124. package/dist/src/ui/import/review.d.ts +9 -0
  125. package/dist/src/ui/import/review.js +98 -0
  126. package/dist/src/ui/import/review.js.map +1 -0
  127. package/dist/src/ui/import/skill-select.d.ts +15 -0
  128. package/dist/src/ui/import/skill-select.js +219 -0
  129. package/dist/src/ui/import/skill-select.js.map +1 -0
  130. package/dist/src/ui/import/types.d.ts +13 -0
  131. package/dist/src/ui/import/types.js +2 -0
  132. package/dist/src/ui/import/types.js.map +1 -0
  133. package/dist/src/ui/install/index.d.ts +6 -0
  134. package/dist/src/ui/install/index.js +6 -0
  135. package/dist/src/ui/install/index.js.map +1 -0
  136. package/dist/src/ui/install/review.d.ts +10 -0
  137. package/dist/src/ui/install/review.js +134 -0
  138. package/dist/src/ui/install/review.js.map +1 -0
  139. package/dist/src/ui/install/types.d.ts +15 -0
  140. package/dist/src/ui/install/types.js +6 -0
  141. package/dist/src/ui/install/types.js.map +1 -0
  142. package/dist/src/ui/overlay/bridge.d.ts +29 -0
  143. package/dist/src/ui/overlay/bridge.js +34 -0
  144. package/dist/src/ui/overlay/bridge.js.map +1 -0
  145. package/dist/src/ui/overlay/dialogs.d.ts +6 -0
  146. package/dist/src/ui/overlay/dialogs.js +31 -0
  147. package/dist/src/ui/overlay/dialogs.js.map +1 -0
  148. package/dist/src/ui/overlay/host.d.ts +30 -0
  149. package/dist/src/ui/overlay/host.js +164 -0
  150. package/dist/src/ui/overlay/host.js.map +1 -0
  151. package/dist/src/ui/overlay/index.d.ts +11 -0
  152. package/dist/src/ui/overlay/index.js +11 -0
  153. package/dist/src/ui/overlay/index.js.map +1 -0
  154. package/dist/src/ui/overlay/slot.d.ts +20 -0
  155. package/dist/src/ui/overlay/slot.js +50 -0
  156. package/dist/src/ui/overlay/slot.js.map +1 -0
  157. package/dist/src/ui/overlay/static.d.ts +13 -0
  158. package/dist/src/ui/overlay/static.js +34 -0
  159. package/dist/src/ui/overlay/static.js.map +1 -0
  160. package/dist/src/ui/overlay/types.d.ts +57 -0
  161. package/dist/src/ui/overlay/types.js +2 -0
  162. package/dist/src/ui/overlay/types.js.map +1 -0
  163. package/dist/src/ui/prompts/index.d.ts +5 -0
  164. package/dist/src/ui/prompts/index.js +6 -0
  165. package/dist/src/ui/prompts/index.js.map +1 -0
  166. package/dist/src/ui/prompts/present.d.ts +29 -0
  167. package/dist/src/ui/prompts/present.js +71 -0
  168. package/dist/src/ui/prompts/present.js.map +1 -0
  169. package/dist/src/ui/search/index.d.ts +4 -0
  170. package/dist/src/ui/{search.js → search/index.js} +20 -8
  171. package/dist/src/ui/search/index.js.map +1 -0
  172. package/dist/src/ui/search/types.d.ts +9 -0
  173. package/dist/src/ui/search/types.js +2 -0
  174. package/dist/src/ui/search/types.js.map +1 -0
  175. package/dist/src/ui/shell/app-shell.d.ts +22 -0
  176. package/dist/src/ui/shell/app-shell.js +46 -0
  177. package/dist/src/ui/shell/app-shell.js.map +1 -0
  178. package/dist/src/ui/shell/footer.d.ts +7 -0
  179. package/dist/src/ui/shell/footer.js +38 -0
  180. package/dist/src/ui/shell/footer.js.map +1 -0
  181. package/dist/src/ui/shell/run.d.ts +41 -0
  182. package/dist/src/ui/shell/run.js +201 -0
  183. package/dist/src/ui/shell/run.js.map +1 -0
  184. package/dist/src/{contracts → ui/shell}/terminal.d.ts +1 -0
  185. package/dist/src/{contracts → ui/shell}/terminal.js +1 -0
  186. package/dist/src/ui/shell/terminal.js.map +1 -0
  187. package/dist/src/ui/skill-labels.d.ts +10 -0
  188. package/dist/src/ui/skill-labels.js +11 -0
  189. package/dist/src/ui/skill-labels.js.map +1 -0
  190. package/package.json +20 -17
  191. package/dist/src/commands/browser.d.ts +0 -3
  192. package/dist/src/commands/browser.js +0 -413
  193. package/dist/src/commands/browser.js.map +0 -1
  194. package/dist/src/contracts/browser.d.ts +0 -68
  195. package/dist/src/contracts/browser.js +0 -2
  196. package/dist/src/contracts/browser.js.map +0 -1
  197. package/dist/src/contracts/search.d.ts +0 -7
  198. package/dist/src/contracts/search.js +0 -2
  199. package/dist/src/contracts/search.js.map +0 -1
  200. package/dist/src/contracts/terminal.js.map +0 -1
  201. package/dist/src/ui/browser-state.d.ts +0 -11
  202. package/dist/src/ui/browser-state.js +0 -17
  203. package/dist/src/ui/browser-state.js.map +0 -1
  204. package/dist/src/ui/browser.d.ts +0 -32
  205. package/dist/src/ui/browser.js +0 -786
  206. package/dist/src/ui/browser.js.map +0 -1
  207. package/dist/src/ui/prompts.d.ts +0 -20
  208. package/dist/src/ui/prompts.js +0 -49
  209. package/dist/src/ui/prompts.js.map +0 -1
  210. package/dist/src/ui/reviews.d.ts +0 -47
  211. package/dist/src/ui/reviews.js +0 -390
  212. package/dist/src/ui/reviews.js.map +0 -1
  213. package/dist/src/ui/search.d.ts +0 -5
  214. package/dist/src/ui/search.js.map +0 -1
  215. package/dist/src/ui/session.d.ts +0 -11
  216. package/dist/src/ui/session.js +0 -104
  217. package/dist/src/ui/session.js.map +0 -1
  218. package/dist/src/ui/termcn.d.ts +0 -58
  219. package/dist/src/ui/termcn.js +0 -303
  220. package/dist/src/ui/termcn.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ import type { BrowserResult, BrowserViewInput } from './types.js';
2
+ interface BrowserProps extends BrowserViewInput {
3
+ finish: (result: BrowserResult) => void;
4
+ }
5
+ /**
6
+ * Browser list view. Navigation/selection live in the parent Jotai Provider
7
+ * (BrowserApp store). Does not create a nested store.
8
+ * Overlays (? / more-actions) go through {@link useModal}.
9
+ */
10
+ export declare function Browser({ projectGroups, collection, globalGroups, canSync, checkUpdates, updatingSkillName, finish, }: BrowserProps): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,657 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text, useStdout } from 'ink';
3
+ import { useInput } from '../components/use-input.js';
4
+ import { useAtom, useAtomValue, useStore } from 'jotai';
5
+ import { useEffect, useMemo, useRef, useState } from 'react';
6
+ import { browserFilterAtom, browserGroupJumpAtom, browserNavigationAtom, browserSelectionAtom, browserUpdateCheckAtom, } from './store.js';
7
+ import { browserFrameDimensions, masterDetailLayout, masterDetailSeparator, masterDetailViewportHeight, masterDetailWidths, } from './layout.js';
8
+ import { TAG_FILTER_ALL, browseDetailRows, collectionCategoryLines, collectionListColumnLines, flatRows, focusAfterDownFromAgents, focusAfterDownFromTabs, focusAfterUpFromList, focusAfterUpFromTags, groupedRows, listSkillSummary, moreActionModalContent, nextAgent, nextMainTab, selectableSkills, skillsForTagFilter, tagFilterOptions, visibleAgentGroups, } from './format.js';
9
+ import { useModal, useOverlayBusy } from '../overlay/host.js';
10
+ import { FramedPanel } from '../components/framed-panel.js';
11
+ import { Select, Tabs, termcnColors, } from '../components/termcn.js';
12
+ import { padColumns, sliceColumns } from '../components/terminal-layout.js';
13
+ import { ShortcutHelpPanel } from './shortcut-help.js';
14
+ /** Framed more-actions panel for absolute modal overlay (list shows through). */
15
+ function MoreActionsPanel({ scope, onConfirm, onCancel, }) {
16
+ return (_jsx(FramedPanel, { title: " \u66F4\u591A\u64CD\u4F5C ", content: [...moreActionModalContent(scope), 'Enter 执行 · Esc 返回'], width: 64, muteLastContent: true, onEscape: onCancel, onKey: (input, key) => {
17
+ if (key.return || input.includes('\r') || input.includes('\n'))
18
+ onConfirm();
19
+ } }));
20
+ }
21
+ function masterDetailBlankRow(tagWidth, listWidth, peekWidth) {
22
+ const divider = '│';
23
+ 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, { width: peekWidth, children: _jsx(Text, { wrap: "truncate-end", children: padColumns('', peekWidth) }) })] }));
24
+ }
25
+ 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, }) {
26
+ const { stdout } = useStdout();
27
+ const selected = useAtomValue(browserSelectionAtom);
28
+ const paneHeight = viewportHeight ?? Math.max(3, (stdout.rows ?? 24) - 8);
29
+ const height = rows.length > paneHeight ? Math.max(3, paneHeight - (showPagination ? 1 : 0)) : paneHeight;
30
+ const active = Math.max(0, Math.min(cursor, rows.length - 1));
31
+ const offset = Math.max(0, Math.min(active - Math.floor(height / 2), rows.length - height));
32
+ const visible = rows.slice(offset, offset + height);
33
+ const paneWidth = columnWidth ?? Math.max(20, (stdout.columns ?? 80) - 4);
34
+ const summaryWidth = Math.max(8, paneWidth - 4);
35
+ const renderRow = (row, index) => {
36
+ if (row.type === 'group') {
37
+ const groupSkills = row.skills;
38
+ const count = groupSkills.filter((skill) => selected.has(skill.path)).length;
39
+ const marker = count === 0 ? '○' : count === groupSkills.length && groupSkills.length ? '●' : '◐';
40
+ return (_jsx(Text, { bold: true, ...(isActive && index === active ? { color: termcnColors.primary } : {}), children: `${isActive && index === active ? '›' : ' '} ${marker} ${row.name} (${row.skills.length})` }, `group:${row.name}:${index}`));
41
+ }
42
+ const skill = row.skill;
43
+ const current = isActive && index === active;
44
+ const summary = compact || layout === 'master'
45
+ ? ''
46
+ : listSkillSummary(skill, preferNote, summaryWidth);
47
+ const inlineSummary = summary;
48
+ const selectionMarker = selected.has(skill.path) ? '●' : '○';
49
+ 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: "\u5F15\u7528 \u00B7 " }), _jsx(Text, { bold: current, children: skill.name })] })) : showSource && !skill.fromCollection ? (`本地 · ${skill.name}`) : (_jsx(Text, { bold: current, children: skill.name })), updatingSkillName === skill.name ? (_jsx(Text, { color: termcnColors.primary, children: " \u66F4\u65B0\u4E2D" })) : updates.has(skill.name) ? (_jsx(Text, { color: termcnColors.primary, children: " \u2191" })) : null, inlineSummary && (_jsxs(Text, { color: termcnColors.muted, children: [" \u2014 ", inlineSummary] }))] }));
50
+ return (_jsx(Text, { wrap: "truncate-end", ...(current ? { color: termcnColors.primary } : {}), children: nameLine }, `${row.group}:${skill.path}:${index}`));
51
+ };
52
+ return (_jsxs(Box, { flexDirection: "column", minHeight: 3, children: [rows.length ? (visible.map((row, visibleIndex) => renderRow(row, offset + visibleIndex))) : (_jsx(Text, { color: termcnColors.muted, children: "\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD" })), showPagination && rows.length > height && (_jsxs(Text, { color: termcnColors.muted, children: [offset + 1, "\u2013", Math.min(offset + height, rows.length), " / ", rows.length] }))] }));
53
+ }
54
+ function AgentTabs({ groups, agent, focused, }) {
55
+ return (_jsx(Box, { paddingLeft: 1, gap: 2, children: groups.map((group) => {
56
+ const active = group.agent === agent;
57
+ // Keyboard focus only: never use foreground/white for "current agent".
58
+ // Unfocused row stays fully muted so switching main tabs does not look
59
+ // like the agent row is already selected.
60
+ const highlighted = focused && active;
61
+ return (_jsx(Text, { color: highlighted ? termcnColors.primary : termcnColors.muted, underline: highlighted, children: `${group.agent} ${group.skills.length}` }, group.agent));
62
+ }) }));
63
+ }
64
+ function masterDetailColumnText(line, width, options = {}) {
65
+ const padded = padColumns(sliceColumns(line, 0, width), width);
66
+ return (_jsx(Text, { wrap: "truncate-end", ...(options.color ? { color: options.color } : {}), ...(options.bold ? { bold: true } : {}), ...(options.inverse ? { inverse: true } : {}), ...(options.muted ? { color: termcnColors.muted } : {}), children: padded }));
67
+ }
68
+ function MasterDetailBody({ tagLines, listLines, peekLines, tagWidth, listWidth, peekWidth, tagActive, listActive, collectionHome = false, listActiveLineIndexes, listSelectedLineIndexes, detailRows, }) {
69
+ const rows = Math.max(tagLines.length, listLines.length, peekLines.length);
70
+ const divided = collectionHome;
71
+ const divider = divided ? '│' : '';
72
+ const tagColumnWidth = tagWidth + (divider ? 1 : 0);
73
+ const listColumnWidth = listWidth + (divider ? 1 : 0);
74
+ return (_jsx(_Fragment, { children: Array.from({ length: rows }, (_, index) => (_jsxs(Box, { flexDirection: "row", children: [_jsxs(Box, { width: tagColumnWidth, flexDirection: "row", children: [masterDetailColumnText(tagLines[index] ?? '', tagWidth, {
75
+ ...(tagActive && tagLines[index]?.startsWith('›')
76
+ ? collectionHome
77
+ ? { inverse: true }
78
+ : { color: termcnColors.primary }
79
+ : {}),
80
+ }), divider ? _jsx(Text, { color: termcnColors.border, children: divider }) : null] }), _jsxs(Box, { width: listColumnWidth, flexDirection: "row", children: [masterDetailColumnText(listLines[index] ?? '', listWidth, {
81
+ ...(listActiveLineIndexes?.has(index)
82
+ ? { inverse: true }
83
+ : listSelectedLineIndexes?.has(index)
84
+ ? { color: termcnColors.primary, bold: true }
85
+ : listActive && listLines[index]?.startsWith('›')
86
+ ? { color: termcnColors.primary, bold: true }
87
+ : index % 2 === 1 && listLines[index]?.trim()
88
+ ? { muted: true }
89
+ : {}),
90
+ }), divider ? _jsx(Text, { color: termcnColors.border, children: divider }) : null] }), _jsx(Box, { width: peekWidth, children: detailRows?.[index] ? (_jsx(Text, { wrap: "truncate-end", ...(detailRows[index]?.primary ? { color: termcnColors.primary } : {}), ...(detailRows[index]?.muted ? { color: termcnColors.muted } : {}), ...(detailRows[index]?.bold ? { bold: true } : {}), children: padColumns(sliceColumns(detailRows[index]?.text ?? '', 0, peekWidth), peekWidth) })) : (_jsx(Text, { wrap: "truncate-end", color: index === 0 && peekLines[index] !== '选择技能查看' ? termcnColors.primary : termcnColors.muted, bold: index === 0 && peekLines[index] !== '选择技能查看', children: padColumns(sliceColumns(peekLines[index] ?? '', 0, peekWidth), peekWidth) })) })] }, `master-detail-row:${index}`))) }));
91
+ }
92
+ /**
93
+ * Browser list view. Navigation/selection live in the parent Jotai Provider
94
+ * (BrowserApp store). Does not create a nested store.
95
+ * Overlays (? / more-actions) go through {@link useModal}.
96
+ */
97
+ export function Browser({ projectGroups, collection, globalGroups, canSync, checkUpdates, updatingSkillName, finish, }) {
98
+ const modal = useModal();
99
+ const shellBusy = useOverlayBusy();
100
+ const store = useStore();
101
+ const [navigation, setNavigationState] = useAtom(browserNavigationAtom);
102
+ const [selected, setSelected] = useAtom(browserSelectionAtom);
103
+ const navigationRef = useRef(navigation);
104
+ navigationRef.current = navigation;
105
+ /** Keep ref in lockstep so multi-key stdin never reads a stale focus/tab. */
106
+ const setNavigation = (value) => {
107
+ setNavigationState((current) => {
108
+ const next = typeof value === 'function' ? value(current) : value;
109
+ navigationRef.current = next;
110
+ return next;
111
+ });
112
+ };
113
+ const tab = navigation?.tab ?? 'project';
114
+ const query = navigation?.query ?? '';
115
+ const cursor = navigation?.cursor ?? 0;
116
+ const agent = navigation?.agent ?? '';
117
+ const focus = navigation?.focus ?? 'tabs';
118
+ const visibleProjectGroups = useMemo(() => visibleAgentGroups(projectGroups), [projectGroups]);
119
+ const visibleGlobalGroups = useMemo(() => visibleAgentGroups(globalGroups), [globalGroups]);
120
+ const activeProjectAgent = visibleProjectGroups.some((group) => group.agent === agent)
121
+ ? agent
122
+ : visibleProjectGroups[0]?.agent ?? '';
123
+ const activeGlobalAgent = visibleGlobalGroups.some((group) => group.agent === agent)
124
+ ? agent
125
+ : visibleGlobalGroups[0]?.agent ?? '';
126
+ const activeAgent = tab === 'global' ? activeGlobalAgent : activeProjectAgent;
127
+ const currentAgentGroups = tab === 'project' ? visibleProjectGroups : tab === 'global' ? visibleGlobalGroups : [];
128
+ const hasAgentTabs = currentAgentGroups.length > 0;
129
+ const project = projectGroups.flatMap((group) => group.skills);
130
+ const projectGroup = visibleProjectGroups.find((group) => group.agent === activeProjectAgent) ??
131
+ visibleProjectGroups[0];
132
+ const projectRows = useMemo(() => groupedRows(projectGroup?.skills ?? [], query), [projectGroup, query]);
133
+ const collectionRows = useMemo(() => groupedRows(collection, query), [collection, query]);
134
+ const globalGroup = visibleGlobalGroups.find((group) => group.agent === activeGlobalAgent) ??
135
+ visibleGlobalGroups[0];
136
+ const globalRows = useMemo(() => flatRows(globalGroup?.skills ?? [], query), [globalGroup, query]);
137
+ const rows = tab === 'project' ? projectRows : tab === 'global' ? globalRows : collectionRows;
138
+ const cursorRef = useRef(cursor);
139
+ cursorRef.current = cursor;
140
+ const setTab = (value) => {
141
+ setNavigation((current) => (current ? { ...current, tab: value } : current));
142
+ };
143
+ const setQuery = (value) => {
144
+ setNavigation((current) => (current ? { ...current, query: value } : current));
145
+ };
146
+ const setAgent = (value) => {
147
+ setNavigation((current) => (current ? { ...current, agent: value } : current));
148
+ };
149
+ const setFocus = (value) => {
150
+ setNavigation((current) => (current ? { ...current, focus: value } : current));
151
+ };
152
+ const setCursor = (value) => {
153
+ setNavigation((current) => {
154
+ if (!current)
155
+ return current;
156
+ const nextCursor = typeof value === 'function' ? value(current.cursor) : value;
157
+ cursorRef.current = nextCursor;
158
+ return { ...current, cursor: nextCursor };
159
+ });
160
+ };
161
+ const [filter, setFilter] = useAtom(browserFilterAtom);
162
+ const [choosingGroup, setChoosingGroup] = useAtom(browserGroupJumpAtom);
163
+ const [updateCheck, setUpdateCheck] = useAtom(browserUpdateCheckAtom);
164
+ const searching = filter.open;
165
+ const selectedCollection = collection.filter((skill) => selected.has(skill.path));
166
+ const selectedUpdates = selectedCollection.filter((skill) => updateCheck.updates.has(skill.name));
167
+ const selectedProject = project.filter((skill) => selected.has(skill.path));
168
+ const selectedGlobal = globalGroups.flatMap((group) => group.skills.filter((skill) => selected.has(skill.path)));
169
+ const selectedProjectLocal = project.filter((skill) => selected.has(skill.path) && !skill.fromCollection);
170
+ const selectedGlobalLocal = globalGroups.flatMap((group) => group.skills.filter((skill) => selected.has(skill.path) && !skill.fromCollection));
171
+ const { stdout } = useStdout();
172
+ const useBrowseHome = masterDetailLayout(stdout.columns, stdout.rows) &&
173
+ !query.trim();
174
+ const useMasterDetail = useBrowseHome;
175
+ // Scope for list + tag sidebar + g-jump: current agent (or full collection),
176
+ // never the whole project/global flat list.
177
+ const tabSkills = tab === 'collection'
178
+ ? collection
179
+ : tab === 'project'
180
+ ? projectGroup?.skills ?? []
181
+ : tab === 'global'
182
+ ? globalGroup?.skills ?? []
183
+ : [];
184
+ const groupRows = useMemo(() => groupedRows(tabSkills, ''), [tabSkills]);
185
+ const groups = groupRows.filter((row) => row.type === 'group');
186
+ const tagOptions = useMemo(() => tagFilterOptions(tabSkills, groups), [groups, tabSkills]);
187
+ const [tagFilter, setTagFilter] = useState(TAG_FILTER_ALL);
188
+ const [tagCursor, setTagCursor] = useState(0);
189
+ const tagCursorRef = useRef(tagCursor);
190
+ tagCursorRef.current = tagCursor;
191
+ const masterDetailSkills = useMemo(() => skillsForTagFilter(tabSkills, tagFilter), [tabSkills, tagFilter]);
192
+ const masterDetailRows = useMemo(() => flatRows(masterDetailSkills, query), [masterDetailSkills, query]);
193
+ const listRows = useMasterDetail ? masterDetailRows : rows;
194
+ const currentRow = listRows[cursor];
195
+ const actionSkills = tab === 'project'
196
+ ? selectedProject.length
197
+ ? selectedProject
198
+ : currentRow?.type === 'skill'
199
+ ? [currentRow.skill]
200
+ : []
201
+ : [];
202
+ const canOpenActions = !updatingSkillName &&
203
+ focus === 'list' &&
204
+ actionSkills.length > 0 &&
205
+ actionSkills.every((skill) => skill.isReference);
206
+ const previousTab = useRef(tab);
207
+ useEffect(() => {
208
+ if (previousTab.current !== tab) {
209
+ setCursor(0);
210
+ setSelected(new Set());
211
+ setTagFilter(TAG_FILTER_ALL);
212
+ setTagCursor(0);
213
+ previousTab.current = tab;
214
+ }
215
+ }, [tab]);
216
+ const previousAgent = useRef(agent);
217
+ useEffect(() => {
218
+ if (previousAgent.current !== agent) {
219
+ setCursor(0);
220
+ setTagFilter(TAG_FILTER_ALL);
221
+ setTagCursor(0);
222
+ previousAgent.current = agent;
223
+ }
224
+ }, [agent]);
225
+ useEffect(() => {
226
+ if (focus === 'agents' && !hasAgentTabs)
227
+ setFocus(useMasterDetail ? 'tags' : 'list');
228
+ }, [focus, hasAgentTabs, useMasterDetail]);
229
+ useEffect(() => {
230
+ if (tab !== 'collection')
231
+ return;
232
+ let active = true;
233
+ setUpdateCheck((current) => ({
234
+ ...current,
235
+ checking: true,
236
+ }));
237
+ void checkUpdates(collection)
238
+ .then(({ updates, failed }) => {
239
+ if (active)
240
+ setUpdateCheck({ checking: false, updates, failed });
241
+ })
242
+ .catch(() => {
243
+ if (active) {
244
+ setUpdateCheck({
245
+ checking: false,
246
+ updates: new Set(),
247
+ failed: collection.length,
248
+ });
249
+ }
250
+ });
251
+ return () => {
252
+ active = false;
253
+ };
254
+ }, [checkUpdates, collection, tab, setUpdateCheck]);
255
+ const frame = browserFrameDimensions({
256
+ rows: stdout.rows,
257
+ columns: stdout.columns,
258
+ projectRows: projectRows.length,
259
+ globalRows: globalRows.length,
260
+ collectionRows: collectionRows.length,
261
+ hasProjectAgents: visibleProjectGroups.length > 0,
262
+ hasGlobalAgents: visibleGlobalGroups.length > 0,
263
+ });
264
+ const openDetail = (skill, collection) => finish({
265
+ type: 'open',
266
+ skill,
267
+ collection,
268
+ frameHeight: frame.frameHeight,
269
+ frameWidth: frame.frameWidth,
270
+ });
271
+ const agentPaneViewportHeight = Math.max(3, frame.frameHeight - 3);
272
+ const collectionPaneViewportHeight = Math.max(3, frame.frameHeight - 2);
273
+ const masterDetailInnerWidth = Math.max(40, frame.frameWidth - 2);
274
+ const masterDetailColumns = masterDetailWidths(masterDetailInnerWidth, useBrowseHome);
275
+ const masterDetailBrowseHeight = (withAgents) => masterDetailViewportHeight(stdout.rows, 1 + 2 + 3 + (withAgents ? 1 : 0));
276
+ const browseViewportHeight = (withAgents) => useMasterDetail
277
+ ? masterDetailBrowseHeight(withAgents)
278
+ : withAgents
279
+ ? agentPaneViewportHeight
280
+ : collectionPaneViewportHeight;
281
+ const masterListVisibleHeight = Math.max(1, Math.floor(masterDetailBrowseHeight(false) / 2));
282
+ const masterListOffset = useMasterDetail
283
+ ? Math.max(0, Math.min(cursor - Math.floor(masterListVisibleHeight / 2), Math.max(0, listRows.length - masterListVisibleHeight)))
284
+ : 0;
285
+ const peekSkill = focus === 'list' && currentRow?.type === 'skill' ? currentRow.skill : undefined;
286
+ useEffect(() => {
287
+ if (focus === 'tags' && !useMasterDetail)
288
+ setFocus('list');
289
+ }, [focus, useMasterDetail, setFocus]);
290
+ useInput((input, key) => {
291
+ const live = navigationRef.current;
292
+ const liveFocus = live?.focus ?? 'tabs';
293
+ const liveTab = live?.tab ?? 'project';
294
+ if (input === '?') {
295
+ void modal.open({
296
+ footerItems: [
297
+ { key: '↑↓', label: '移动' },
298
+ { key: 'e', label: '展开' },
299
+ { key: 'Esc', label: '关闭' },
300
+ ],
301
+ content: (close) => (_jsx(ShortcutHelpPanel, { onClose: () => close(undefined), maxBodyRows: 14 })),
302
+ });
303
+ return;
304
+ }
305
+ if (key.escape || input === 'q')
306
+ return finish({ type: 'quit' });
307
+ if (input === '/') {
308
+ setFilter({
309
+ open: true,
310
+ draft: query,
311
+ queryBefore: query,
312
+ cursorBefore: cursorRef.current,
313
+ });
314
+ return;
315
+ }
316
+ if (input === 'g' && groups.length) {
317
+ return setChoosingGroup(true);
318
+ }
319
+ if (input === 's' && liveTab === 'collection' && canSync) {
320
+ return finish({ type: 'sync' });
321
+ }
322
+ // Focus ladder + tab/agent switching: always branch on the live ref so
323
+ // multi-key stdin batches each advance from the latest navigation.
324
+ if (key.downArrow || key.upArrow || key.leftArrow || key.rightArrow) {
325
+ if (liveFocus === 'tabs' || liveFocus === 'agents' || liveFocus === 'tags') {
326
+ const direction = key.leftArrow ? -1 : key.rightArrow ? 1 : 0;
327
+ setNavigation((current) => {
328
+ if (!current)
329
+ return current;
330
+ const groups = current.tab === 'project'
331
+ ? visibleProjectGroups
332
+ : current.tab === 'global'
333
+ ? visibleGlobalGroups
334
+ : [];
335
+ const hasAgents = groups.length > 0;
336
+ const names = groups.map((group) => group.agent);
337
+ if (current.focus === 'tabs') {
338
+ if (key.downArrow) {
339
+ return {
340
+ ...current,
341
+ focus: focusAfterDownFromTabs(hasAgents, useMasterDetail),
342
+ };
343
+ }
344
+ if (key.leftArrow || key.rightArrow) {
345
+ const next = nextMainTab(current.tab, direction);
346
+ return next ? { ...current, tab: next } : current;
347
+ }
348
+ return current;
349
+ }
350
+ if (current.focus === 'agents') {
351
+ if (key.upArrow)
352
+ return { ...current, focus: 'tabs' };
353
+ if (key.downArrow) {
354
+ return {
355
+ ...current,
356
+ focus: focusAfterDownFromAgents(useMasterDetail),
357
+ };
358
+ }
359
+ if (key.leftArrow || key.rightArrow) {
360
+ const next = nextAgent(names, current.agent || names[0] || '', direction);
361
+ return next ? { ...current, agent: next } : current;
362
+ }
363
+ return current;
364
+ }
365
+ if (current.focus === 'tags') {
366
+ // ↑/↓ move among tag rows (handled below). Only ←/→ change the focus ladder here.
367
+ if (key.leftArrow)
368
+ return { ...current, focus: focusAfterUpFromTags(hasAgents) };
369
+ if (key.rightArrow)
370
+ return { ...current, focus: 'list' };
371
+ return current;
372
+ }
373
+ return current;
374
+ });
375
+ // Tag index moves stay on the tags-local path below when still on tags.
376
+ if (liveFocus !== 'tags' || key.leftArrow || key.rightArrow)
377
+ return;
378
+ }
379
+ }
380
+ if (liveFocus === 'tabs' || liveFocus === 'agents') {
381
+ return;
382
+ }
383
+ if (liveFocus === 'tags' || focus === 'tags') {
384
+ const selectTag = (index) => {
385
+ const option = tagOptions[index];
386
+ if (!option)
387
+ return;
388
+ setTagFilter(option.key);
389
+ tagCursorRef.current = index;
390
+ setTagCursor(index);
391
+ setCursor(0);
392
+ };
393
+ const liveTagCursor = tagCursorRef.current;
394
+ if (key.upArrow) {
395
+ if (liveTagCursor === 0)
396
+ return setFocus(focusAfterUpFromTags(hasAgentTabs));
397
+ selectTag(liveTagCursor - 1);
398
+ return;
399
+ }
400
+ if (key.downArrow) {
401
+ if (liveTagCursor >= tagOptions.length - 1)
402
+ return setFocus('list');
403
+ selectTag(liveTagCursor + 1);
404
+ return;
405
+ }
406
+ if (key.leftArrow)
407
+ return setFocus(focusAfterUpFromTags(hasAgentTabs));
408
+ if (key.rightArrow) {
409
+ selectTag(liveTagCursor);
410
+ return setFocus('list');
411
+ }
412
+ const tagOption = tagOptions[liveTagCursor];
413
+ if (input === ' ' && tagOption) {
414
+ const paths = tagOption.skills.map((skill) => skill.path);
415
+ return setSelected((previous) => {
416
+ const next = new Set(previous);
417
+ const allSelected = paths.every((path) => previous.has(path));
418
+ for (const path of paths)
419
+ allSelected ? next.delete(path) : next.add(path);
420
+ return next;
421
+ });
422
+ }
423
+ if (key.return || input.includes('\r') || input.includes('\n')) {
424
+ selectTag(liveTagCursor);
425
+ return setFocus('list');
426
+ }
427
+ return;
428
+ }
429
+ if ((navigationRef.current?.focus ?? focus) !== 'list')
430
+ return;
431
+ const row = listRows[cursorRef.current];
432
+ if (input === 'm' && canOpenActions) {
433
+ const skills = actionSkills;
434
+ const scope = selectedProject.length
435
+ ? `已选择 ${skills.length} 个技能`
436
+ : `技能:${skills[0]?.name ?? ''}`;
437
+ void modal
438
+ .open({
439
+ footerItems: [
440
+ { key: 'Enter', label: '确认' },
441
+ { key: 'Esc', label: '取消' },
442
+ ],
443
+ content: (close) => (_jsx(MoreActionsPanel, { scope: scope, onConfirm: () => close(true), onCancel: () => close(false) })),
444
+ })
445
+ .then((confirmed) => {
446
+ if (confirmed)
447
+ finish({ type: 'materialize', skills });
448
+ });
449
+ return;
450
+ }
451
+ if (input === 'u' && (navigationRef.current?.tab ?? tab) === 'collection') {
452
+ const updateable = selectedCollection.length
453
+ ? selectedUpdates
454
+ : row?.type === 'skill' && updateCheck.updates.has(row.skill.name)
455
+ ? [row.skill]
456
+ : [];
457
+ if (updateable.length) {
458
+ return finish({ type: 'update', skills: updateable });
459
+ }
460
+ }
461
+ if (input === 't' && tab === 'collection' && selectedCollection.length) {
462
+ return finish({ type: 'tags', skills: selectedCollection });
463
+ }
464
+ const removableCollection = tab === 'collection'
465
+ ? selectedCollection.length
466
+ ? selectedCollection
467
+ : row?.type === 'skill'
468
+ ? [row.skill]
469
+ : []
470
+ : [];
471
+ const removableLocations = tab === 'project'
472
+ ? selectedProject.length
473
+ ? selectedProject
474
+ : row?.type === 'skill'
475
+ ? [row.skill]
476
+ : []
477
+ : tab === 'global'
478
+ ? selectedGlobal.length
479
+ ? selectedGlobal
480
+ : row?.type === 'skill'
481
+ ? [row.skill]
482
+ : []
483
+ : [];
484
+ if ((input === 'd' || key.delete) && removableCollection.length) {
485
+ const skills = removableCollection;
486
+ void modal
487
+ .confirm({
488
+ title: '删除收藏',
489
+ message: skills.length === 1
490
+ ? `从收藏夹移除 ${skills[0]?.name ?? ''} 吗?`
491
+ : `从收藏夹移除 ${skills.length} 个技能吗?`,
492
+ ...(skills.length > 1
493
+ ? { details: [`技能:${skills.map((skill) => skill.name).join(', ')}`] }
494
+ : {}),
495
+ })
496
+ .then((ok) => {
497
+ if (ok)
498
+ finish({ type: 'removeCollection', skills });
499
+ });
500
+ return;
501
+ }
502
+ if ((input === 'd' || key.delete) && removableLocations.length) {
503
+ const skills = removableLocations;
504
+ void modal
505
+ .confirm({
506
+ title: '删除技能',
507
+ message: skills.length === 1
508
+ ? `删除 ${skills[0]?.name ?? ''} 的当前位置吗?`
509
+ : `删除所选 ${skills.length} 个技能位置吗?`,
510
+ details: [
511
+ '将永久删除以下位置;收藏夹内容(如有)保留。',
512
+ ...skills.map((skill) => skill.path),
513
+ ],
514
+ })
515
+ .then((ok) => {
516
+ if (ok)
517
+ finish({ type: 'removeLocations', skills });
518
+ });
519
+ return;
520
+ }
521
+ const selectedLocal = tab === 'project' ? selectedProjectLocal : selectedGlobalLocal;
522
+ if (input === 'i' && tab !== 'collection' && selectedLocal.length) {
523
+ return finish({ type: 'import', skills: selectedLocal });
524
+ }
525
+ if (key.leftArrow && useMasterDetail)
526
+ return setFocus('tags');
527
+ if (key.upArrow) {
528
+ if (cursorRef.current === 0) {
529
+ return setFocus(focusAfterUpFromList(useMasterDetail, hasAgentTabs));
530
+ }
531
+ return setCursor((index) => index - 1);
532
+ }
533
+ if (key.downArrow) {
534
+ return setCursor((index) => Math.min(Math.max(0, listRows.length - 1), index + 1));
535
+ }
536
+ if (input === ' ' && row) {
537
+ const paths = selectableSkills(row).map((skill) => skill.path);
538
+ if (!paths.length)
539
+ return;
540
+ return setSelected((previous) => {
541
+ const next = new Set(previous);
542
+ const allSelected = paths.every((path) => previous.has(path));
543
+ for (const path of paths)
544
+ allSelected ? next.delete(path) : next.add(path);
545
+ return next;
546
+ });
547
+ }
548
+ if (key.rightArrow && row?.type === 'skill' && !useBrowseHome) {
549
+ if (tab === 'collection')
550
+ return openDetail(row.skill, true);
551
+ if (row.skill.fromCollection)
552
+ return openDetail(row.skill, true);
553
+ }
554
+ if (key.return || input.includes('\r') || input.includes('\n')) {
555
+ if (tab === 'collection' && selectedCollection.length) {
556
+ return finish({ type: 'add', skills: selectedCollection });
557
+ }
558
+ if (tab === 'collection' && row?.type === 'skill') {
559
+ return openDetail(row.skill, true);
560
+ }
561
+ if (tab !== 'collection') {
562
+ if (row?.type === 'skill')
563
+ openDetail(row.skill, false);
564
+ }
565
+ }
566
+ }, {
567
+ isActive: !shellBusy && !searching && !choosingGroup && !updatingSkillName,
568
+ });
569
+ useInput((input, key) => {
570
+ if (key.escape || input === 'q') {
571
+ setChoosingGroup(false);
572
+ }
573
+ }, { isActive: !shellBusy && choosingGroup });
574
+ // Backup filter cancel: TextInput also handles Esc; this covers focus edge cases.
575
+ useInput((_input, key) => {
576
+ if (!key.escape)
577
+ return;
578
+ const prior = store.get(browserFilterAtom);
579
+ setFilter({
580
+ open: false,
581
+ draft: '',
582
+ queryBefore: '',
583
+ cursorBefore: 0,
584
+ });
585
+ setNavigation((current) => current
586
+ ? {
587
+ ...current,
588
+ query: prior.queryBefore,
589
+ cursor: prior.cursorBefore,
590
+ }
591
+ : current);
592
+ }, { isActive: !shellBusy && searching });
593
+ const renderBrowsePane = (paneRows, viewportHeight, options = {}) => {
594
+ if (useBrowseHome) {
595
+ const { tagWidth, listWidth, peekWidth } = masterDetailColumns;
596
+ const selectedPaths = selected;
597
+ const tagLines = collectionCategoryLines(tagOptions, tagCursor, focus === 'tags', tagWidth, viewportHeight);
598
+ const { lines: listLines, activeLineIndexes: listActiveLineIndexes, selectedLineIndexes: listSelectedLineIndexes, } = collectionListColumnLines(paneRows, cursor, focus === 'list', options.preferNote ?? false, listWidth, viewportHeight, selectedPaths, options.updates ?? new Set(), options.updatingSkillName);
599
+ const detailRows = browseDetailRows(peekSkill, peekWidth, viewportHeight, options.collection ?? false, options.updates ?? new Set(), options.updatingSkillName);
600
+ 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, { width: peekWidth, children: _jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(right, peekWidth) }) })] }));
601
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: termcnColors.border, wrap: "truncate-end", children: masterDetailSeparator(tagWidth, listWidth, peekWidth, 'top', true) }), headerLine('标签', '技能', '详情'), masterDetailBlankRow(tagWidth, listWidth, peekWidth), _jsx(MasterDetailBody, { tagLines: tagLines, listLines: listLines, peekLines: [], tagWidth: tagWidth, listWidth: listWidth, peekWidth: peekWidth, tagActive: focus === 'tags', listActive: focus === 'list', collectionHome: true, ...(listActiveLineIndexes ? { listActiveLineIndexes } : {}), ...(listSelectedLineIndexes ? { listSelectedLineIndexes } : {}), detailRows: detailRows }), _jsx(Text, { color: termcnColors.border, wrap: "truncate-end", children: masterDetailSeparator(tagWidth, listWidth, peekWidth, 'bottom', true) })] }));
602
+ }
603
+ return (_jsx(SkillPane, { rows: paneRows, cursor: cursor, isActive: focus === 'list', viewportHeight: viewportHeight, ...options }));
604
+ };
605
+ const tabs = [
606
+ {
607
+ key: 'project',
608
+ label: `当前项目 ${project.length}`,
609
+ content: (_jsxs(Box, { flexDirection: "column", minHeight: frame.frameHeight - 1, children: [_jsx(AgentTabs, { groups: visibleProjectGroups, agent: activeProjectAgent, focused: !shellBusy && !searching && focus === 'agents' }), renderBrowsePane(listRows, browseViewportHeight(true), {
610
+ showSource: true,
611
+ showReferences: true,
612
+ showGroup: Boolean(query.trim()),
613
+ })] })),
614
+ },
615
+ {
616
+ key: 'global',
617
+ label: `全局 ${globalGroups.reduce((count, group) => count + group.skills.length, 0)}`,
618
+ content: (_jsxs(Box, { flexDirection: "column", minHeight: frame.frameHeight - 1, children: [_jsx(AgentTabs, { groups: visibleGlobalGroups, agent: activeGlobalAgent, focused: !shellBusy && !searching && focus === 'agents' }), renderBrowsePane(listRows, browseViewportHeight(true), {
619
+ showSource: true,
620
+ showGroup: Boolean(query.trim()),
621
+ })] })),
622
+ },
623
+ {
624
+ key: 'collection',
625
+ label: `收藏夹 ${collection.length}`,
626
+ content: (_jsx(Box, { flexDirection: "column", minHeight: frame.frameHeight - 1, children: renderBrowsePane(listRows, browseViewportHeight(false), {
627
+ preferNote: true,
628
+ collection: true,
629
+ showGroup: Boolean(query.trim()),
630
+ updates: updateCheck.updates,
631
+ updatingSkillName,
632
+ }) })),
633
+ },
634
+ ];
635
+ if (choosingGroup) {
636
+ return (_jsx(Select, { label: "\u8DF3\u8F6C\u5230\u5206\u7EC4\uFF1A", numbered: true, options: groups.map((group) => ({
637
+ label: `${group.name} (${group.skills.length})`,
638
+ value: group.name,
639
+ })), onSubmit: (name) => {
640
+ if (useMasterDetail) {
641
+ const index = tagOptions.findIndex((option) => option.key === name);
642
+ setTagFilter(name);
643
+ setTagCursor(Math.max(0, index));
644
+ setCursor(0);
645
+ setFocus('list');
646
+ }
647
+ else {
648
+ setQuery('');
649
+ setCursor(groupRows.findIndex((row) => row.type === 'group' && row.name === name));
650
+ setFocus('list');
651
+ }
652
+ setChoosingGroup(false);
653
+ } }));
654
+ }
655
+ return (_jsx(Box, { flexDirection: "column", children: _jsx(Tabs, { tabs: tabs, activeTab: tab, onTabChange: (key) => setTab(key), isActive: !shellBusy && !searching && focus === 'tabs', enableArrowNav: false, focused: !shellBusy && !searching && focus === 'tabs', width: frame.frameWidth, bordered: false, chip: useBrowseHome, trailing: useMasterDetail && !searching ? (_jsx(Text, { color: termcnColors.muted, children: "/ \u641C\u7D22\u6280\u80FD\u2026" })) : undefined }) }));
656
+ }
657
+ //# sourceMappingURL=browser.js.map