@vibe-forge/client 0.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/LICENSE +21 -0
  2. package/cli.cjs +6 -0
  3. package/index.html +27 -0
  4. package/package.json +42 -0
  5. package/src/App.tsx +174 -0
  6. package/src/api.ts +241 -0
  7. package/src/components/ArchiveView.scss +168 -0
  8. package/src/components/ArchiveView.tsx +299 -0
  9. package/src/components/AutomationView/AutomationView.scss +26 -0
  10. package/src/components/AutomationView/RuleFormPanel.scss +129 -0
  11. package/src/components/AutomationView/RuleFormPanel.tsx +257 -0
  12. package/src/components/AutomationView/RuleSidebar.scss +219 -0
  13. package/src/components/AutomationView/RuleSidebar.tsx +258 -0
  14. package/src/components/AutomationView/RunHistoryPanel.scss +286 -0
  15. package/src/components/AutomationView/RunHistoryPanel.tsx +320 -0
  16. package/src/components/AutomationView/TaskList.scss +128 -0
  17. package/src/components/AutomationView/TaskList.tsx +79 -0
  18. package/src/components/AutomationView/TriggerList.scss +153 -0
  19. package/src/components/AutomationView/TriggerList.tsx +217 -0
  20. package/src/components/AutomationView/index.tsx +228 -0
  21. package/src/components/AutomationView/types.ts +21 -0
  22. package/src/components/Chat.scss +89 -0
  23. package/src/components/Chat.tsx +92 -0
  24. package/src/components/ConfigView.scss +185 -0
  25. package/src/components/ConfigView.tsx +258 -0
  26. package/src/components/NavRail.scss +71 -0
  27. package/src/components/NavRail.tsx +188 -0
  28. package/src/components/Sidebar.scss +112 -0
  29. package/src/components/Sidebar.tsx +291 -0
  30. package/src/components/chat/ChatHeader.scss +401 -0
  31. package/src/components/chat/ChatHeader.tsx +342 -0
  32. package/src/components/chat/ChatHistoryView.tsx +122 -0
  33. package/src/components/chat/ChatSettingsView.tsx +22 -0
  34. package/src/components/chat/ChatTimelineView.scss +53 -0
  35. package/src/components/chat/ChatTimelineView.tsx +158 -0
  36. package/src/components/chat/CodeBlock.scss +87 -0
  37. package/src/components/chat/CodeBlock.tsx +179 -0
  38. package/src/components/chat/CompletionMenu.scss +70 -0
  39. package/src/components/chat/CompletionMenu.tsx +58 -0
  40. package/src/components/chat/CurrentTodoList.scss +217 -0
  41. package/src/components/chat/CurrentTodoList.tsx +103 -0
  42. package/src/components/chat/MarkdownContent.tsx +43 -0
  43. package/src/components/chat/MessageFooter.tsx +48 -0
  44. package/src/components/chat/MessageItem.scss +251 -0
  45. package/src/components/chat/MessageItem.tsx +78 -0
  46. package/src/components/chat/NewSessionGuide.scss +186 -0
  47. package/src/components/chat/NewSessionGuide.tsx +167 -0
  48. package/src/components/chat/Sender.scss +367 -0
  49. package/src/components/chat/Sender.tsx +541 -0
  50. package/src/components/chat/SessionTimelinePanel/EventList.scss +58 -0
  51. package/src/components/chat/SessionTimelinePanel/EventList.tsx +212 -0
  52. package/src/components/chat/SessionTimelinePanel/gantt.ts +177 -0
  53. package/src/components/chat/SessionTimelinePanel/git-graph.ts +518 -0
  54. package/src/components/chat/SessionTimelinePanel/index.scss +28 -0
  55. package/src/components/chat/SessionTimelinePanel/index.tsx +121 -0
  56. package/src/components/chat/SessionTimelinePanel/mermaid.ts +4 -0
  57. package/src/components/chat/SessionTimelinePanel/types.ts +64 -0
  58. package/src/components/chat/SessionTimelinePanel/utils.ts +20 -0
  59. package/src/components/chat/ThinkingStatus.scss +70 -0
  60. package/src/components/chat/ThinkingStatus.tsx +13 -0
  61. package/src/components/chat/ToolCallBox.scss +137 -0
  62. package/src/components/chat/ToolCallBox.tsx +55 -0
  63. package/src/components/chat/ToolGroup.scss +154 -0
  64. package/src/components/chat/ToolGroup.tsx +102 -0
  65. package/src/components/chat/ToolRenderer.tsx +45 -0
  66. package/src/components/chat/messageUtils.ts +171 -0
  67. package/src/components/chat/safeSerialize.ts +84 -0
  68. package/src/components/chat/tools/DefaultTool.tsx +63 -0
  69. package/src/components/chat/tools/adapter-claude/BashTool.scss +71 -0
  70. package/src/components/chat/tools/adapter-claude/BashTool.tsx +82 -0
  71. package/src/components/chat/tools/adapter-claude/GlobTool.scss +88 -0
  72. package/src/components/chat/tools/adapter-claude/GlobTool.tsx +85 -0
  73. package/src/components/chat/tools/adapter-claude/GrepTool.scss +96 -0
  74. package/src/components/chat/tools/adapter-claude/GrepTool.tsx +114 -0
  75. package/src/components/chat/tools/adapter-claude/LSTool.scss +85 -0
  76. package/src/components/chat/tools/adapter-claude/LSTool.tsx +94 -0
  77. package/src/components/chat/tools/adapter-claude/ReadTool.scss +57 -0
  78. package/src/components/chat/tools/adapter-claude/ReadTool.tsx +87 -0
  79. package/src/components/chat/tools/adapter-claude/TodoTool.scss +78 -0
  80. package/src/components/chat/tools/adapter-claude/TodoTool.tsx +60 -0
  81. package/src/components/chat/tools/adapter-claude/WriteTool.scss +92 -0
  82. package/src/components/chat/tools/adapter-claude/WriteTool.tsx +86 -0
  83. package/src/components/chat/tools/adapter-claude/components/FileList.scss +65 -0
  84. package/src/components/chat/tools/adapter-claude/components/FileList.tsx +185 -0
  85. package/src/components/chat/tools/adapter-claude/index.ts +28 -0
  86. package/src/components/chat/tools/defineToolRender.ts +28 -0
  87. package/src/components/chat/tools/task/GetTaskInfoTool.scss +50 -0
  88. package/src/components/chat/tools/task/GetTaskInfoTool.tsx +88 -0
  89. package/src/components/chat/tools/task/ListTasksTool.scss +56 -0
  90. package/src/components/chat/tools/task/ListTasksTool.tsx +83 -0
  91. package/src/components/chat/tools/task/StartTasksTool.scss +56 -0
  92. package/src/components/chat/tools/task/StartTasksTool.tsx +96 -0
  93. package/src/components/chat/tools/task/components/TaskToolCard.scss +127 -0
  94. package/src/components/chat/tools/task/components/TaskToolCard.tsx +177 -0
  95. package/src/components/chat/tools/task/index.ts +15 -0
  96. package/src/components/chat/useChatModels.tsx +206 -0
  97. package/src/components/chat/useChatSession.ts +370 -0
  98. package/src/components/config/ConfigAboutSection.scss +111 -0
  99. package/src/components/config/ConfigAboutSection.tsx +86 -0
  100. package/src/components/config/ConfigDisplayValue.scss +22 -0
  101. package/src/components/config/ConfigDisplayValue.tsx +62 -0
  102. package/src/components/config/ConfigEditors.scss +65 -0
  103. package/src/components/config/ConfigEditors.tsx +98 -0
  104. package/src/components/config/ConfigFieldRow.scss +97 -0
  105. package/src/components/config/ConfigFieldRow.tsx +36 -0
  106. package/src/components/config/ConfigSectionForm.scss +94 -0
  107. package/src/components/config/ConfigSectionForm.tsx +436 -0
  108. package/src/components/config/ConfigSectionPanel.tsx +67 -0
  109. package/src/components/config/ConfigShortcutInput.scss +11 -0
  110. package/src/components/config/ConfigShortcutInput.tsx +52 -0
  111. package/src/components/config/ConfigSourceSwitch.tsx +57 -0
  112. package/src/components/config/configSchema.ts +319 -0
  113. package/src/components/config/configUtils.ts +83 -0
  114. package/src/components/config/index.tsx +5 -0
  115. package/src/components/config/recordEditors/BooleanRecordEditor.scss +1 -0
  116. package/src/components/config/recordEditors/BooleanRecordEditor.tsx +75 -0
  117. package/src/components/config/recordEditors/KeyValueEditor.scss +1 -0
  118. package/src/components/config/recordEditors/KeyValueEditor.tsx +97 -0
  119. package/src/components/config/recordEditors/McpServersRecordEditor.scss +1 -0
  120. package/src/components/config/recordEditors/McpServersRecordEditor.tsx +258 -0
  121. package/src/components/config/recordEditors/ModelServicesRecordEditor.scss +1 -0
  122. package/src/components/config/recordEditors/ModelServicesRecordEditor.tsx +233 -0
  123. package/src/components/config/recordEditors/RecordEditors.scss +117 -0
  124. package/src/components/config/recordEditors/RecordJsonEditor.scss +1 -0
  125. package/src/components/config/recordEditors/RecordJsonEditor.tsx +113 -0
  126. package/src/components/config/recordEditors/index.tsx +5 -0
  127. package/src/components/knowledge-base/KnowledgeBaseView.scss +19 -0
  128. package/src/components/knowledge-base/KnowledgeBaseView.tsx +186 -0
  129. package/src/components/knowledge-base/components/ActionButton.scss +5 -0
  130. package/src/components/knowledge-base/components/ActionButton.tsx +9 -0
  131. package/src/components/knowledge-base/components/EmptyState.scss +19 -0
  132. package/src/components/knowledge-base/components/EmptyState.tsx +42 -0
  133. package/src/components/knowledge-base/components/EntitiesTab.scss +5 -0
  134. package/src/components/knowledge-base/components/EntitiesTab.tsx +80 -0
  135. package/src/components/knowledge-base/components/EntityItem.scss +82 -0
  136. package/src/components/knowledge-base/components/EntityItem.tsx +79 -0
  137. package/src/components/knowledge-base/components/EntityList.scss +5 -0
  138. package/src/components/knowledge-base/components/EntityList.tsx +70 -0
  139. package/src/components/knowledge-base/components/FilterBar.scss +21 -0
  140. package/src/components/knowledge-base/components/FilterBar.tsx +51 -0
  141. package/src/components/knowledge-base/components/FlowsTab.scss +5 -0
  142. package/src/components/knowledge-base/components/FlowsTab.tsx +80 -0
  143. package/src/components/knowledge-base/components/KnowledgeBaseHeader.scss +27 -0
  144. package/src/components/knowledge-base/components/KnowledgeBaseHeader.tsx +29 -0
  145. package/src/components/knowledge-base/components/KnowledgeList.scss +19 -0
  146. package/src/components/knowledge-base/components/KnowledgeList.tsx +19 -0
  147. package/src/components/knowledge-base/components/LoadingState.scss +5 -0
  148. package/src/components/knowledge-base/components/LoadingState.tsx +11 -0
  149. package/src/components/knowledge-base/components/MetaList.scss +19 -0
  150. package/src/components/knowledge-base/components/MetaList.tsx +18 -0
  151. package/src/components/knowledge-base/components/RulesTab.scss +5 -0
  152. package/src/components/knowledge-base/components/RulesTab.tsx +49 -0
  153. package/src/components/knowledge-base/components/SectionHeader.scss +22 -0
  154. package/src/components/knowledge-base/components/SectionHeader.tsx +21 -0
  155. package/src/components/knowledge-base/components/SkillsTab.scss +5 -0
  156. package/src/components/knowledge-base/components/SkillsTab.tsx +49 -0
  157. package/src/components/knowledge-base/components/SpecItem.scss +138 -0
  158. package/src/components/knowledge-base/components/SpecItem.tsx +131 -0
  159. package/src/components/knowledge-base/components/SpecList.scss +5 -0
  160. package/src/components/knowledge-base/components/SpecList.tsx +70 -0
  161. package/src/components/knowledge-base/components/TabContent.scss +8 -0
  162. package/src/components/knowledge-base/components/TabContent.tsx +17 -0
  163. package/src/components/knowledge-base/components/TabLabel.scss +10 -0
  164. package/src/components/knowledge-base/components/TabLabel.tsx +15 -0
  165. package/src/components/knowledge-base/index.tsx +1 -0
  166. package/src/components/sidebar/SessionItem.scss +256 -0
  167. package/src/components/sidebar/SessionItem.tsx +265 -0
  168. package/src/components/sidebar/SessionList.scss +92 -0
  169. package/src/components/sidebar/SessionList.tsx +166 -0
  170. package/src/components/sidebar/SidebarHeader.scss +79 -0
  171. package/src/components/sidebar/SidebarHeader.tsx +128 -0
  172. package/src/connectionManager.ts +172 -0
  173. package/src/hooks/useGlobalShortcut.ts +26 -0
  174. package/src/hooks/useQueryParams.ts +54 -0
  175. package/src/i18n.ts +22 -0
  176. package/src/main.tsx +41 -0
  177. package/src/resources/locales/en.json +765 -0
  178. package/src/resources/locales/zh.json +766 -0
  179. package/src/store/index.ts +23 -0
  180. package/src/styles/global.scss +100 -0
  181. package/src/utils/shortcutUtils.ts +88 -0
  182. package/src/vite-env.d.ts +12 -0
  183. package/src/ws.ts +33 -0
  184. package/vite.config.ts +26 -0
@@ -0,0 +1,113 @@
1
+ import './RecordJsonEditor.scss'
2
+
3
+ import { Button, Input, Tooltip } from 'antd'
4
+ import { useEffect, useMemo, useState } from 'react'
5
+
6
+ import { ComplexTextEditor } from '../ConfigEditors'
7
+ import type { TranslationFn } from '../configUtils'
8
+
9
+ export const RecordJsonEditor = ({
10
+ value,
11
+ onChange,
12
+ t,
13
+ keyPlaceholder
14
+ }: {
15
+ value: Record<string, unknown>
16
+ onChange: (nextValue: Record<string, unknown>) => void
17
+ t: TranslationFn
18
+ keyPlaceholder: string
19
+ }) => {
20
+ const [newKey, setNewKey] = useState('')
21
+ const entries = useMemo(() => Object.entries(value), [value])
22
+ const [collapsedKeys, setCollapsedKeys] = useState<Record<string, boolean>>(() => (
23
+ Object.fromEntries(entries.map(([key]) => [key, true]))
24
+ ))
25
+
26
+ useEffect(() => {
27
+ setCollapsedKeys(prev => {
28
+ const next: Record<string, boolean> = {}
29
+ for (const [key] of entries) {
30
+ next[key] = prev[key] ?? true
31
+ }
32
+ return next
33
+ })
34
+ }, [entries])
35
+
36
+ return (
37
+ <div className='config-view__record-list'>
38
+ {entries.map(([key, itemValue]) => {
39
+ const isCollapsed = collapsedKeys[key] === true
40
+ return (
41
+ <div
42
+ key={key}
43
+ className={`config-view__record-card${isCollapsed ? ' config-view__record-card--collapsed' : ''}`}
44
+ >
45
+ <div className='config-view__record-title'>
46
+ <div className='config-view__record-title-left'>
47
+ <Tooltip title={isCollapsed ? t('config.editor.expand') : t('config.editor.collapse')}>
48
+ <Button
49
+ size='small'
50
+ type='text'
51
+ className='config-view__icon-button config-view__icon-button--compact'
52
+ aria-label={isCollapsed ? t('config.editor.expand') : t('config.editor.collapse')}
53
+ icon={<span className='material-symbols-rounded'>{isCollapsed ? 'chevron_right' : 'expand_more'}</span>}
54
+ onClick={() => {
55
+ setCollapsedKeys(prev => ({ ...prev, [key]: !isCollapsed }))
56
+ }}
57
+ />
58
+ </Tooltip>
59
+ <span>{key}</span>
60
+ </div>
61
+ <Tooltip title={t('config.editor.remove')}>
62
+ <Button
63
+ size='small'
64
+ type='text'
65
+ danger
66
+ className='config-view__icon-button config-view__icon-button--compact'
67
+ aria-label={t('config.editor.remove')}
68
+ icon={<span className='material-symbols-rounded'>delete</span>}
69
+ onClick={() => {
70
+ const updated = { ...value }
71
+ delete updated[key]
72
+ onChange(updated)
73
+ }}
74
+ />
75
+ </Tooltip>
76
+ </div>
77
+ <div className='config-view__record-body'>
78
+ <ComplexTextEditor
79
+ value={itemValue}
80
+ onChange={(next) => {
81
+ onChange({ ...value, [key]: next })
82
+ }}
83
+ />
84
+ </div>
85
+ </div>
86
+ )
87
+ })}
88
+ <div className='config-view__record-add'>
89
+ <div className='config-view__record-add-inputs'>
90
+ <Input
91
+ value={newKey}
92
+ placeholder={keyPlaceholder}
93
+ onChange={(event) => setNewKey(event.target.value)}
94
+ />
95
+ <Tooltip title={t('common.confirm')}>
96
+ <Button
97
+ size='small'
98
+ type='primary'
99
+ className='config-view__icon-button'
100
+ aria-label={t('common.confirm')}
101
+ icon={<span className='material-symbols-rounded'>check</span>}
102
+ disabled={newKey.trim() === '' || Object.hasOwn(value, newKey)}
103
+ onClick={() => {
104
+ onChange({ ...value, [newKey]: {} })
105
+ setNewKey('')
106
+ }}
107
+ />
108
+ </Tooltip>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ )
113
+ }
@@ -0,0 +1,5 @@
1
+ export { BooleanRecordEditor } from './BooleanRecordEditor'
2
+ export { KeyValueEditor } from './KeyValueEditor'
3
+ export { McpServersRecordEditor } from './McpServersRecordEditor'
4
+ export { ModelServicesRecordEditor } from './ModelServicesRecordEditor'
5
+ export { RecordJsonEditor } from './RecordJsonEditor'
@@ -0,0 +1,19 @@
1
+ .knowledge-base-view {
2
+ height: 100%;
3
+ display: flex;
4
+ flex-direction: column;
5
+ padding: 24px;
6
+ background: var(--bg-color);
7
+ color: var(--text-color);
8
+ overflow: hidden;
9
+ }
10
+
11
+ .knowledge-base-view__tabs {
12
+ flex: 1;
13
+ min-height: 0;
14
+ }
15
+
16
+ .knowledge-base-view__tabs > .ant-tabs-nav {
17
+ padding: 0 24px;
18
+ margin: 0;
19
+ }
@@ -0,0 +1,186 @@
1
+ import './KnowledgeBaseView.scss'
2
+
3
+ import { App, Tabs } from 'antd'
4
+ import React from 'react'
5
+ import { useTranslation } from 'react-i18next'
6
+ import useSWR from 'swr'
7
+
8
+ import type { EntitySummary, SpecSummary } from '#~/api.js'
9
+ import { EntitiesTab } from './components/EntitiesTab.js'
10
+ import { FlowsTab } from './components/FlowsTab.js'
11
+ import { KnowledgeBaseHeader } from './components/KnowledgeBaseHeader.js'
12
+ import { RulesTab } from './components/RulesTab.js'
13
+ import { SkillsTab } from './components/SkillsTab.js'
14
+ import { TabLabel } from './components/TabLabel.js'
15
+
16
+ export function KnowledgeBaseView() {
17
+ const { t } = useTranslation()
18
+ const { message } = App.useApp()
19
+ const {
20
+ data: specsRes,
21
+ isLoading: isSpecsLoading,
22
+ mutate: mutateSpecs
23
+ } = useSWR<{ specs: SpecSummary[] }>('/api/ai/specs')
24
+ const {
25
+ data: entitiesRes,
26
+ isLoading: isEntitiesLoading,
27
+ mutate: mutateEntities
28
+ } = useSWR<{ entities: EntitySummary[] }>('/api/ai/entities')
29
+
30
+ const specs = specsRes?.specs ?? []
31
+ const entities = entitiesRes?.entities ?? []
32
+
33
+ const [specQuery, setSpecQuery] = React.useState('')
34
+ const [specTagFilter, setSpecTagFilter] = React.useState<string[]>([])
35
+ const [entityQuery, setEntityQuery] = React.useState('')
36
+ const [entityTagFilter, setEntityTagFilter] = React.useState<string[]>([])
37
+
38
+ const specTagOptions = React.useMemo(() => {
39
+ const tags = new Set<string>()
40
+ specs.forEach(spec => {
41
+ spec.tags?.forEach(tag => tags.add(tag))
42
+ })
43
+ return Array.from(tags).sort().map(tag => ({ label: tag, value: tag }))
44
+ }, [specs])
45
+
46
+ const entityTagOptions = React.useMemo(() => {
47
+ const tags = new Set<string>()
48
+ entities.forEach(entity => {
49
+ entity.tags?.forEach(tag => tags.add(tag))
50
+ })
51
+ return Array.from(tags).sort().map(tag => ({ label: tag, value: tag }))
52
+ }, [entities])
53
+
54
+ const filteredSpecs = React.useMemo(() => {
55
+ const query = specQuery.trim().toLowerCase()
56
+ return specs.filter(spec => {
57
+ const tags = spec.tags ?? []
58
+ if (specTagFilter.length > 0 && !specTagFilter.every(tag => tags.includes(tag))) return false
59
+ if (query === '') return true
60
+ const paramsText = spec.params.map(param => `${param.name} ${param.description ?? ''}`).join(' ')
61
+ const tagsText = tags.join(' ')
62
+ const skillsText = (spec.skills ?? []).join(' ')
63
+ const rulesText = (spec.rules ?? []).join(' ')
64
+ const haystack = `${spec.name} ${spec.description} ${paramsText} ${tagsText} ${skillsText} ${rulesText}`
65
+ .toLowerCase()
66
+ return haystack.includes(query)
67
+ })
68
+ }, [specQuery, specTagFilter, specs])
69
+
70
+ const filteredEntities = React.useMemo(() => {
71
+ const query = entityQuery.trim().toLowerCase()
72
+ return entities.filter(entity => {
73
+ const tags = entity.tags ?? []
74
+ if (entityTagFilter.length > 0 && !entityTagFilter.every(tag => tags.includes(tag))) return false
75
+ if (query === '') return true
76
+ const tagsText = tags.join(' ')
77
+ const skillsText = (entity.skills ?? []).join(' ')
78
+ const rulesText = (entity.rules ?? []).join(' ')
79
+ const haystack = `${entity.name} ${entity.description} ${tagsText} ${skillsText} ${rulesText}`.toLowerCase()
80
+ return haystack.includes(query)
81
+ })
82
+ }, [entityQuery, entityTagFilter, entities])
83
+
84
+ const handleRefresh = async () => {
85
+ await Promise.all([mutateSpecs(), mutateEntities()])
86
+ void message.success(t('knowledge.actions.refreshed'))
87
+ }
88
+
89
+ const handleCreateSpec = () => {
90
+ message.info(t('knowledge.flows.createHint'))
91
+ }
92
+
93
+ const handleImportSpec = () => {
94
+ message.info(t('knowledge.flows.importHint'))
95
+ }
96
+
97
+ const handleCreateEntity = () => {
98
+ message.info(t('knowledge.entities.createHint'))
99
+ }
100
+
101
+ const handleImportEntity = () => {
102
+ message.info(t('knowledge.entities.importHint'))
103
+ }
104
+
105
+ const handleCreateSkill = () => {
106
+ message.info(t('knowledge.skills.createHint'))
107
+ }
108
+
109
+ const handleImportSkill = () => {
110
+ message.info(t('knowledge.skills.importHint'))
111
+ }
112
+
113
+ const handleCreateRule = () => {
114
+ message.info(t('knowledge.rules.createHint'))
115
+ }
116
+
117
+ const handleImportRule = () => {
118
+ message.info(t('knowledge.rules.importHint'))
119
+ }
120
+
121
+ const tabs = [
122
+ {
123
+ key: 'skills',
124
+ label: <TabLabel icon='psychology' label={t('knowledge.tabs.skills')} />,
125
+ children: (
126
+ <SkillsTab
127
+ onCreate={handleCreateSkill}
128
+ onImport={handleImportSkill}
129
+ />
130
+ )
131
+ },
132
+ {
133
+ key: 'entities',
134
+ label: <TabLabel icon='group_work' label={t('knowledge.tabs.entities')} />,
135
+ children: (
136
+ <EntitiesTab
137
+ entities={entities}
138
+ filteredEntities={filteredEntities}
139
+ isLoading={isEntitiesLoading}
140
+ query={entityQuery}
141
+ tagOptions={entityTagOptions}
142
+ tagFilter={entityTagFilter}
143
+ onQueryChange={setEntityQuery}
144
+ onTagFilterChange={setEntityTagFilter}
145
+ onCreate={handleCreateEntity}
146
+ onImport={handleImportEntity}
147
+ />
148
+ )
149
+ },
150
+ {
151
+ key: 'flows',
152
+ label: <TabLabel icon='account_tree' label={t('knowledge.tabs.flows')} />,
153
+ children: (
154
+ <FlowsTab
155
+ specs={specs}
156
+ filteredSpecs={filteredSpecs}
157
+ isLoading={isSpecsLoading}
158
+ query={specQuery}
159
+ tagOptions={specTagOptions}
160
+ tagFilter={specTagFilter}
161
+ onQueryChange={setSpecQuery}
162
+ onTagFilterChange={setSpecTagFilter}
163
+ onCreate={handleCreateSpec}
164
+ onImport={handleImportSpec}
165
+ />
166
+ )
167
+ },
168
+ {
169
+ key: 'rules',
170
+ label: <TabLabel icon='gavel' label={t('knowledge.tabs.rules')} />,
171
+ children: (
172
+ <RulesTab
173
+ onCreate={handleCreateRule}
174
+ onImport={handleImportRule}
175
+ />
176
+ )
177
+ }
178
+ ]
179
+
180
+ return (
181
+ <div className='knowledge-base-view'>
182
+ <KnowledgeBaseHeader onRefresh={handleRefresh} />
183
+ <Tabs className='knowledge-base-view__tabs' items={tabs} />
184
+ </div>
185
+ )
186
+ }
@@ -0,0 +1,5 @@
1
+ .knowledge-base-view__action-button {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: 6px;
5
+ }
@@ -0,0 +1,9 @@
1
+ import './ActionButton.scss'
2
+
3
+ import { Button } from 'antd'
4
+ import type { ButtonProps } from 'antd'
5
+
6
+ export function ActionButton({ className, ...rest }: ButtonProps) {
7
+ const mergedClassName = ['knowledge-base-view__action-button', className].filter(Boolean).join(' ')
8
+ return <Button {...rest} className={mergedClassName} />
9
+ }
@@ -0,0 +1,19 @@
1
+ .knowledge-base-view__empty {
2
+ padding: 24px;
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: center;
6
+ gap: 12px;
7
+ border-radius: 12px;
8
+ border: 1px dashed var(--border-color);
9
+ background: var(--code-bg);
10
+ }
11
+
12
+ .knowledge-base-view__empty-simple {
13
+ padding: 24px;
14
+ display: grid;
15
+ place-items: center;
16
+ border-radius: 12px;
17
+ border: 1px dashed var(--border-color);
18
+ background: var(--code-bg);
19
+ }
@@ -0,0 +1,42 @@
1
+ import './EmptyState.scss'
2
+
3
+ import { Empty } from 'antd'
4
+
5
+ import { ActionButton } from './ActionButton'
6
+
7
+ type EmptyStateProps = {
8
+ description: string
9
+ actionLabel?: string
10
+ onAction?: () => void
11
+ variant?: 'default' | 'simple'
12
+ }
13
+
14
+ export function EmptyState({
15
+ description,
16
+ actionLabel,
17
+ onAction,
18
+ variant = 'default'
19
+ }: EmptyStateProps) {
20
+ if (variant === 'simple') {
21
+ return (
22
+ <div className='knowledge-base-view__empty-simple'>
23
+ <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={description} />
24
+ </div>
25
+ )
26
+ }
27
+
28
+ return (
29
+ <div className='knowledge-base-view__empty'>
30
+ <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={description} />
31
+ {actionLabel && onAction && (
32
+ <ActionButton
33
+ type='primary'
34
+ icon={<span className='material-symbols-rounded'>add_circle</span>}
35
+ onClick={onAction}
36
+ >
37
+ {actionLabel}
38
+ </ActionButton>
39
+ )}
40
+ </div>
41
+ )
42
+ }
@@ -0,0 +1,5 @@
1
+ .knowledge-base-view__entities-tab {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 16px;
5
+ }
@@ -0,0 +1,80 @@
1
+ import './EntitiesTab.scss'
2
+
3
+ import { Space } from 'antd'
4
+ import { useTranslation } from 'react-i18next'
5
+
6
+ import type { EntitySummary } from '#~/api.js'
7
+ import { ActionButton } from './ActionButton'
8
+ import { EntityList } from './EntityList'
9
+ import { FilterBar } from './FilterBar'
10
+ import { SectionHeader } from './SectionHeader'
11
+ import { TabContent } from './TabContent'
12
+
13
+ interface EntitiesTabProps {
14
+ entities: EntitySummary[]
15
+ filteredEntities: EntitySummary[]
16
+ isLoading: boolean
17
+ query: string
18
+ tagOptions: Array<{ label: string; value: string }>
19
+ tagFilter: string[]
20
+ onQueryChange: (value: string) => void
21
+ onTagFilterChange: (value: string[]) => void
22
+ onCreate: () => void
23
+ onImport: () => void
24
+ }
25
+
26
+ export function EntitiesTab({
27
+ entities,
28
+ filteredEntities,
29
+ isLoading,
30
+ query,
31
+ tagOptions,
32
+ tagFilter,
33
+ onQueryChange,
34
+ onTagFilterChange,
35
+ onCreate,
36
+ onImport
37
+ }: EntitiesTabProps) {
38
+ const { t } = useTranslation()
39
+
40
+ return (
41
+ <TabContent className='knowledge-base-view__entities-tab'>
42
+ <SectionHeader
43
+ title={t('knowledge.entities.title')}
44
+ description={t('knowledge.entities.desc')}
45
+ actions={(
46
+ <Space>
47
+ <ActionButton
48
+ icon={<span className='material-symbols-rounded'>download</span>}
49
+ onClick={onImport}
50
+ >
51
+ {t('knowledge.actions.import')}
52
+ </ActionButton>
53
+ <ActionButton
54
+ type='primary'
55
+ icon={<span className='material-symbols-rounded'>add_circle</span>}
56
+ onClick={onCreate}
57
+ >
58
+ {t('knowledge.entities.create')}
59
+ </ActionButton>
60
+ </Space>
61
+ )}
62
+ />
63
+ <FilterBar
64
+ query={query}
65
+ tagOptions={tagOptions}
66
+ tagFilter={tagFilter}
67
+ searchPlaceholder={t('knowledge.filters.search')}
68
+ tagsPlaceholder={t('knowledge.filters.tags')}
69
+ onQueryChange={onQueryChange}
70
+ onTagFilterChange={onTagFilterChange}
71
+ />
72
+ <EntityList
73
+ isLoading={isLoading}
74
+ entities={entities}
75
+ filteredEntities={filteredEntities}
76
+ onCreate={onCreate}
77
+ />
78
+ </TabContent>
79
+ )
80
+ }
@@ -0,0 +1,82 @@
1
+ .knowledge-base-view__item {
2
+ width: 100%;
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 12px;
6
+ padding: 12px 16px;
7
+ }
8
+
9
+ .knowledge-base-view__item-row {
10
+ display: flex;
11
+ align-items: flex-start;
12
+ gap: 16px;
13
+ }
14
+
15
+ .knowledge-base-view__item-main {
16
+ flex: 1;
17
+ min-width: 0;
18
+ display: flex;
19
+ flex-direction: column;
20
+ gap: 4px;
21
+ }
22
+
23
+ .knowledge-base-view__item-title {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: 8px;
27
+ font-weight: 600;
28
+ }
29
+
30
+ .knowledge-base-view__item-icon {
31
+ font-size: 18px;
32
+ color: var(--sub-text-color);
33
+ }
34
+
35
+ .knowledge-base-view__item-desc {
36
+ font-size: 12px;
37
+ color: var(--sub-text-color);
38
+ }
39
+
40
+ .knowledge-base-view__item-meta {
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 8px;
44
+ flex-shrink: 0;
45
+ }
46
+
47
+ .knowledge-base-view__meta-pills {
48
+ display: flex;
49
+ align-items: center;
50
+ gap: 6px;
51
+ }
52
+
53
+ .knowledge-base-view__meta-pill {
54
+ display: inline-flex;
55
+ align-items: center;
56
+ gap: 4px;
57
+ padding: 0 8px;
58
+ height: 28px;
59
+ }
60
+
61
+ .knowledge-base-view__meta-pill-icon {
62
+ font-size: 14px;
63
+ color: var(--sub-text-color);
64
+ }
65
+
66
+ .knowledge-base-view__tag-list {
67
+ display: flex;
68
+ flex-wrap: wrap;
69
+ gap: 6px;
70
+ margin-top: 6px;
71
+ }
72
+
73
+ .knowledge-base-view__tag {
74
+ display: inline-flex;
75
+ align-items: center;
76
+ gap: 4px;
77
+ }
78
+
79
+ .knowledge-base-view__tag-icon {
80
+ font-size: 12px;
81
+ color: var(--sub-text-color);
82
+ }
@@ -0,0 +1,79 @@
1
+ import './EntityItem.scss'
2
+
3
+ import { Button, Popover, Tag } from 'antd'
4
+ import { useTranslation } from 'react-i18next'
5
+
6
+ import type { EntitySummary } from '#~/api.js'
7
+ import { MetaList } from './MetaList'
8
+
9
+ type EntityItemProps = {
10
+ entity: EntitySummary
11
+ }
12
+
13
+ export function EntityItem({ entity }: EntityItemProps) {
14
+ const { t } = useTranslation()
15
+ const tags = entity.tags ?? []
16
+ const skills = entity.skills ?? []
17
+ const rules = entity.rules ?? []
18
+
19
+ return (
20
+ <div className='knowledge-base-view__item'>
21
+ <div className='knowledge-base-view__item-row'>
22
+ <div className='knowledge-base-view__item-main'>
23
+ <div className='knowledge-base-view__item-title'>
24
+ <span className='material-symbols-rounded knowledge-base-view__item-icon'>group_work</span>
25
+ <span>{entity.name}</span>
26
+ </div>
27
+ <div className='knowledge-base-view__item-desc'>{entity.description}</div>
28
+ {tags.length > 0 && (
29
+ <div className='knowledge-base-view__tag-list'>
30
+ {tags.map(tag => (
31
+ <Tag key={tag} className='knowledge-base-view__tag'>
32
+ <span className='material-symbols-rounded knowledge-base-view__tag-icon'>sell</span>
33
+ <span>{tag}</span>
34
+ </Tag>
35
+ ))}
36
+ </div>
37
+ )}
38
+ </div>
39
+ <div className='knowledge-base-view__item-meta'>
40
+ {entity.always && (
41
+ <Tag color='blue'>{t('knowledge.meta.always')}</Tag>
42
+ )}
43
+ <div className='knowledge-base-view__meta-pills'>
44
+ <Popover
45
+ content={<MetaList items={skills} />}
46
+ title={t('knowledge.meta.skills')}
47
+ trigger='click'
48
+ placement='bottomRight'
49
+ >
50
+ <Button
51
+ type='text'
52
+ className='knowledge-base-view__meta-pill'
53
+ disabled={skills.length === 0}
54
+ >
55
+ <span className='material-symbols-rounded knowledge-base-view__meta-pill-icon'>psychology</span>
56
+ <span>{t('knowledge.meta.skillsCount', { count: skills.length })}</span>
57
+ </Button>
58
+ </Popover>
59
+ <Popover
60
+ content={<MetaList items={rules} />}
61
+ title={t('knowledge.meta.rules')}
62
+ trigger='click'
63
+ placement='bottomRight'
64
+ >
65
+ <Button
66
+ type='text'
67
+ className='knowledge-base-view__meta-pill'
68
+ disabled={rules.length === 0}
69
+ >
70
+ <span className='material-symbols-rounded knowledge-base-view__meta-pill-icon'>gavel</span>
71
+ <span>{t('knowledge.meta.rulesCount', { count: rules.length })}</span>
72
+ </Button>
73
+ </Popover>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ )
79
+ }
@@ -0,0 +1,5 @@
1
+ .knowledge-base-view__entity-list {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 12px;
5
+ }