@lobehub/lobehub 2.0.0-next.73 → 2.0.0-next.75

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 (78) hide show
  1. package/.github/workflows/desktop-pr-build.yml +7 -3
  2. package/CHANGELOG.md +50 -0
  3. package/apps/desktop/package.json +1 -0
  4. package/apps/desktop/src/main/controllers/LocalFileCtr.ts +55 -11
  5. package/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts +153 -0
  6. package/changelog/v1.json +18 -0
  7. package/locales/ar/chat.json +5 -0
  8. package/locales/ar/models.json +15 -0
  9. package/locales/ar/tool.json +12 -1
  10. package/locales/bg-BG/chat.json +5 -0
  11. package/locales/bg-BG/models.json +15 -0
  12. package/locales/bg-BG/tool.json +12 -1
  13. package/locales/de-DE/chat.json +5 -0
  14. package/locales/de-DE/models.json +15 -0
  15. package/locales/de-DE/tool.json +12 -1
  16. package/locales/en-US/models.json +15 -0
  17. package/locales/en-US/tool.json +12 -1
  18. package/locales/es-ES/chat.json +5 -0
  19. package/locales/es-ES/models.json +15 -0
  20. package/locales/es-ES/tool.json +12 -1
  21. package/locales/fa-IR/chat.json +5 -0
  22. package/locales/fa-IR/models.json +15 -0
  23. package/locales/fa-IR/tool.json +12 -1
  24. package/locales/fr-FR/chat.json +5 -0
  25. package/locales/fr-FR/models.json +15 -0
  26. package/locales/fr-FR/tool.json +12 -1
  27. package/locales/it-IT/chat.json +5 -0
  28. package/locales/it-IT/models.json +15 -0
  29. package/locales/it-IT/tool.json +12 -1
  30. package/locales/ja-JP/chat.json +5 -0
  31. package/locales/ja-JP/models.json +15 -0
  32. package/locales/ja-JP/tool.json +12 -1
  33. package/locales/ko-KR/chat.json +5 -0
  34. package/locales/ko-KR/models.json +15 -0
  35. package/locales/ko-KR/tool.json +12 -1
  36. package/locales/nl-NL/chat.json +5 -0
  37. package/locales/nl-NL/models.json +15 -0
  38. package/locales/nl-NL/tool.json +12 -1
  39. package/locales/pl-PL/chat.json +5 -0
  40. package/locales/pl-PL/models.json +15 -0
  41. package/locales/pl-PL/tool.json +12 -1
  42. package/locales/pt-BR/chat.json +5 -0
  43. package/locales/pt-BR/models.json +15 -0
  44. package/locales/pt-BR/tool.json +12 -1
  45. package/locales/ru-RU/chat.json +5 -0
  46. package/locales/ru-RU/models.json +15 -0
  47. package/locales/ru-RU/tool.json +12 -1
  48. package/locales/tr-TR/chat.json +5 -0
  49. package/locales/tr-TR/models.json +15 -0
  50. package/locales/tr-TR/tool.json +12 -1
  51. package/locales/vi-VN/chat.json +5 -0
  52. package/locales/vi-VN/models.json +15 -0
  53. package/locales/vi-VN/tool.json +12 -1
  54. package/locales/zh-CN/models.json +15 -0
  55. package/locales/zh-CN/tool.json +12 -1
  56. package/locales/zh-TW/chat.json +5 -0
  57. package/locales/zh-TW/models.json +15 -0
  58. package/locales/zh-TW/tool.json +12 -1
  59. package/package.json +2 -1
  60. package/packages/electron-client-ipc/src/types/localSystem.ts +4 -0
  61. package/scripts/prebuild.mts +15 -5
  62. package/src/app/[variants]/desktopRouter.config.tsx +0 -17
  63. package/src/app/[variants]/mobileRouter.config.tsx +0 -16
  64. package/src/app/[variants]/page.tsx +5 -4
  65. package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +23 -4
  66. package/src/locales/default/tool.ts +11 -0
  67. package/src/store/chat/slices/builtinTool/actions/__tests__/localSystem.test.ts +5 -6
  68. package/src/store/chat/slices/builtinTool/actions/localSystem.ts +45 -182
  69. package/src/tools/executionRuntimes.ts +3 -0
  70. package/src/tools/local-system/ExecutionRuntime/index.ts +407 -0
  71. package/src/tools/local-system/Intervention/EditLocalFile/index.tsx +89 -0
  72. package/src/tools/local-system/Intervention/WriteFile/index.tsx +72 -0
  73. package/src/tools/local-system/Intervention/index.ts +4 -0
  74. package/src/tools/local-system/Render/EditLocalFile/index.tsx +67 -0
  75. package/src/tools/local-system/Render/ReadLocalFile/ReadFileView.tsx +53 -78
  76. package/src/tools/local-system/Render/index.ts +2 -0
  77. package/src/tools/local-system/index.ts +1 -0
  78. package/src/tools/local-system/type.ts +4 -3
@@ -1,8 +1,8 @@
1
1
  import { LocalReadFileResult } from '@lobechat/electron-client-ipc';
2
2
  import { ActionIcon, Icon, Markdown, Text } from '@lobehub/ui';
3
3
  import { createStyles } from 'antd-style';
4
- import { AlignLeft, Asterisk, ChevronDownIcon, ExternalLink, FolderOpen } from 'lucide-react';
5
- import React, { memo, useState } from 'react';
4
+ import { AlignLeft, Asterisk, ExternalLink, FolderOpen } from 'lucide-react';
5
+ import React, { memo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
@@ -24,7 +24,6 @@ const useStyles = createStyles(({ css, token, cx }) => ({
24
24
  container: css`
25
25
  justify-content: space-between;
26
26
 
27
- height: 64px;
28
27
  padding: 8px;
29
28
  border-radius: ${token.borderRadiusLG}px;
30
29
 
@@ -79,11 +78,11 @@ const useStyles = createStyles(({ css, token, cx }) => ({
79
78
 
80
79
  overflow: hidden;
81
80
 
82
- margin-block-start: 8px;
83
- padding: 8px;
81
+ padding-block: 0;
82
+ padding-inline: 8px;
84
83
  border-radius: 8px;
85
84
 
86
- background: ${token.colorFillQuaternary};
85
+ background: ${token.colorBgContainer};
87
86
  `,
88
87
  previewText: css`
89
88
  font-size: 12px;
@@ -102,11 +101,6 @@ const ReadFileView = memo<ReadFileViewProps>(
102
101
  ({ filename, path, fileType, charCount, content, totalLineCount, totalCharCount, loc }) => {
103
102
  const { t } = useTranslation('tool');
104
103
  const { styles } = useStyles();
105
- const [isExpanded, setIsExpanded] = useState(false);
106
-
107
- const handleToggleExpand = () => {
108
- setIsExpanded(!isExpanded);
109
- };
110
104
 
111
105
  const handleOpenFile = (e: React.MouseEvent) => {
112
106
  e.stopPropagation();
@@ -121,89 +115,70 @@ const ReadFileView = memo<ReadFileViewProps>(
121
115
  const displayPath = useElectronStore(desktopStateSelectors.displayRelativePath(path));
122
116
 
123
117
  return (
124
- <Flexbox className={styles.container}>
125
- <Flexbox
126
- align={'center'}
127
- className={styles.header}
128
- gap={12}
129
- horizontal
130
- justify={'space-between'}
131
- onClick={handleToggleExpand}
132
- >
133
- <Flexbox align={'center'} flex={1} gap={0} horizontal style={{ overflow: 'hidden' }}>
134
- <FileIcon fileName={filename} fileType={fileType} size={16} variant={'raw'} />
135
- <Flexbox horizontal>
136
- <Text className={styles.fileName} ellipsis>
137
- {filename}
138
- </Text>
139
- {/* Actions on Hover */}
140
- <Flexbox className={styles.actions} gap={2} horizontal style={{ marginLeft: 8 }}>
141
- <ActionIcon
142
- icon={ExternalLink}
143
- onClick={handleOpenFile}
144
- size="small"
145
- title={t('localFiles.openFile')}
146
- />
147
- <ActionIcon
148
- icon={FolderOpen}
149
- onClick={handleOpenFolder}
150
- size="small"
151
- title={t('localFiles.openFolder')}
152
- />
118
+ <Flexbox className={styles.container} gap={12}>
119
+ <Flexbox>
120
+ <Flexbox
121
+ align={'center'}
122
+ className={styles.header}
123
+ gap={12}
124
+ horizontal
125
+ justify={'space-between'}
126
+ >
127
+ <Flexbox align={'center'} flex={1} gap={0} horizontal style={{ overflow: 'hidden' }}>
128
+ <FileIcon fileName={filename} fileType={fileType} size={16} variant={'raw'} />
129
+ <Flexbox horizontal>
130
+ <Text className={styles.fileName} ellipsis>
131
+ {filename}
132
+ </Text>
133
+ {/* Actions on Hover */}
134
+ <Flexbox className={styles.actions} gap={2} horizontal style={{ marginLeft: 8 }}>
135
+ <ActionIcon
136
+ icon={ExternalLink}
137
+ onClick={handleOpenFile}
138
+ size="small"
139
+ title={t('localFiles.openFile')}
140
+ />
141
+ <ActionIcon
142
+ icon={FolderOpen}
143
+ onClick={handleOpenFolder}
144
+ size="small"
145
+ title={t('localFiles.openFolder')}
146
+ />
147
+ </Flexbox>
153
148
  </Flexbox>
154
149
  </Flexbox>
155
- </Flexbox>
156
- <Flexbox align={'center'} className={styles.meta} gap={8} horizontal>
157
- {isExpanded && (
150
+ <Flexbox align={'center'} className={styles.meta} gap={16} horizontal>
158
151
  <Flexbox align={'center'} gap={4} horizontal>
159
152
  <Icon icon={Asterisk} size={'small'} />
160
153
  <span>
161
154
  {charCount} / <span className={styles.lineCount}>{totalCharCount}</span>
162
155
  </span>
163
156
  </Flexbox>
164
- )}
165
- <Flexbox align={'center'} gap={4} horizontal>
166
- <Icon icon={AlignLeft} size={'small'} />
167
- {isExpanded ? (
157
+ <Flexbox align={'center'} gap={4} horizontal>
158
+ <Icon icon={AlignLeft} size={'small'} />
168
159
  <span>
169
160
  L{loc?.[0]}-{loc?.[1]} /{' '}
170
161
  <span className={styles.lineCount}>{totalLineCount}</span>
171
162
  </span>
172
- ) : (
173
- <span>
174
- L{loc?.[0]}-{loc?.[1]}
175
- </span>
176
- )}
163
+ </Flexbox>
177
164
  </Flexbox>
178
- <ActionIcon
179
- active={isExpanded}
180
- icon={ChevronDownIcon}
181
- onClick={handleToggleExpand}
182
- size="small"
183
- style={{
184
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
185
- transition: 'transform 0.2s',
186
- }}
187
- />
188
165
  </Flexbox>
166
+
167
+ {/* Path */}
168
+ <Text className={styles.path} ellipsis type={'secondary'}>
169
+ {displayPath}
170
+ </Text>
189
171
  </Flexbox>
190
172
 
191
- {/* Path */}
192
- <Text className={styles.path} ellipsis type={'secondary'}>
193
- {displayPath}
194
- </Text>
195
-
196
- {isExpanded && (
197
- <Flexbox className={styles.previewBox} style={{ maxHeight: 240, overflow: 'auto' }}>
198
- {fileType === 'md' ? (
199
- <Markdown>{content}</Markdown>
200
- ) : (
201
- <div className={styles.previewText} style={{ width: '100%' }}>
202
- {content}
203
- </div>
204
- )}
205
- </Flexbox>
206
- )}
173
+ <Flexbox className={styles.previewBox} style={{ maxHeight: 240 }}>
174
+ {fileType === 'md' ? (
175
+ <Markdown style={{ overflow: 'auto' }}>{content}</Markdown>
176
+ ) : (
177
+ <div className={styles.previewText} style={{ width: '100%' }}>
178
+ {content}
179
+ </div>
180
+ )}
181
+ </Flexbox>
207
182
  </Flexbox>
208
183
  );
209
184
  },
@@ -1,4 +1,5 @@
1
1
  import { LocalSystemApiName } from '../index';
2
+ import EditLocalFile from './EditLocalFile';
2
3
  import ListFiles from './ListFiles';
3
4
  import MoveLocalFiles from './MoveLocalFiles';
4
5
  import ReadLocalFile from './ReadLocalFile';
@@ -11,6 +12,7 @@ import WriteFile from './WriteFile';
11
12
  * Local System Render Components Registry
12
13
  */
13
14
  export const LocalSystemRenders = {
15
+ [LocalSystemApiName.editLocalFile]: EditLocalFile,
14
16
  [LocalSystemApiName.listLocalFiles]: ListFiles,
15
17
  [LocalSystemApiName.moveLocalFiles]: MoveLocalFiles,
16
18
  [LocalSystemApiName.readLocalFile]: ReadLocalFile,
@@ -206,6 +206,7 @@ export const LocalSystemManifest: BuiltinToolManifest = {
206
206
  {
207
207
  description:
208
208
  'Perform exact string replacements in files. Must read the file first before editing.',
209
+ humanIntervention: 'required',
209
210
  name: LocalSystemApiName.editLocalFile,
210
211
  parameters: {
211
212
  properties: {
@@ -1,5 +1,4 @@
1
1
  import {
2
- EditLocalFileResult,
3
2
  GetCommandOutputResult,
4
3
  GlobFilesResult,
5
4
  GrepContentResult,
@@ -85,6 +84,8 @@ export interface GlobFilesState {
85
84
 
86
85
  // Edit State
87
86
  export interface EditLocalFileState {
88
- message: string;
89
- result: EditLocalFileResult;
87
+ diffText?: string;
88
+ linesAdded?: number;
89
+ linesDeleted?: number;
90
+ replacements: number;
90
91
  }