@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,92 @@
1
+ .write-tool {
2
+ .tool-header-content {
3
+ display: flex;
4
+ align-items: center;
5
+ width: 100%;
6
+ height: 100%;
7
+ overflow: hidden;
8
+
9
+ .material-symbols-rounded {
10
+ font-size: 18px;
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ color: var(--sub-text-color);
15
+ height: 20px;
16
+ width: 18px;
17
+ margin-right: 8px;
18
+ position: relative;
19
+ top: 1px;
20
+ }
21
+
22
+ .file-name {
23
+ font-size: 13px;
24
+ font-weight: 500;
25
+ color: var(--text-color);
26
+ white-space: nowrap;
27
+ line-height: 20px;
28
+ display: flex;
29
+ align-items: center;
30
+ }
31
+
32
+ .file-path {
33
+ font-size: 12px;
34
+ color: var(--sub-text-color);
35
+ white-space: nowrap;
36
+ overflow: hidden;
37
+ text-overflow: ellipsis;
38
+ display: flex;
39
+ align-items: center;
40
+ min-width: 0;
41
+ flex: 1;
42
+ line-height: 20px;
43
+
44
+ &::before {
45
+ content: '—';
46
+ margin: 0 8px;
47
+ color: var(--border-color);
48
+ font-weight: 300;
49
+ }
50
+ }
51
+ }
52
+
53
+ .write-result-status {
54
+ display: flex;
55
+ align-items: center;
56
+ gap: 4px;
57
+
58
+ .status-icon {
59
+ font-size: 14px;
60
+ }
61
+
62
+ .status-text {
63
+ font-size: 12px;
64
+ }
65
+
66
+ &.error {
67
+ .status-icon, .status-text {
68
+ color: #ef4444;
69
+ }
70
+ }
71
+
72
+ &.success {
73
+ .status-icon {
74
+ color: #10b981;
75
+ }
76
+ .status-text {
77
+ color: #059669;
78
+ }
79
+ }
80
+ }
81
+
82
+ .tool-content {
83
+ display: flex;
84
+ flex-direction: column;
85
+ }
86
+
87
+ .write-result-status {
88
+ display: flex;
89
+ align-items: center;
90
+ gap: 4px;
91
+ }
92
+ }
@@ -0,0 +1,86 @@
1
+ import React from 'react'
2
+ import './WriteTool.scss'
3
+ import { useTranslation } from 'react-i18next'
4
+
5
+ import { defineToolRender } from '../defineToolRender'
6
+ import { CodeBlock } from '../../CodeBlock'
7
+ import { ToolCallBox } from '../../ToolCallBox'
8
+
9
+ export const WriteTool = defineToolRender(({ item, resultItem }) => {
10
+ const { t } = useTranslation()
11
+ const input = (item.input != null ? item.input : {}) as { file_path?: string; content?: string }
12
+ const filePath = (input.file_path != null && input.file_path !== '') ? input.file_path : 'unknown file'
13
+ const lastPart = filePath.split('/').pop()
14
+ const fileName = (lastPart != null && lastPart !== '') ? lastPart : filePath
15
+ const dirPath = filePath.includes('/') ? filePath.substring(0, filePath.lastIndexOf('/')) : ''
16
+ const content = input.content ?? ''
17
+
18
+ const getLanguage = (path: string) => {
19
+ const extPart = path.split('.').pop()
20
+ const ext = (extPart != null && extPart !== '') ? extPart.toLowerCase() : ''
21
+ const langMap: Record<string, string> = {
22
+ 'js': 'javascript',
23
+ 'jsx': 'jsx',
24
+ 'ts': 'typescript',
25
+ 'tsx': 'tsx',
26
+ 'py': 'python',
27
+ 'md': 'markdown',
28
+ 'json': 'json',
29
+ 'scss': 'scss',
30
+ 'css': 'css',
31
+ 'html': 'html',
32
+ 'sh': 'bash',
33
+ 'yml': 'yaml',
34
+ 'yaml': 'yaml',
35
+ 'sql': 'sql'
36
+ }
37
+ return langMap[ext] || 'text'
38
+ }
39
+
40
+ const language = getLanguage(filePath)
41
+
42
+ return (
43
+ <div className='tool-group write-tool'>
44
+ <ToolCallBox
45
+ defaultExpanded={false}
46
+ header={
47
+ <div className='tool-header-content'>
48
+ <span className='material-symbols-rounded'>edit_note</span>
49
+ <span className='file-name'>{fileName}</span>
50
+ {(dirPath != null && dirPath !== '') && <span className='file-path'>{dirPath}</span>}
51
+ </div>
52
+ }
53
+ content={
54
+ <div className='tool-content'>
55
+ <div className='bash-content-scroll'>
56
+ <div className='bash-code-wrapper'>
57
+ <CodeBlock
58
+ code={content}
59
+ lang={language}
60
+ showLineNumbers={true}
61
+ />
62
+ </div>
63
+ </div>
64
+ </div>
65
+ }
66
+ />
67
+ {resultItem != null && (
68
+ <ToolCallBox
69
+ type='result'
70
+ isError={resultItem.is_error}
71
+ header={
72
+ <div className={`write-result-status ${resultItem.is_error ? 'error' : 'success'}`}>
73
+ <span className='material-symbols-rounded status-icon'>
74
+ {resultItem.is_error === true ? 'error' : 'check_circle'}
75
+ </span>
76
+ <span className='status-text'>
77
+ {resultItem.is_error === true ? t('chat.tools.writeFailed') : t('chat.tools.writeSuccess')}
78
+ </span>
79
+ </div>
80
+ }
81
+ content={null}
82
+ />
83
+ )}
84
+ </div>
85
+ )
86
+ })
@@ -0,0 +1,65 @@
1
+ .file-list-container {
2
+ font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', 'Consolas', 'Courier New', monospace;
3
+ font-size: 12px;
4
+ line-height: 1.4;
5
+ border-radius: 6px;
6
+ background: var(--bg-color);
7
+ color: var(--text-color);
8
+ }
9
+
10
+ .file-list-item {
11
+ display: flex;
12
+ align-items: center;
13
+ padding: 2px 8px;
14
+ cursor: pointer;
15
+ user-select: none;
16
+ white-space: nowrap;
17
+ overflow: hidden;
18
+ text-overflow: ellipsis;
19
+ transition: background-color 0.2s ease;
20
+
21
+ &:hover {
22
+ background-color: var(--tag-bg);
23
+ }
24
+
25
+ &.is-dir {
26
+ font-weight: 500;
27
+ }
28
+ }
29
+
30
+ .file-icon {
31
+ font-size: 14px;
32
+ margin-right: 4px;
33
+ color: var(--sub-text-color);
34
+
35
+ &.folder {
36
+ color: var(--primary-color);
37
+ }
38
+
39
+ &.file {
40
+ color: var(--sub-text-color);
41
+ }
42
+ }
43
+
44
+ .toggle-icon {
45
+ font-size: 14px;
46
+ margin-right: 4px;
47
+ color: var(--sub-text-color);
48
+ }
49
+
50
+ .spacer {
51
+ width: 14px;
52
+ margin-right: 4px;
53
+ }
54
+
55
+ .file-path {
56
+ overflow: hidden;
57
+ text-overflow: ellipsis;
58
+ }
59
+
60
+ .file-list-empty {
61
+ padding: 8px 12px;
62
+ color: var(--sub-text-color);
63
+ font-size: 12px;
64
+ text-align: center;
65
+ }
@@ -0,0 +1,185 @@
1
+ import React, { useEffect, useMemo, useState } from 'react'
2
+ import './FileList.scss'
3
+
4
+ interface FileNode {
5
+ rawLine: string
6
+ name: string
7
+ path: string
8
+ depth: number
9
+ isDir: boolean
10
+ }
11
+
12
+ interface FileListProps {
13
+ content: string | string[]
14
+ removeRoot?: boolean
15
+ defaultCollapsed?: boolean
16
+ }
17
+
18
+ export function FileList({ content, removeRoot = false, defaultCollapsed = false }: FileListProps) {
19
+ const nodes = useMemo(() => {
20
+ let lines: string[] = []
21
+ if (Array.isArray(content)) {
22
+ lines = content
23
+ } else if (typeof content === 'string') {
24
+ if (content.trim().startsWith('[') && content.trim().endsWith(']')) {
25
+ try {
26
+ const parsed = JSON.parse(content)
27
+ if (Array.isArray(parsed)) {
28
+ lines = parsed.map(String)
29
+ } else {
30
+ lines = content.split('\n')
31
+ }
32
+ } catch (e) {
33
+ lines = content.split('\n')
34
+ }
35
+ } else {
36
+ lines = content.split('\n')
37
+ }
38
+ }
39
+
40
+ lines = lines.filter(line => line.trim() !== '')
41
+
42
+ let parsedNodes: FileNode[] = []
43
+
44
+ lines.forEach(line => {
45
+ const leadingSpaces = line.match(/^\s*/)?.[0].length || 0
46
+ const depth = Math.floor(leadingSpaces / 2)
47
+
48
+ let name = line.trim()
49
+ if (name.startsWith('- ')) {
50
+ name = name.substring(2)
51
+ }
52
+
53
+ const isDir = name.endsWith('/') || name.endsWith('\\')
54
+
55
+ parsedNodes.push({
56
+ rawLine: line,
57
+ name,
58
+ path: name,
59
+ depth,
60
+ isDir
61
+ })
62
+ })
63
+
64
+ if (removeRoot && parsedNodes.length > 1 && parsedNodes[0].isDir) {
65
+ if (parsedNodes[1].depth > parsedNodes[0].depth) {
66
+ const rootDepth = parsedNodes[0].depth
67
+ parsedNodes.shift()
68
+ const minDepth = Math.min(...parsedNodes.map(n => n.depth))
69
+ parsedNodes = parsedNodes.map(n => ({
70
+ ...n,
71
+ depth: n.depth - minDepth
72
+ }))
73
+ }
74
+ }
75
+
76
+ return parsedNodes
77
+ }, [content, removeRoot])
78
+
79
+ const [collapsedIndices, setCollapsedIndices] = useState<Set<number>>(new Set())
80
+
81
+ const hasDirectories = useMemo(() => {
82
+ return nodes.some(node => node.isDir)
83
+ }, [nodes])
84
+
85
+ useEffect(() => {
86
+ if (defaultCollapsed) {
87
+ const newSet = new Set<number>()
88
+ nodes.forEach((node, index) => {
89
+ if (node.isDir) {
90
+ newSet.add(index)
91
+ }
92
+ })
93
+ setCollapsedIndices(newSet)
94
+ } else {
95
+ setCollapsedIndices(new Set())
96
+ }
97
+ }, [nodes, defaultCollapsed])
98
+
99
+ const toggleCollapse = (index: number) => {
100
+ const newSet = new Set(collapsedIndices)
101
+ if (newSet.has(index)) {
102
+ newSet.delete(index)
103
+ } else {
104
+ newSet.add(index)
105
+ }
106
+ setCollapsedIndices(newSet)
107
+ }
108
+
109
+ if (nodes.length === 0) {
110
+ return <div className='file-list-empty'>No files found</div>
111
+ }
112
+
113
+ const getIcon = (node: FileNode) => {
114
+ if (node.isDir) {
115
+ return { name: 'folder', className: 'folder' }
116
+ }
117
+
118
+ const ext = node.name.split('.').pop()?.toLowerCase()
119
+ if (ext && ['ts', 'tsx', 'js', 'jsx', 'py', 'java', 'c', 'cpp', 'go', 'rs'].includes(ext)) {
120
+ return { name: 'code', className: 'file' }
121
+ }
122
+ if (ext && ['md', 'txt', 'json', 'yml', 'yaml', 'xml', 'html', 'css', 'scss'].includes(ext)) {
123
+ return { name: 'description', className: 'file' }
124
+ }
125
+ if (ext && ['png', 'jpg', 'jpeg', 'gif', 'svg', 'ico'].includes(ext)) {
126
+ return { name: 'image', className: 'file' }
127
+ }
128
+
129
+ return { name: 'draft', className: 'file' }
130
+ }
131
+
132
+ const renderNodes = () => {
133
+ const elements: React.ReactNode[] = []
134
+ let hideDepth: number | null = null
135
+
136
+ nodes.forEach((node, index) => {
137
+ if (hideDepth !== null) {
138
+ if (node.depth > hideDepth) {
139
+ return
140
+ } else {
141
+ hideDepth = null
142
+ }
143
+ }
144
+
145
+ const icon = getIcon(node)
146
+ const isCollapsed = collapsedIndices.has(index)
147
+
148
+ if (isCollapsed) {
149
+ hideDepth = node.depth
150
+ }
151
+
152
+ elements.push(
153
+ <div
154
+ key={index}
155
+ className={`file-list-item ${node.isDir ? 'is-dir' : ''}`}
156
+ style={{ paddingLeft: `${node.depth * 20 + 12}px` }}
157
+ onClick={() => node.isDir && toggleCollapse(index)}
158
+ >
159
+ {hasDirectories && (
160
+ <>
161
+ {node.isDir && (
162
+ <span className='material-symbols-rounded toggle-icon'>
163
+ {isCollapsed ? 'arrow_right' : 'arrow_drop_down'}
164
+ </span>
165
+ )}
166
+ {!node.isDir && <span className='spacer' />}
167
+ </>
168
+ )}
169
+
170
+ <span className={`material-symbols-rounded file-icon ${icon.className}`}>
171
+ {icon.name}
172
+ </span>
173
+ <span className='file-path'>{node.name}</span>
174
+ </div>
175
+ )
176
+ })
177
+ return elements
178
+ }
179
+
180
+ return (
181
+ <div className='file-list-container'>
182
+ {renderNodes()}
183
+ </div>
184
+ )
185
+ }
@@ -0,0 +1,28 @@
1
+ import { defineToolRenders } from '../defineToolRender'
2
+ import { BashTool } from './BashTool'
3
+ import { GlobTool } from './GlobTool'
4
+ import { GrepTool } from './GrepTool'
5
+ import { LsTool } from './LSTool'
6
+ import { ReadTool } from './ReadTool'
7
+ import { TodoTool } from './TodoTool'
8
+ import { WriteTool } from './WriteTool'
9
+
10
+ export const adapterClaudeToolRenders = defineToolRenders({
11
+ Bash: BashTool,
12
+ LS: LsTool,
13
+ Glob: GlobTool,
14
+ Grep: GrepTool,
15
+ Read: ReadTool,
16
+ Write: WriteTool,
17
+ TodoWrite: TodoTool
18
+ })
19
+
20
+ export {
21
+ BashTool,
22
+ GlobTool,
23
+ GrepTool,
24
+ LsTool,
25
+ ReadTool,
26
+ TodoTool,
27
+ WriteTool
28
+ }
@@ -0,0 +1,28 @@
1
+ import type { ChatMessageContent } from '@vibe-forge/core'
2
+ import type React from 'react'
3
+
4
+ export interface ToolRenderProps {
5
+ item: Extract<ChatMessageContent, { type: 'tool_use' }>
6
+ resultItem?: Extract<ChatMessageContent, { type: 'tool_result' }>
7
+ }
8
+
9
+ export type ToolRenderComponent = React.ComponentType<ToolRenderProps>
10
+
11
+ export function defineToolRender<T extends ToolRenderComponent>(render: T) {
12
+ return render
13
+ }
14
+
15
+ export function defineToolRenders(
16
+ renders: Record<string, ToolRenderComponent>,
17
+ options?: { namespace?: string }
18
+ ) {
19
+ const namespace = options?.namespace
20
+ const entries = Object.entries(renders).flatMap(([name, renderer]) => {
21
+ const current: Array<[string, ToolRenderComponent]> = [[name, renderer]]
22
+ if (namespace) {
23
+ current.push([`${namespace}${name}`, renderer])
24
+ }
25
+ return current
26
+ })
27
+ return Object.fromEntries(entries) as Record<string, ToolRenderComponent>
28
+ }
@@ -0,0 +1,50 @@
1
+ .tool-group.get-task-info-tool {
2
+ border-color: color-mix(
3
+ in srgb,
4
+ var(--border-color) 55%,
5
+ var(--primary-color) 45%
6
+ );
7
+
8
+ & .tool-call-header {
9
+ background: linear-gradient(
10
+ 90deg,
11
+ color-mix(in srgb, var(--tag-bg) 80%, var(--primary-color) 20%),
12
+ var(--tag-bg)
13
+ );
14
+ }
15
+
16
+ &__header {
17
+ display: flex;
18
+ align-items: center;
19
+ gap: 8px;
20
+ }
21
+
22
+ &__icon {
23
+ font-size: 16px;
24
+ }
25
+
26
+ &__title {
27
+ font-weight: 600;
28
+ }
29
+
30
+ &__count {
31
+ margin-left: 4px;
32
+ padding: 1px 6px;
33
+ border: 1px solid var(--border-color);
34
+ border-radius: 999px;
35
+ font-size: 11px;
36
+ font-weight: 600;
37
+ color: var(--sub-text-color);
38
+ background: color-mix(in srgb, var(--bg-color) 70%, transparent 30%);
39
+ }
40
+
41
+ &__empty {
42
+ margin: 10px 12px;
43
+ padding: 10px 12px;
44
+ border: 1px dashed var(--border-color);
45
+ border-radius: 8px;
46
+ font-size: 12px;
47
+ color: var(--sub-text-color);
48
+ background: var(--bg-color);
49
+ }
50
+ }
@@ -0,0 +1,88 @@
1
+ import './GetTaskInfoTool.scss'
2
+
3
+ import React, { useMemo } from 'react'
4
+ import { useTranslation } from 'react-i18next'
5
+
6
+ import { defineToolRender } from '../defineToolRender'
7
+ import { ToolCallBox } from '../../ToolCallBox'
8
+ import { TaskToolCard } from './components/TaskToolCard'
9
+
10
+ interface TaskResult {
11
+ taskId: string
12
+ status?: 'running' | 'completed' | 'failed'
13
+ exitCode?: number | null
14
+ description?: string
15
+ type?: 'default' | 'spec' | 'entity'
16
+ name?: string | null
17
+ adapter?: string | null
18
+ background?: boolean
19
+ logs?: string[] | null
20
+ }
21
+
22
+ export const GetTaskInfoTool = defineToolRender(({ item, resultItem }) => {
23
+ const { t } = useTranslation()
24
+
25
+ const input = (item.input != null ? item.input : {}) as { taskId?: string }
26
+ const inputTaskId = input.taskId
27
+
28
+ const taskResult = useMemo(() => {
29
+ if (!resultItem?.content) {
30
+ return null
31
+ }
32
+ const text = resultItem.content[0].text.trim()
33
+ const parsed = JSON.parse(text) as TaskResult[]
34
+ return parsed[0] ?? null
35
+ }, [resultItem?.content])
36
+
37
+ const logs = taskResult?.logs ?? []
38
+ const metaChips = taskResult ? (() => {
39
+ const { exitCode, ...cardMeta } = taskResult
40
+ return [
41
+ cardMeta.adapter,
42
+ cardMeta.type === 'default' ? undefined : cardMeta.type,
43
+ cardMeta.name,
44
+ cardMeta.status,
45
+ exitCode != null ? t('chat.tools.taskExitCode', { code: exitCode }) : undefined,
46
+ cardMeta.background === false ? t('chat.tools.startTasksForeground') : cardMeta.background === true ? t('chat.tools.startTasksBackground') : undefined
47
+ ]
48
+ })() : []
49
+ const titleFallback = t('chat.tools.task')
50
+
51
+ return (
52
+ <div className='tool-group get-task-info-tool'>
53
+ <ToolCallBox
54
+ defaultExpanded={true}
55
+ header={
56
+ <div className='get-task-info-tool__header'>
57
+ <span className='material-symbols-rounded get-task-info-tool__icon'>info</span>
58
+ <span className='get-task-info-tool__title'>{t('chat.tools.getTaskInfo')}</span>
59
+ <span className='get-task-info-tool__count'>{taskResult ? 1 : 0}</span>
60
+ </div>
61
+ }
62
+ content={
63
+ <div className='tool-content'>
64
+ {taskResult ? (
65
+ (() => {
66
+ const { taskId, exitCode, ...cardProps } = taskResult
67
+ return (
68
+ <TaskToolCard
69
+ {...cardProps}
70
+ logs={logs}
71
+ sessionId={taskId || inputTaskId}
72
+ titleFallback={titleFallback}
73
+ metaChips={metaChips}
74
+ showExecutionIcon={false}
75
+ />
76
+ )
77
+ })()
78
+ ) : (
79
+ <div className='get-task-info-tool__empty'>
80
+ {t('chat.tools.startTasksEmpty')}
81
+ </div>
82
+ )}
83
+ </div>
84
+ }
85
+ />
86
+ </div>
87
+ )
88
+ })
@@ -0,0 +1,56 @@
1
+ .list-tasks-tool {
2
+ border-color: color-mix(
3
+ in srgb,
4
+ var(--border-color) 55%,
5
+ var(--primary-color) 45%
6
+ );
7
+
8
+ & .tool-call-header {
9
+ background: linear-gradient(
10
+ 90deg,
11
+ color-mix(in srgb, var(--tag-bg) 80%, var(--primary-color) 20%),
12
+ var(--tag-bg)
13
+ );
14
+ }
15
+
16
+ &__header {
17
+ display: flex;
18
+ align-items: center;
19
+ gap: 8px;
20
+ }
21
+
22
+ &__icon {
23
+ font-size: 16px;
24
+ }
25
+
26
+ &__title {
27
+ font-weight: 600;
28
+ }
29
+
30
+ &__count {
31
+ margin-left: 4px;
32
+ padding: 1px 6px;
33
+ border: 1px solid var(--border-color);
34
+ border-radius: 999px;
35
+ font-size: 11px;
36
+ font-weight: 600;
37
+ color: var(--sub-text-color);
38
+ background: color-mix(in srgb, var(--bg-color) 70%, transparent 30%);
39
+ }
40
+
41
+ &__list {
42
+ padding: 10px 12px;
43
+ display: flex;
44
+ flex-direction: column;
45
+ gap: 8px;
46
+ }
47
+
48
+ &__empty {
49
+ padding: 10px 12px;
50
+ border: 1px dashed var(--border-color);
51
+ border-radius: 8px;
52
+ font-size: 12px;
53
+ color: var(--sub-text-color);
54
+ background: var(--bg-color);
55
+ }
56
+ }