iskills 0.2.26 → 0.2.32

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