@celljs/ta-workspace 4.8.0 → 4.9.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 (41) hide show
  1. package/README.md +2 -2
  2. package/README.zh-cn.md +2 -2
  3. package/package.json +13 -4
  4. package/web/index.js +913 -294
  5. package/web-src/browser-agent.ts +0 -440
  6. package/web-src/browser-common.tsx +0 -278
  7. package/web-src/browser-import.tsx +0 -126
  8. package/web-src/browser-webview.tsx +0 -270
  9. package/web-src/browser.tsx +0 -80
  10. package/web-src/common.tsx +0 -296
  11. package/web-src/editors.tsx +0 -471
  12. package/web-src/explorer.tsx +0 -717
  13. package/web-src/file-icon.tsx +0 -21
  14. package/web-src/host.ts +0 -121
  15. package/web-src/i18n.ts +0 -395
  16. package/web-src/index.tsx +0 -71
  17. package/web-src/open-files.tsx +0 -80
  18. package/web-src/preview.tsx +0 -132
  19. package/web-src/react.ts +0 -8
  20. package/web-src/scm.tsx +0 -388
  21. package/web-src/search.tsx +0 -485
  22. package/web-src/style.ts +0 -254
  23. package/web-src/terminal.tsx +0 -269
  24. package/web-src/util/browser-snapshot.spec.ts +0 -96
  25. package/web-src/util/browser-snapshot.ts +0 -225
  26. package/web-src/util/file-icon.spec.ts +0 -35
  27. package/web-src/util/file-icon.ts +0 -23
  28. package/web-src/util/git.ts +0 -203
  29. package/web-src/util/preview.spec.ts +0 -48
  30. package/web-src/util/preview.ts +0 -90
  31. package/web-src/util/search.spec.ts +0 -164
  32. package/web-src/util/search.ts +0 -274
  33. package/web-src/util/seti-font.ts +0 -6
  34. package/web-src/util/seti.ts +0 -761
  35. package/web-src/util/upload.spec.ts +0 -66
  36. package/web-src/util/upload.ts +0 -123
  37. package/web-src/util/workspace.spec.ts +0 -220
  38. package/web-src/util/workspace.ts +0 -396
  39. package/web-src/util/zip.spec.ts +0 -60
  40. package/web-src/util/zip.ts +0 -137
  41. package/web-src/workspace-client.ts +0 -221
@@ -1,21 +0,0 @@
1
- import type { WebIcon } from '@celljs/ta-web/lib/browser/extension/web-extension-api';
2
- // biome-ignore lint/style/useImportType: the JSX below is React.createElement
3
- import { React } from './react';
4
- import { FileIconUtil } from './util/file-icon';
5
-
6
- /** The icon of a file, drawn with the Seti font (style.ts) in the colors of the page's theme. */
7
- export function FileIcon({ path, size = 16 }: { path: string; size?: number | string }) {
8
- const [character, dark, light] = FileIconUtil.of(path);
9
- const box = typeof size === 'number' ? size : Number.parseFloat(size) || 16;
10
- const style = { width: box, height: box, fontSize: box * 1.25, '--taw-icon': dark, '--taw-icon-light': light } as React.CSSProperties;
11
- return (
12
- <span className="taw-file-icon" style={style} aria-hidden="true">
13
- {String.fromCharCode(character)}
14
- </span>
15
- );
16
- }
17
-
18
- /** The icon of a file for a tab of the workbench. */
19
- export function fileTabIcon(path: string): WebIcon {
20
- return ({ size }) => <FileIcon path={path} size={size} />;
21
- }
package/web-src/host.ts DELETED
@@ -1,121 +0,0 @@
1
- import type { WebExtensionAPI, WebIcon } from '@celljs/ta-web/lib/browser/extension/web-extension-api';
2
- import { React } from './react';
3
-
4
- /** The name of this package: the ids of its views are `<name>/<view>`. */
5
- export const PACKAGE = '@celljs/ta-workspace';
6
-
7
- /** The API ta gave the extension when it started. */
8
- export let pi: WebExtensionAPI;
9
-
10
- export function bindHost(api: WebExtensionAPI): void {
11
- pi = api;
12
- }
13
-
14
- export namespace Host {
15
- /** An icon of the page by its lucide name; a blank one when the page does not have it. */
16
- export function icon(name: string): WebIcon {
17
- return pi.ui.icons[name] ?? (() => null);
18
- }
19
-
20
- /** Errors of the server, as the user reads them. */
21
- export function message(error: unknown): string {
22
- return error instanceof Error ? error.message : String(error);
23
- }
24
- }
25
-
26
- /** A value that is read again when `deps` change; `reload` reads it again now. */
27
- export function useLoad<T>(load: () => Promise<T>, deps: unknown[]): { value?: T; error?: string; loading: boolean; reload(): void } {
28
- const [state, setState] = React.useState<{ value?: T; error?: string; loading: boolean }>({ loading: true });
29
- const [tick, setTick] = React.useState(0);
30
- React.useEffect(() => {
31
- let live = true;
32
- setState(previous => ({ ...previous, loading: true }));
33
- load().then(
34
- value => live && setState({ value, loading: false }),
35
- error => live && setState({ error: Host.message(error), loading: false }),
36
- );
37
- return () => {
38
- live = false;
39
- };
40
- }, [...deps, tick]);
41
- return { ...state, reload: React.useCallback(() => setTick(value => value + 1), []) };
42
- }
43
-
44
- /** Bumped when the agent changed files: a tool ran or a run ended. */
45
- export function useFilesChanged(): number {
46
- const [version, setVersion] = React.useState(0);
47
- React.useEffect(() => FilesChanged.subscribe(() => setVersion(value => value + 1)), []);
48
- return version;
49
- }
50
-
51
- /** A request one view makes of another (reveal a file, search a folder), kept until the view that takes it is there. */
52
- export class Channel<T> {
53
- protected pending?: T;
54
- protected readonly listeners = new Set<() => void>();
55
-
56
- send(value: T): void {
57
- this.pending = value;
58
- for (const listener of this.listeners) {
59
- listener();
60
- }
61
- }
62
-
63
- take(): T | undefined {
64
- const value = this.pending;
65
- this.pending = undefined;
66
- return value;
67
- }
68
-
69
- /** A React hook: `receive` gets each request, also one sent before the view was there. */
70
- useReceive(receive: (value: T) => void): void {
71
- const callback = React.useRef(receive);
72
- callback.current = receive;
73
- React.useEffect(() => {
74
- const deliver = () => {
75
- const value = this.take();
76
- if (value !== undefined) {
77
- callback.current(value);
78
- }
79
- };
80
- deliver();
81
- this.listeners.add(deliver);
82
- return () => {
83
- this.listeners.delete(deliver);
84
- };
85
- }, []);
86
- }
87
- }
88
-
89
- /** Whether the page runs on a Mac: the keys it names. */
90
- export const MAC = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);
91
-
92
- /** Whoever shows files hears when the agent may have changed them. */
93
- export namespace FilesChanged {
94
- const listeners = new Set<() => void>();
95
- let timer: ReturnType<typeof setTimeout> | undefined;
96
-
97
- export function subscribe(listener: () => void): () => void {
98
- listeners.add(listener);
99
- return () => listeners.delete(listener);
100
- }
101
-
102
- /** Many tools end at once: they count as one change. */
103
- export function notify(): void {
104
- clearTimeout(timer);
105
- timer = setTimeout(() => {
106
- for (const listener of listeners) {
107
- listener();
108
- }
109
- }, 300);
110
- }
111
- }
112
- /** The theme of the page, `light` or `dark`: what pi.ui.theme says, again when it changes. */
113
- export function useTheme(): string {
114
- const [theme, setTheme] = React.useState(() => pi.ui.theme);
115
- React.useEffect(() => {
116
- const observer = new MutationObserver(() => setTheme(pi.ui.theme));
117
- observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
118
- return () => observer.disconnect();
119
- }, []);
120
- return theme;
121
- }
package/web-src/i18n.ts DELETED
@@ -1,395 +0,0 @@
1
- import { pi } from './host';
2
-
3
- const ZH = {
4
- newFile: '新建文件…',
5
- newFolder: '新建文件夹…',
6
- rename: '重命名…',
7
- delete: '删除',
8
- open: '打开',
9
- copyPath: '复制路径',
10
- copyRelativePath: '复制相对路径',
11
- copied: '已复制',
12
- findInFolder: '在文件夹中查找…',
13
- revealInExplorer: '在资源管理器中显示',
14
- revealInFinder: '在 Finder 中显示',
15
- revealInFileExplorer: '在文件资源管理器中显示',
16
- openContainingFolder: '打开所在的文件夹',
17
- revealFailed: '无法在文件管理器中显示:{message}',
18
- uploadFiles: '上传文件…',
19
- uploadFolder: '上传文件夹…',
20
- download: '下载',
21
- uploading: '正在上传 {name}',
22
- uploaded: '已上传 {count} 个文件',
23
- uploadFailed: '上传失败:{message}',
24
- replaceTitle: '已存在 {names},要替换吗?',
25
- replaceMessage: '同名的文件会被上传的文件覆盖。',
26
- packing: '正在打包 {name}',
27
- downloadFailed: '下载失败:{message}',
28
- moveExists: '目标文件夹中已有“{name}”。',
29
- moveFailed: '移动失败:{message}',
30
- nameEmpty: '必须提供文件或文件夹名称。',
31
- nameSlash: '文件或文件夹名称不能以斜杠开头。',
32
- nameInvalid: '名称 {name} 不能用作文件或文件夹名称,请换一个。',
33
- nameExists: '此位置已存在文件或文件夹 {name},请换一个名称。',
34
- nameWhitespace: '文件或文件夹名称的开头或结尾有空格。',
35
- deleteFile: '确定要永久删除“{name}”吗?',
36
- deleteFolder: '确定要永久删除“{name}”及其内容吗?',
37
- irreversible: '此操作不可撤销!',
38
- createFailed: '创建失败:{message}',
39
- renameFailed: '重命名失败:{message}',
40
- deleteFailed: '删除失败:{message}',
41
- gitM: '已修改',
42
- gitA: '已添加',
43
- gitD: '已删除',
44
- gitR: '已重命名',
45
- gitC: '已复制',
46
- gitU: '未跟踪',
47
- gitT: '类型已更改',
48
- gitConflict: '冲突',
49
- matchWholeWord: '全字匹配',
50
- toggleReplace: '切换替换',
51
- replacePlaceholder: '替换',
52
- replace: '替换',
53
- replaceAll: '全部替换',
54
- replaceAllInFile: '在此文件中全部替换',
55
- replaceAllInFolder: '在此文件夹中全部替换',
56
- replaceAllTitle: '将 {files} 个文件中的 {count} 处匹配替换为“{text}”?',
57
- cannotReplace: '{path} 太大或不是文本,不能替换。',
58
- toggleDetails: '切换搜索详细信息',
59
- filesToInclude: '包含的文件',
60
- filesToExclude: '排除的文件',
61
- excludePlaceholder: '例如 *.test.ts, dist',
62
- dismiss: '关闭',
63
- clearResults: '清除搜索结果',
64
- expandAll: '全部展开',
65
- copy: '复制',
66
- mergeChanges: '合并更改',
67
- commit: '提交',
68
- commitMessage: '提交信息',
69
- commitPlaceholder: '消息(按 {keys} 提交)',
70
- commitPlaceholderBranch: '消息(按 {keys} 在“{branch}”提交)',
71
- commitMessageMissing: '请先写提交信息。',
72
- nothingToCommit: '没有可提交的更改。',
73
- stageAllTitle: '没有暂存的更改。要暂存全部更改并直接提交吗?',
74
- stageAllMessage: '会把工作区里所有更改(包括未跟踪的文件)加入这次提交。',
75
- stageAllCommit: '暂存全部并提交',
76
- stage: '暂存更改',
77
- unstage: '取消暂存更改',
78
- discard: '放弃更改',
79
- stageAll: '暂存所有更改',
80
- unstageAll: '取消暂存所有更改',
81
- discardAll: '放弃所有更改',
82
- discardOne: '确定要放弃“{name}”中的更改吗?',
83
- discardMany: '确定要放弃 {count} 个文件中的更改吗?',
84
- deleteUntracked: '确定要删除未跟踪的文件“{name}”吗?',
85
- deleteUntrackedMany: '确定要删除 {count} 个未跟踪的文件吗?',
86
- openChanges: '打开更改',
87
- openFile: '打开文件',
88
- pull: '拉取',
89
- push: '推送',
90
- fetch: '抓取',
91
- pullDone: '已拉取。',
92
- pushDone: '已推送。',
93
- fetchDone: '已抓取。',
94
- moreActions: '更多操作…',
95
- viewAsTree: '以树形式查看',
96
- viewAsList: '以列表形式查看',
97
- aheadBehind: '领先 {ahead},落后 {behind}',
98
- changes: '更改',
99
- changeCount: '{count} 处更改',
100
- previousChange: '上一个更改',
101
- nextChange: '下一个更改',
102
- inline: '内联视图',
103
- sideBySide: '并排视图',
104
- closeOthers: '关闭其他',
105
- closeToTheRight: '关闭下方的',
106
- closeToTheLeft: '关闭左侧',
107
- closeTabsToTheRight: '关闭右侧',
108
- closeEnded: '关闭已退出的',
109
- openCount: '{count} 个已打开',
110
- explorer: '资源管理器',
111
- openFiles: '打开的文件',
112
- search: '搜索',
113
- scm: '源代码管理',
114
- terminal: '终端',
115
- browser: '浏览器',
116
- refresh: '刷新',
117
- collapseAll: '全部折叠',
118
- changeFolder: '切换目录',
119
- followConversation: '回到对话的目录({name})',
120
- loading: '加载中…',
121
- empty: '空目录',
122
- noOpenFiles: '还没有打开的文件。在资源管理器、搜索或源代码管理里点一个文件。',
123
- close: '关闭',
124
- closeAll: '全部关闭',
125
- searchPlaceholder: '搜索',
126
- includePlaceholder: '例如 src/**/*.ts, *.md',
127
- matchCase: '区分大小写',
128
- useRegex: '使用正则表达式',
129
- noResults: '没有结果。',
130
- results: '{files} 个文件中有 {count} 个结果',
131
- moreResults: '结果太多,只显示前 {count} 个。',
132
- notRepository: '当前目录不是 git 仓库。',
133
- noChanges: '没有更改。',
134
- staged: '暂存的更改',
135
- ahead: '领先 {count}',
136
- behind: '落后 {count}',
137
- newTerminal: '新建终端',
138
- noTerminals: '没有打开的终端。',
139
- terminalEnded: '[进程已结束,退出码 {code}]',
140
- pipeMode: '服务器上没有 script,终端运行在管道上:全屏程序(vim、top)和密码输入不可用。',
141
- address: '输入网址或搜索',
142
- back: '后退',
143
- forward: '前进',
144
- openExternal: '在新窗口打开',
145
- recent: '最近访问',
146
- browserTitle: '在这里打开网页',
147
- browserHint: '输入网址或搜索,也可以打开本机的开发服务器。',
148
- home: '起始页',
149
- removeRecent: '从最近访问中移除',
150
- frameHint: '有的网站不允许被嵌入,页面空白时请在新窗口打开;Ta 桌面版没有这个限制。',
151
- stop: '停止',
152
- openBrowser: '在默认浏览器中打开',
153
- loadFailed: '无法打开这个网页',
154
- pageCrashed: '这个网页崩溃了',
155
- retry: '重试',
156
- agentDriving: 'Ta 正在操作',
157
- importSignIns: '导入浏览器的登录状态',
158
- importTitle: '导入登录状态',
159
- importHint: '把所选浏览器的 Cookie 复制到这里,你和 Agent 都能直接使用已登录的网站。不导入密码和浏览记录。',
160
- importFrom: '从哪个浏览器导入',
161
- noProfiles: '没有找到 Chrome、Edge、Brave、Arc、Vivaldi 或 Chromium 的个人资料。',
162
- importNow: '导入…',
163
- importing: '导入中…',
164
- imported: '已导入 {count} 个 Cookie',
165
- importSkipped: '{count} 个无法读取,已跳过。',
166
- importAppBound: '{count} 个受 Chrome 应用绑定加密保护,只能在网站上重新登录。',
167
- clearBrowserData: '清除内置浏览器数据',
168
- clearBrowserDataDetail: '删除内置浏览器的全部 Cookie、网站存储和缓存,网站都需要重新登录。',
169
- clear: '清除',
170
- cleared: '已清除内置浏览器数据',
171
- done: '完成',
172
- binary: '二进制文件,不显示内容({size})。',
173
- truncated: '文件较大,只显示前 1 MB,不能编辑。',
174
- line: '第 {line} 行',
175
- diffTitle: '{name}(更改)',
176
- stagedTitle: '{name}(已暂存)',
177
- unchanged: '内容相同。',
178
- skipped: '⋯ {count} 行未更改',
179
- failed: '出错了:{message}',
180
- preview: '预览',
181
- edit: '编辑',
182
- save: '保存',
183
- saveFailed: '保存失败:{message}',
184
- changedOnDisk: '文件已在磁盘上更改。',
185
- reload: '放弃我的更改',
186
- fit: '适应窗口',
187
- actualSize: '实际大小',
188
- };
189
-
190
- type Key = keyof typeof ZH;
191
-
192
- const EN: Record<Key, string> = {
193
- newFile: 'New File…',
194
- newFolder: 'New Folder…',
195
- rename: 'Rename…',
196
- delete: 'Delete',
197
- open: 'Open',
198
- copyPath: 'Copy Path',
199
- copyRelativePath: 'Copy Relative Path',
200
- copied: 'Copied',
201
- findInFolder: 'Find in Folder…',
202
- revealInExplorer: 'Reveal in Explorer',
203
- revealInFinder: 'Reveal in Finder',
204
- revealInFileExplorer: 'Reveal in File Explorer',
205
- openContainingFolder: 'Open Containing Folder',
206
- revealFailed: 'Could not show it in the file manager: {message}',
207
- uploadFiles: 'Upload Files…',
208
- uploadFolder: 'Upload Folder…',
209
- download: 'Download',
210
- uploading: 'Uploading {name}',
211
- uploaded: 'Uploaded {count} file(s)',
212
- uploadFailed: 'Could not upload: {message}',
213
- replaceTitle: '{names} already exists. Replace it?',
214
- replaceMessage: 'Files of the same name are overwritten by the uploaded ones.',
215
- packing: 'Packing {name}',
216
- downloadFailed: 'Could not download: {message}',
217
- moveExists: '{name} already exists in the folder.',
218
- moveFailed: 'Could not move: {message}',
219
- nameEmpty: 'A file or folder name must be provided.',
220
- nameSlash: 'A file or folder name cannot start with a slash.',
221
- nameInvalid: 'The name {name} is not valid as a file or folder name. Please choose a different name.',
222
- nameExists: 'A file or folder {name} already exists at this location. Please choose a different name.',
223
- nameWhitespace: 'Leading or trailing whitespace detected in file or folder name.',
224
- deleteFile: "Are you sure you want to permanently delete '{name}'?",
225
- deleteFolder: "Are you sure you want to permanently delete '{name}' and its contents?",
226
- irreversible: 'This action is irreversible!',
227
- createFailed: 'Could not create it: {message}',
228
- renameFailed: 'Could not rename it: {message}',
229
- deleteFailed: 'Could not delete it: {message}',
230
- gitM: 'Modified',
231
- gitA: 'Added',
232
- gitD: 'Deleted',
233
- gitR: 'Renamed',
234
- gitC: 'Copied',
235
- gitU: 'Untracked',
236
- gitT: 'Type changed',
237
- gitConflict: 'Conflict',
238
- matchWholeWord: 'Match Whole Word',
239
- toggleReplace: 'Toggle Replace',
240
- replacePlaceholder: 'Replace',
241
- replace: 'Replace',
242
- replaceAll: 'Replace All',
243
- replaceAllInFile: 'Replace All in File',
244
- replaceAllInFolder: 'Replace All in Folder',
245
- replaceAllTitle: "Replace {count} occurrences across {files} files with '{text}'?",
246
- cannotReplace: '{path} is too large or not text; it cannot be replaced in.',
247
- toggleDetails: 'Toggle Search Details',
248
- filesToInclude: 'files to include',
249
- filesToExclude: 'files to exclude',
250
- excludePlaceholder: 'e.g. *.test.ts, dist',
251
- dismiss: 'Dismiss',
252
- clearResults: 'Clear Search Results',
253
- expandAll: 'Expand All',
254
- copy: 'Copy',
255
- mergeChanges: 'Merge Changes',
256
- commit: 'Commit',
257
- commitMessage: 'Commit message',
258
- commitPlaceholder: 'Message ({keys} to commit)',
259
- commitPlaceholderBranch: "Message ({keys} to commit on '{branch}')",
260
- commitMessageMissing: 'Write a commit message first.',
261
- nothingToCommit: 'There are no changes to commit.',
262
- stageAllTitle: 'There are no staged changes to commit. Stage all your changes and commit them directly?',
263
- stageAllMessage: 'All the changes of the working tree, untracked files too, go into the commit.',
264
- stageAllCommit: 'Stage All and Commit',
265
- stage: 'Stage Changes',
266
- unstage: 'Unstage Changes',
267
- discard: 'Discard Changes',
268
- stageAll: 'Stage All Changes',
269
- unstageAll: 'Unstage All Changes',
270
- discardAll: 'Discard All Changes',
271
- discardOne: "Are you sure you want to discard changes in '{name}'?",
272
- discardMany: 'Are you sure you want to discard changes in {count} files?',
273
- deleteUntracked: "Are you sure you want to DELETE the untracked file '{name}'?",
274
- deleteUntrackedMany: 'Are you sure you want to DELETE the {count} untracked files?',
275
- openChanges: 'Open Changes',
276
- openFile: 'Open File',
277
- pull: 'Pull',
278
- push: 'Push',
279
- fetch: 'Fetch',
280
- pullDone: 'Pulled.',
281
- pushDone: 'Pushed.',
282
- fetchDone: 'Fetched.',
283
- moreActions: 'More Actions…',
284
- viewAsTree: 'View as Tree',
285
- viewAsList: 'View as List',
286
- aheadBehind: '{ahead} ahead, {behind} behind',
287
- changes: 'Changes',
288
- changeCount: '{count} changes',
289
- previousChange: 'Previous Change',
290
- nextChange: 'Next Change',
291
- inline: 'Inline View',
292
- sideBySide: 'Side by Side View',
293
- closeOthers: 'Close Others',
294
- closeToTheRight: 'Close Below',
295
- closeToTheLeft: 'Close to the Left',
296
- closeTabsToTheRight: 'Close to the Right',
297
- closeEnded: 'Close Exited',
298
- openCount: '{count} open',
299
- explorer: 'Explorer',
300
- openFiles: 'Open files',
301
- search: 'Search',
302
- scm: 'Source control',
303
- terminal: 'Terminal',
304
- browser: 'Browser',
305
- refresh: 'Refresh',
306
- collapseAll: 'Collapse all',
307
- changeFolder: 'Change folder',
308
- followConversation: 'Back to the folder of the conversation ({name})',
309
- loading: 'Loading…',
310
- empty: 'Empty folder',
311
- noOpenFiles: 'No files are open. Click a file in the explorer, search or source control.',
312
- close: 'Close',
313
- closeAll: 'Close all',
314
- searchPlaceholder: 'Search',
315
- includePlaceholder: 'e.g. src/**/*.ts, *.md',
316
- matchCase: 'Match case',
317
- useRegex: 'Use regular expression',
318
- noResults: 'No results.',
319
- results: '{count} results in {files} files',
320
- moreResults: 'Too many results; the first {count} are shown.',
321
- notRepository: 'This folder is not a git repository.',
322
- noChanges: 'No changes.',
323
- staged: 'Staged changes',
324
- ahead: '{count} ahead',
325
- behind: '{count} behind',
326
- newTerminal: 'New terminal',
327
- noTerminals: 'No terminals are open.',
328
- terminalEnded: '[The process ended with code {code}]',
329
- pipeMode: 'The server has no script: the terminal runs on pipes, so full-screen programs (vim, top) and password prompts do not work.',
330
- address: 'Enter an address or search',
331
- back: 'Back',
332
- forward: 'Forward',
333
- openExternal: 'Open in a new window',
334
- recent: 'Recent',
335
- browserTitle: 'Open a page here',
336
- browserHint: 'Enter an address or search, or open a dev server on this machine.',
337
- home: 'Start page',
338
- removeRecent: 'Remove from recent',
339
- frameHint: 'Some sites refuse to be embedded; if the page stays blank, open it in a new window. Ta Desktop has no such limit.',
340
- stop: 'Stop',
341
- openBrowser: 'Open in the default browser',
342
- loadFailed: 'This page did not open',
343
- pageCrashed: 'This page crashed',
344
- retry: 'Retry',
345
- agentDriving: 'Ta is working here',
346
- importSignIns: 'Import sign-ins from your browser',
347
- importTitle: 'Import sign-ins',
348
- importHint:
349
- 'Copies the cookies of the browser you pick here, so you and the agent use the sites you are signed in to. Passwords and history are not imported.',
350
- importFrom: 'Import from',
351
- noProfiles: 'No profile of Chrome, Edge, Brave, Arc, Vivaldi or Chromium was found.',
352
- importNow: 'Import…',
353
- importing: 'Importing…',
354
- imported: '{count} cookies imported',
355
- importSkipped: '{count} could not be read and were skipped.',
356
- importAppBound: "{count} are under Chrome's app-bound encryption: sign in again on those sites.",
357
- clearBrowserData: 'Clear browser data',
358
- clearBrowserDataDetail: 'Deletes every cookie, site storage and the cache of the browser of Ta: every site needs a sign-in again.',
359
- clear: 'Clear',
360
- cleared: 'Browser data cleared',
361
- done: 'Done',
362
- binary: 'A binary file; its content is not shown ({size}).',
363
- truncated: 'A large file: only the first 1 MB is shown, read-only.',
364
- line: 'Line {line}',
365
- diffTitle: '{name} (changes)',
366
- stagedTitle: '{name} (staged)',
367
- unchanged: 'The contents are the same.',
368
- skipped: '⋯ {count} unchanged lines',
369
- failed: 'Failed: {message}',
370
- preview: 'Preview',
371
- edit: 'Edit',
372
- save: 'Save',
373
- saveFailed: 'Could not save: {message}',
374
- changedOnDisk: 'The file changed on disk.',
375
- reload: 'Discard my changes',
376
- fit: 'Fit to window',
377
- actualSize: 'Actual size',
378
- };
379
-
380
- /** Words in the language of the page; `{name}` takes `vars.name`. */
381
- export function t(key: Key, vars: Record<string, string | number> = {}): string {
382
- const words = pi.ui.language === 'zh-CN' ? ZH : EN;
383
- return words[key].replace(/\{(\w+)\}/g, (all, name: string) => (name in vars ? String(vars[name]) : all));
384
- }
385
-
386
- /** The words of a letter of git (M, A, D, R, C, U, T, !), as VS Code names the states. */
387
- export function gitLabel(letter: string): string {
388
- const keys: Record<string, Key> = { M: 'gitM', A: 'gitA', D: 'gitD', R: 'gitR', C: 'gitC', U: 'gitU', T: 'gitT', '!': 'gitConflict' };
389
- return keys[letter] ? t(keys[letter]) : letter;
390
- }
391
-
392
- /** A label read again when the language changes. */
393
- export function label(key: Key): () => string {
394
- return () => t(key);
395
- }
package/web-src/index.tsx DELETED
@@ -1,71 +0,0 @@
1
- import type { WebExtensionAPI, WebLink } from '@celljs/ta-web/lib/browser/extension/web-extension-api';
2
- import { BrowserView } from './browser';
3
- import { AgentBrowser } from './browser-agent';
4
- import { ShowPage } from './browser-common';
5
- import { OpenFiles, openFile } from './editors';
6
- import { ExplorerView, ShowDirectory } from './explorer';
7
- import { bindHost, FilesChanged, Host, PACKAGE } from './host';
8
- import { label } from './i18n';
9
- import { OpenFilesView } from './open-files';
10
- import { bind } from './react';
11
- import { ScmView } from './scm';
12
- import { SearchView } from './search';
13
- import { injectStyle } from './style';
14
- import { Terminals, TerminalView } from './terminal';
15
- import { WorkspaceUtil } from './util/workspace';
16
-
17
- /** Links of replies: a file at its lines, a directory in the explorer, a page in the browser. */
18
- function openLink(pi: WebExtensionAPI, link: WebLink): boolean {
19
- if (link.type === 'file') {
20
- const selection = link.selection;
21
- openFile(
22
- link.cwd,
23
- link.path,
24
- selection && { line: selection.startLine, column: selection.startColumn, endLine: selection.endLine, endColumn: selection.endColumn },
25
- );
26
- } else if (link.type === 'directory') {
27
- ShowDirectory.send(WorkspaceUtil.absolute(link.cwd, link.path));
28
- pi.ui.showView(`${PACKAGE}/explorer`);
29
- } else {
30
- ShowPage.send(link.url);
31
- pi.ui.showView(`${PACKAGE}/browser`);
32
- }
33
- return true;
34
- }
35
-
36
- /**
37
- * The workspace of the conversation shown, as the tools of an IDE: its files, the files opened, a
38
- * search, the changes of git, terminals and a browser. Each is a `panel` view, a tool of the workbench
39
- * beside the conversation; files and diffs open as more of its tabs.
40
- */
41
- export default function activate(pi: WebExtensionAPI): () => void {
42
- bind(pi.React);
43
- bindHost(pi);
44
- const removeStyle = injectStyle();
45
- const views = [
46
- ['explorer', 'explorer', 'Files', ExplorerView],
47
- ['open-files', 'openFiles', 'FileText', OpenFilesView],
48
- ['search', 'search', 'Search', SearchView],
49
- ['scm', 'scm', 'GitBranch', ScmView],
50
- ['terminal', 'terminal', 'SquareTerminal', TerminalView],
51
- ['browser', 'browser', 'Globe', BrowserView],
52
- ] as const;
53
- views.forEach(([name, title, icon, render], index) => {
54
- pi.registerView(name, { title: label(title), icon: Host.icon(icon), render, location: 'panel', order: 10 + index * 10 });
55
- });
56
- // The agent changes files with its tools: what is shown is read again.
57
- pi.on('tool_execution_end', () => FilesChanged.notify());
58
- pi.on('agent_end', () => FilesChanged.notify());
59
- pi.registerOpener(link => openLink(pi, link));
60
- // The agent works the browser in Ta Desktop only, where the app gives the page the DevTools protocol.
61
- if (pi.ui.debugWebview) {
62
- pi.registerTool(AgentBrowser.TOOL);
63
- }
64
- const stopTerminals = pi.onTerminalData((terminalId, data, exitCode) => Terminals.receive(terminalId, data, exitCode));
65
- // The files open when the page closed open again, behind what is shown.
66
- void OpenFiles.restore();
67
- return () => {
68
- stopTerminals();
69
- removeStyle();
70
- };
71
- }