@celljs/ta-workspace 4.7.0 → 4.8.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.
- package/README.md +5 -5
- package/README.zh-cn.md +6 -6
- package/package.json +3 -3
- package/web/index.js +1911 -634
- package/web-src/browser-agent.ts +440 -0
- package/web-src/browser-common.tsx +278 -0
- package/web-src/browser-import.tsx +126 -0
- package/web-src/browser-webview.tsx +270 -0
- package/web-src/browser.tsx +25 -220
- package/web-src/explorer.tsx +241 -3
- package/web-src/i18n.ts +77 -2
- package/web-src/index.tsx +7 -1
- package/web-src/style.ts +35 -6
- package/web-src/terminal.tsx +53 -134
- package/web-src/util/browser-snapshot.spec.ts +96 -0
- package/web-src/util/browser-snapshot.ts +225 -0
- package/web-src/util/upload.spec.ts +66 -0
- package/web-src/util/upload.ts +123 -0
- package/web-src/util/workspace.spec.ts +32 -13
- package/web-src/util/workspace.ts +42 -0
- package/web-src/util/zip.spec.ts +60 -0
- package/web-src/util/zip.ts +137 -0
- package/web-src/workspace-client.ts +103 -1
- package/web-src/util/ansi.spec.ts +0 -66
- package/web-src/util/ansi.ts +0 -438
- package/web-src/util/keys.ts +0 -56
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@ A pi package that comes with Ta: the workspace of the conversation shown, in the
|
|
|
4
4
|
|
|
5
5
|
| View | What it does |
|
|
6
6
|
| --- | --- |
|
|
7
|
-
| Explorer | The files of the conversation's directory, with the file icons of VS Code, the colors and letters of git (folders take the change inside them, ignored files are dimmed) and indent guides; it follows the tab shown. A click opens a file as a preview tab (the next preview takes its place), a double click keeps it: Markdown, HTML, images, videos, sounds and PDFs as a preview, the rest in Monaco (`pi.ui.CodeEditor`), saved with Ctrl+S or Cmd+S. New file and folder (`a/b.ts` makes the folders), rename and delete in place, with the checks of VS Code on names; a context menu with copy path and find in folder; the keys of a tree (arrows, Home/End, F2 or Enter on a Mac, Delete) |
|
|
7
|
+
| Explorer | The files of the conversation's directory, with the file icons of VS Code, the colors and letters of git (folders take the change inside them, ignored files are dimmed) and indent guides; it follows the tab shown. A click opens a file as a preview tab (the next preview takes its place), a double click keeps it: Markdown, HTML, images, videos, sounds and PDFs as a preview, the rest in Monaco (`pi.ui.CodeEditor`), saved with Ctrl+S or Cmd+S. New file and folder (`a/b.ts` makes the folders), rename and delete in place, with the checks of VS Code on names; a context menu with copy path and relative path, find in folder, upload files or a folder, and download (a folder as a zip made in the page); in Ta Desktop, reveal in Finder (File Explorer on Windows, the file manager on Linux) for directories of this machine (`pi.ui.desktop`). Drag an item onto a folder to move it there (a closed folder opens while it is held over it), files or folders of the system onto the tree to upload them, and an item onto the message box (an `@` reference) or a terminal (its path) (`pi.ui.fileDrag`); the keys of a tree (arrows, Home/End, F2 or Enter on a Mac, Delete) |
|
|
8
8
|
| Open files | The tabs of files and changes this package opened, the one shown marked; close, close others, close below, reveal in the explorer |
|
|
9
9
|
| Search | Text in the files (ripgrep, git grep or grep, whichever the machine has): match case, whole word, a regular expression (its error shown), files to include and to exclude (globs separated by commas, a folder takes all inside it); each match of a line is a result, which opens the file selected on it. Replace one, in a file or all (with `$1` for a group), the change shown on each result; dismiss results (a file or a folder); collapse and expand all; the results as a list or a tree of folders |
|
|
10
10
|
| Source control | The branch with what it is ahead and behind, a box for the commit message (Ctrl+Enter or Cmd+Enter; with nothing staged it offers to stage all), merge changes, staged changes and changes, as a list or a tree; stage, unstage and discard a file or a group (discarding asks; for an untracked file it deletes), pull, push and fetch. A change opens in Monaco's diff editor, side by side or inline, the unchanged lines folded; a change not staged can be edited there and saved |
|
|
11
|
-
| Terminal | Shells on the machine of the session, in one tab; the first opens with it; they survive a dropped connection for 30 s |
|
|
12
|
-
| Browser | A page in its tab, such as the dev server the agent started: back, forward, reload and the address in one bar, a line while the page loads; a start page with the addresses opened lately (remove one with its ×), or the ports dev servers take when there are none yet. A page of the origin of Ta itself runs without `allow-same-origin`, so it cannot reach the page or its token. In a directory of another machine (`ssh://`), a page of its `localhost` is that machine's: its port is opened on the machine of `ta serve` (`pi.remote.forwardPort`), and the bar keeps the address as typed |
|
|
11
|
+
| Terminal | Shells on the machine of the session, in one tab; the first opens with it; they survive a dropped connection for 30 s. Files dragged from the explorer are typed as their paths, quoted for the shell |
|
|
12
|
+
| Browser | A page in its tab, such as the dev server the agent started: back, forward, reload and the address in one bar, a line while the page loads; a start page with the addresses opened lately (remove one with its ×), or the ports dev servers take when there are none yet. A page of the origin of Ta itself runs without `allow-same-origin`, so it cannot reach the page or its token. In a directory of another machine (`ssh://`), a page of its `localhost` is that machine's: its port is opened on the machine of `ta serve` (`pi.remote.forwardPort`), and the bar keeps the address as typed. In Ta Desktop (`pi.ui.supportsWebview`) the page is a `<webview>` instead of a frame: sites cannot refuse it, signing in works and stays (a partition of its own), back and forward follow the page, the bar shows its title and icon and stops a load, a failed load or a crashed page says so with a retry, and the context menu, browser shortcuts and DevTools are the app's. There the agent works the same page with the `browser` tool (`pi.ui.debugWebview`): navigate, back, forward, reload; a snapshot of the accessibility tree whose elements carry refs; click, type, press, scroll; a screenshot (a data URL for codemode's `image()`); evaluate, wait, and any command of the DevTools protocol on the page. Refs hold for the page of the last snapshot only. The view comes up while the agent works it and the bar says so; text goes in without the keyboard focus, and a click or a key gives the focus back to where the user was typing. The start page offers to import sign-ins (`pi.ui.desktop.browserData`, macOS and Windows): the user picks a profile of Chrome, Edge, Brave, Arc, Vivaldi or Chromium, says yes in a dialog of the app, and its cookies come over; passwords and history do not. The same dialog clears the data of the browser |
|
|
13
13
|
|
|
14
|
-
Each view is a `panel` view of its web extension, opened from the `+` of the workbench or its empty state (`pi.web` of `package.json`); the work runs on the server through `pi.workspace` (`listDirectory`, `readFile`, `writeFile`, `fileUrl`, `runCommand`, …) and `pi.terminals`, in the execution environment of the directory, so a remote `ta exec-server` works the same. Search, source control and the changes to files are this package's: it runs `rg` (or `git grep`, or `grep`), `git`, `mkdir`, `mv -n` and `rm` with `runCommand` and reads their output; paths go to git as `:(literal)` pathspecs. Paths may not leave the directory. What the agent changes with its tools shows at once.
|
|
14
|
+
Each view is a `panel` view of its web extension, opened from the `+` of the workbench or its empty state (`pi.web` of `package.json`); the work runs on the server through `pi.workspace` (`listDirectory`, `readFile`, `writeFile`, `uploadFile`, `fileUrl`, `runCommand`, …) and `pi.terminals`, in the execution environment of the directory, so a remote `ta exec-server` works the same. Search, source control and the changes to files are this package's: it runs `rg` (or `git grep`, or `grep`), `git`, `mkdir`, `mv -n` and `rm` with `runCommand` and reads their output; paths go to git as `:(literal)` pathspecs. Paths may not leave the directory. What the agent changes with its tools shows at once.
|
|
15
15
|
|
|
16
|
-
Files open in Monaco, which the page brings (`pi.ui.CodeEditor`, bundled with Ta, no network); Markdown, HTML, SVG open as a preview first, with Edit beside Preview. Previews load the file from `TaWorkspaceServer.fileUrl`: a page runs sandboxed in an origin of its own, Markdown (rendered with marked, bundled in) runs no scripts, and both load the files beside them with relative URLs. Diffs open in Monaco's diff editor (`pi.ui.DiffEditor`), terminals are
|
|
16
|
+
Files open in Monaco, which the page brings (`pi.ui.CodeEditor`, bundled with Ta, no network); Markdown, HTML, SVG open as a preview first, with Edit beside Preview. Previews load the file from `TaWorkspaceServer.fileUrl`: a page runs sandboxed in an origin of its own, Markdown (rendered with marked, bundled in) runs no scripts, and both load the files beside them with relative URLs. Diffs open in Monaco's diff editor (`pi.ui.DiffEditor`), terminals are xterm.js, as in VS Code (`pi.ui.createTerminal`: drawn with WebGL, in the theme of the page; Cmd or Ctrl + click opens the URLs and the paths of files they print, at the line a compiler or grep names). The file icons are the Seti icons VS Code shows by default (font and map from `extensions/theme-seti` of microsoft/vscode, MIT; `bun scripts/seti.ts` writes them again into `web-src/util/seti*.ts`). With `script` on the server a shell gets a pseudo-terminal; without it, it runs on pipes and the server echoes and edits the line.
|
|
17
17
|
|
|
18
18
|
Links of replies open here (`pi.registerOpener`): a file as its tab, with the lines the link names selected (`src/a.ts#L10-L20`, `src/a.ts:10:5`), even a file open with changes, which keeps them; a directory in the explorer, which switches to it; a page in the browser. Cmd or Ctrl + click opens a page in the browser of the system instead, which Ta does itself.
|
|
19
19
|
|
package/README.zh-cn.md
CHANGED
|
@@ -4,16 +4,16 @@ Ta 自带的 pi 包:`ta serve` 的 web 客户端中会话的工作区,以 ID
|
|
|
4
4
|
|
|
5
5
|
| 视图 | 功能 |
|
|
6
6
|
| --- | --- |
|
|
7
|
-
| 资源管理器 | 会话目录的文件,带有 VS Code 的文件图标、git 的颜色和字母(文件夹显示其内部的更改,被忽略的文件变暗)并缩进指南;它遵循显示的标签页。单击打开文件作为预览标签页(下一个预览替换它),双击保留它:Markdown、HTML、图像、视频、声音和 PDF 作为预览,其余的在 Monaco(`pi.ui.CodeEditor`)中,用 Ctrl+S 或 Cmd+S 保存。新建文件和文件夹(`a/b.ts` 创建文件夹)、就地重命名和删除,带有 VS Code
|
|
7
|
+
| 资源管理器 | 会话目录的文件,带有 VS Code 的文件图标、git 的颜色和字母(文件夹显示其内部的更改,被忽略的文件变暗)并缩进指南;它遵循显示的标签页。单击打开文件作为预览标签页(下一个预览替换它),双击保留它:Markdown、HTML、图像、视频、声音和 PDF 作为预览,其余的在 Monaco(`pi.ui.CodeEditor`)中,用 Ctrl+S 或 Cmd+S 保存。新建文件和文件夹(`a/b.ts` 创建文件夹)、就地重命名和删除,带有 VS Code 的名称检查;右键菜单有复制路径和相对路径、在文件夹中查找、上传文件或文件夹、下载(文件夹在页面里打包成 zip);在 Ta 桌面版里,本机目录还可以在 Finder 中显示(Windows 上是文件资源管理器,Linux 上是文件管理器,`pi.ui.desktop`)。把一项拖到文件夹上即移到那里(悬停在关着的文件夹上会展开),把系统里的文件或文件夹拖进树里即上传,拖到输入框成为 `@` 引用、拖到终端输入它的路径(`pi.ui.fileDrag`);树的按键(箭头、Home/End、F2 或 Mac 上的 Enter、Delete) |
|
|
8
8
|
| 打开的文件 | 此包打开的文件和更改的标签页,显示的被标记;关闭、关闭其他、关闭下方、在资源管理器中显示 |
|
|
9
9
|
| 搜索 | 文件中的文本(ripgrep、git grep 或 grep,机器有哪个就用哪个):匹配大小写、全词、正则表达式(其错误显示)、要包含和排除的文件(逗号分隔的 glob,一个文件夹包含其内部所有文件);一行的每个匹配都是一个结果,在它上面打开选中的文件。替换一个、在一个文件中或全部(用 `$1` 表示组),变更显示在每个结果上;关闭结果(一个文件或文件夹);全部折叠和展开;结果作为列表或文件夹树 |
|
|
10
10
|
| 源代码管理 | 分支及其领先和落后的情况,提交消息的框(Ctrl+Enter 或 Cmd+Enter;没有暂存任何东西时提供暂存全部),合并变更、暂存的变更和变更,作为列表或树;暂存、取消暂存和放弃一个文件或组(放弃询问;对于未跟踪的文件它删除)、拉取、推送和获取。不暂存的变更在 Monaco 的 diff 编辑器中打开,并排或内联,未更改的行折叠;不暂存的变更可以在那里编辑并保存 |
|
|
11
|
-
| 终端 | 会话机器上的 shell,在一个标签页中;第一个与它一起打开;它们在丢失连接后存活 30
|
|
12
|
-
| 浏览器 | 其标签页中的页面,例如 agent 启动的开发服务器:后退、前进、重新加载和一行中的地址,页面加载时的一条线;如果还没有的话,带有最近打开的地址(用其 × 删除一个)的起始页,或开发服务器采用的端口。Ta 本身的来源的页面在没有 `allow-same-origin` 的情况下运行,因此无法到达页面或其令牌。在其他机器的目录里(`ssh://`),页面里的 `localhost` 是那台机器的:它的端口在 `ta serve` 所在的机器上打开(`pi.remote.forwardPort
|
|
11
|
+
| 终端 | 会话机器上的 shell,在一个标签页中;第一个与它一起打开;它们在丢失连接后存活 30 秒。从资源管理器拖进来的文件输入为它们的路径,按 shell 的规则加引号 |
|
|
12
|
+
| 浏览器 | 其标签页中的页面,例如 agent 启动的开发服务器:后退、前进、重新加载和一行中的地址,页面加载时的一条线;如果还没有的话,带有最近打开的地址(用其 × 删除一个)的起始页,或开发服务器采用的端口。Ta 本身的来源的页面在没有 `allow-same-origin` 的情况下运行,因此无法到达页面或其令牌。在其他机器的目录里(`ssh://`),页面里的 `localhost` 是那台机器的:它的端口在 `ta serve` 所在的机器上打开(`pi.remote.forwardPort`),地址栏保留输入的地址。在 Ta 桌面版里(`pi.ui.supportsWebview`),页面是 `<webview>` 而不是 iframe:网站不能拒绝被打开,登录可用且会保留(独立分区),后退前进跟随页面,地址栏显示标题和图标、加载中可停止,加载失败或页面崩溃时提示并可重试,右键菜单、浏览器快捷键和开发者工具由应用提供。Agent 在那里用 `browser` 工具(`pi.ui.debugWebview`)操作同一个网页:打开、后退、前进、刷新;读取无障碍树快照,可操作的元素带编号(ref);点击、输入、按键、滚动;截图(数据 URL,交给 codemode 的 `image()`);执行脚本、等待,以及任意只作用于该网页的 DevTools 协议命令。编号只对最近一次快照所在的页面有效。Agent 操作时浏览器会显示出来,地址栏旁标明“Ta 正在操作”;输入文字不占用键盘焦点,点击或按键之后焦点回到用户原来输入的地方。起始页可以导入登录状态(`pi.ui.desktop.browserData`,macOS 和 Windows):选择 Chrome、Edge、Brave、Arc、Vivaldi 或 Chromium 的一个个人资料,在应用的原生对话框里确认后复制它的 Cookie;不导入密码和浏览记录。同一个对话框里可以清除内置浏览器的数据 |
|
|
13
13
|
|
|
14
|
-
每个视图是其 web 扩展的 `panel` 视图,从工作台的 `+` 或其空状态打开(`pi.web` 的 `package.json`);工作通过 `pi.workspace`(`listDirectory`、`readFile`、`writeFile`、`fileUrl`、`runCommand` 等)和 `pi.terminals` 在目录的执行环境上运行,所以远程 `ta exec-server` 一样工作。搜索、源代码管理和对文件的更改是此包的:它用 `runCommand` 运行 `rg`(或 `git grep`,或 `grep`)、`git`、`mkdir`、`mv -n` 和 `rm` 并读取其输出;路径作为 `:(literal)` pathspec 传递给 git。路径不能离开目录。agent 用其工具所做的更改立即显示。
|
|
14
|
+
每个视图是其 web 扩展的 `panel` 视图,从工作台的 `+` 或其空状态打开(`pi.web` 的 `package.json`);工作通过 `pi.workspace`(`listDirectory`、`readFile`、`writeFile`、`uploadFile`、`fileUrl`、`runCommand` 等)和 `pi.terminals` 在目录的执行环境上运行,所以远程 `ta exec-server` 一样工作。搜索、源代码管理和对文件的更改是此包的:它用 `runCommand` 运行 `rg`(或 `git grep`,或 `grep`)、`git`、`mkdir`、`mv -n` 和 `rm` 并读取其输出;路径作为 `:(literal)` pathspec 传递给 git。路径不能离开目录。agent 用其工具所做的更改立即显示。
|
|
15
15
|
|
|
16
|
-
文件在 Monaco 中打开,页面带来(`pi.ui.CodeEditor`,与 Ta 打包,无网络);Markdown、HTML、SVG 首先作为预览打开,旁边有编辑。预览从 `TaWorkspaceServer.fileUrl` 加载文件:页面在其自己的原始地点沙箱化,Markdown(用 marked 呈现,打包在)不运行脚本,两个都用相对 URL 加载其旁边的文件。Diff 在 Monaco 的 diff 编辑器中打开(`pi.ui.DiffEditor
|
|
16
|
+
文件在 Monaco 中打开,页面带来(`pi.ui.CodeEditor`,与 Ta 打包,无网络);Markdown、HTML、SVG 首先作为预览打开,旁边有编辑。预览从 `TaWorkspaceServer.fileUrl` 加载文件:页面在其自己的原始地点沙箱化,Markdown(用 marked 呈现,打包在)不运行脚本,两个都用相对 URL 加载其旁边的文件。Diff 在 Monaco 的 diff 编辑器中打开(`pi.ui.DiffEditor`),终端是 xterm.js,与 VS Code 相同(`pi.ui.createTerminal`:WebGL 绘制,跟随页面主题;输出里的 URL 和文件路径按 Cmd 或 Ctrl + 点击打开,定位到编译器或 grep 给出的行)。文件图标是 VS Code 默认显示的 Seti 图标(字体和地图来自 microsoft/vscode 的 `extensions/theme-seti`,MIT;`bun scripts/seti.ts` 将它们再次写入 `web-src/util/seti*.ts`)。在服务器上用 `script` 时,shell 获得伪终端;没有它,它在管道上运行,服务器回显并编辑线。
|
|
17
17
|
|
|
18
18
|
回复的链接在这里打开(`pi.registerOpener`):文件作为其标签页,链接名称选中的行(`src/a.ts#L10-L20`、`src/a.ts:10:5`),甚至文件打开有更改,这保留它们;资源管理器中的目录,切换到它;浏览器中的页面。Cmd 或 Ctrl + 单击在系统的浏览器中打开页面,Ta 自己做。
|
|
19
19
|
|
|
@@ -26,4 +26,4 @@ bun run build # tsc -b,然后 bun build web-src/index.tsx → web/index.js
|
|
|
26
26
|
bun run test
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
web 扩展从页面获得 React(`web-src/react.ts`)和来自 `pi.ui.icons` 的图标:它在运行时不导入任何东西。要用已安装的 Ta 试用它,将包链接到 `~/.ta/agent/extensions/`。
|
|
29
|
+
web 扩展从页面获得 React(`web-src/react.ts`)和来自 `pi.ui.icons` 的图标:它在运行时不导入任何东西。要用已安装的 Ta 试用它,将包链接到 `~/.ta/agent/extensions/`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-workspace",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "A pi package for Ta: the workspace beside the conversation, with an explorer, open files, search, source control, terminals and a browser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@celljs/ta-protocol": "4.
|
|
29
|
-
"@celljs/ta-web": "4.
|
|
28
|
+
"@celljs/ta-protocol": "4.8.0",
|
|
29
|
+
"@celljs/ta-web": "4.8.0",
|
|
30
30
|
"@types/react": "^19.3.0",
|
|
31
31
|
"marked": "^14.0.0"
|
|
32
32
|
},
|