@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.
- package/.github/workflows/desktop-pr-build.yml +7 -3
- package/CHANGELOG.md +50 -0
- package/apps/desktop/package.json +1 -0
- package/apps/desktop/src/main/controllers/LocalFileCtr.ts +55 -11
- package/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts +153 -0
- package/changelog/v1.json +18 -0
- package/locales/ar/chat.json +5 -0
- package/locales/ar/models.json +15 -0
- package/locales/ar/tool.json +12 -1
- package/locales/bg-BG/chat.json +5 -0
- package/locales/bg-BG/models.json +15 -0
- package/locales/bg-BG/tool.json +12 -1
- package/locales/de-DE/chat.json +5 -0
- package/locales/de-DE/models.json +15 -0
- package/locales/de-DE/tool.json +12 -1
- package/locales/en-US/models.json +15 -0
- package/locales/en-US/tool.json +12 -1
- package/locales/es-ES/chat.json +5 -0
- package/locales/es-ES/models.json +15 -0
- package/locales/es-ES/tool.json +12 -1
- package/locales/fa-IR/chat.json +5 -0
- package/locales/fa-IR/models.json +15 -0
- package/locales/fa-IR/tool.json +12 -1
- package/locales/fr-FR/chat.json +5 -0
- package/locales/fr-FR/models.json +15 -0
- package/locales/fr-FR/tool.json +12 -1
- package/locales/it-IT/chat.json +5 -0
- package/locales/it-IT/models.json +15 -0
- package/locales/it-IT/tool.json +12 -1
- package/locales/ja-JP/chat.json +5 -0
- package/locales/ja-JP/models.json +15 -0
- package/locales/ja-JP/tool.json +12 -1
- package/locales/ko-KR/chat.json +5 -0
- package/locales/ko-KR/models.json +15 -0
- package/locales/ko-KR/tool.json +12 -1
- package/locales/nl-NL/chat.json +5 -0
- package/locales/nl-NL/models.json +15 -0
- package/locales/nl-NL/tool.json +12 -1
- package/locales/pl-PL/chat.json +5 -0
- package/locales/pl-PL/models.json +15 -0
- package/locales/pl-PL/tool.json +12 -1
- package/locales/pt-BR/chat.json +5 -0
- package/locales/pt-BR/models.json +15 -0
- package/locales/pt-BR/tool.json +12 -1
- package/locales/ru-RU/chat.json +5 -0
- package/locales/ru-RU/models.json +15 -0
- package/locales/ru-RU/tool.json +12 -1
- package/locales/tr-TR/chat.json +5 -0
- package/locales/tr-TR/models.json +15 -0
- package/locales/tr-TR/tool.json +12 -1
- package/locales/vi-VN/chat.json +5 -0
- package/locales/vi-VN/models.json +15 -0
- package/locales/vi-VN/tool.json +12 -1
- package/locales/zh-CN/models.json +15 -0
- package/locales/zh-CN/tool.json +12 -1
- package/locales/zh-TW/chat.json +5 -0
- package/locales/zh-TW/models.json +15 -0
- package/locales/zh-TW/tool.json +12 -1
- package/package.json +2 -1
- package/packages/electron-client-ipc/src/types/localSystem.ts +4 -0
- package/scripts/prebuild.mts +15 -5
- package/src/app/[variants]/desktopRouter.config.tsx +0 -17
- package/src/app/[variants]/mobileRouter.config.tsx +0 -16
- package/src/app/[variants]/page.tsx +5 -4
- package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +23 -4
- package/src/locales/default/tool.ts +11 -0
- package/src/store/chat/slices/builtinTool/actions/__tests__/localSystem.test.ts +5 -6
- package/src/store/chat/slices/builtinTool/actions/localSystem.ts +45 -182
- package/src/tools/executionRuntimes.ts +3 -0
- package/src/tools/local-system/ExecutionRuntime/index.ts +407 -0
- package/src/tools/local-system/Intervention/EditLocalFile/index.tsx +89 -0
- package/src/tools/local-system/Intervention/WriteFile/index.tsx +72 -0
- package/src/tools/local-system/Intervention/index.ts +4 -0
- package/src/tools/local-system/Render/EditLocalFile/index.tsx +67 -0
- package/src/tools/local-system/Render/ReadLocalFile/ReadFileView.tsx +53 -78
- package/src/tools/local-system/Render/index.ts +2 -0
- package/src/tools/local-system/index.ts +1 -0
- 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,
|
|
5
|
-
import React, { memo
|
|
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
|
-
|
|
83
|
-
padding: 8px;
|
|
81
|
+
padding-block: 0;
|
|
82
|
+
padding-inline: 8px;
|
|
84
83
|
border-radius: 8px;
|
|
85
84
|
|
|
86
|
-
background: ${token.
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
89
|
-
|
|
87
|
+
diffText?: string;
|
|
88
|
+
linesAdded?: number;
|
|
89
|
+
linesDeleted?: number;
|
|
90
|
+
replacements: number;
|
|
90
91
|
}
|