@celljs/ta-workspace 4.9.1 → 4.10.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 +1 -1
- package/README.zh-cn.md +1 -1
- package/package.json +3 -3
- package/web/index.js +235 -67
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ A pi package that comes with Ta: the workspace of the conversation shown, in the
|
|
|
13
13
|
|
|
14
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 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.
|
|
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 (`PAGE_SANDBOX`, never `allow-same-origin`), Markdown (rendered with marked, bundled in) runs no scripts, and both load the files beside them with relative URLs. Where the page is not served by ta serve — the app on a phone, a page through a relay — that URL is not there to load: pictures, videos, sounds and PDFs come as the bytes of `pi.files` in a `blob:` URL, and an HTML page is shown from the text of the file in a frame under a policy that reaches nothing (`PAGE_CSP`), so the css, js and pictures it loads by relative path do not come and a self-contained report shows as it is. 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
|
@@ -13,7 +13,7 @@ Ta 自带的 pi 包:`ta serve` 的 web 客户端中会话的工作区,以 ID
|
|
|
13
13
|
|
|
14
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`
|
|
16
|
+
文件在 Monaco 中打开,页面带来(`pi.ui.CodeEditor`,与 Ta 打包,无网络);Markdown、HTML、SVG 首先作为预览打开,旁边有编辑。预览从 `TaWorkspaceServer.fileUrl` 加载文件:页面在自己的源里沙箱化(`PAGE_SANDBOX`,绝不含 `allow-same-origin`),Markdown(用 marked 呈现,打包在)不运行脚本,两个都用相对 URL 加载其旁边的文件。页面不是由 ta serve 提供时——手机应用、经中继打开的页面——这个地址在页面里加载不到:图片、视频、声音和 PDF 用 `pi.files` 取字节做成 `blob:` 地址,HTML 页面按文件文本放进一个够不到任何东西的沙框里显示(`PAGE_CSP`),所以用相对路径加载的 css、js、图片不会来,自包含的报告页照原样显示。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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-workspace",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.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.10.0",
|
|
29
|
+
"@celljs/ta-web": "4.10.0",
|
|
30
30
|
"@types/react": "^19.3.0",
|
|
31
31
|
"marked": "^14.0.0"
|
|
32
32
|
},
|
package/web/index.js
CHANGED
|
@@ -185,39 +185,26 @@ function useContextMenu() {
|
|
|
185
185
|
const target = event.currentTarget;
|
|
186
186
|
const box = target.getBoundingClientRect();
|
|
187
187
|
const pointer = "clientX" in event && (event.clientX || event.clientY);
|
|
188
|
-
setMenu({ x:
|
|
188
|
+
setMenu(pointer ? { x: event.clientX, y: event.clientY, around: { top: box.top, bottom: box.bottom }, items } : { x: box.left + 16, y: box.bottom, items });
|
|
189
189
|
}, []);
|
|
190
|
+
const close = React.useCallback(() => setMenu(undefined), []);
|
|
190
191
|
const element = menu ? /* @__PURE__ */ React.createElement(ContextMenu, {
|
|
191
192
|
...menu,
|
|
192
|
-
onClose:
|
|
193
|
+
onClose: close
|
|
193
194
|
}) : null;
|
|
194
195
|
return [element, open];
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
-
const probe = document.createElement("div");
|
|
198
|
-
probe.style.cssText = "position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top)";
|
|
199
|
-
element.appendChild(probe);
|
|
200
|
-
const top = Number.parseFloat(getComputedStyle(probe).paddingTop) || 0;
|
|
201
|
-
probe.remove();
|
|
202
|
-
return top;
|
|
203
|
-
}
|
|
204
|
-
function ContextMenu({ x, y, items, onClose }) {
|
|
197
|
+
function ContextMenu({ x, y, around, items, onClose }) {
|
|
205
198
|
const root = React.useRef(null);
|
|
206
|
-
const [place, setPlace] = React.useState({ left: 0, top: 0, ready: false });
|
|
207
199
|
React.useLayoutEffect(() => {
|
|
208
200
|
const element = root.current;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const top = touch ? above >= safeTop + 4 ? above : clamp(y + 14, window.innerHeight - box.height) : y + box.height > window.innerHeight - 4 ? Math.max(4, y - box.height) : y;
|
|
217
|
-
setPlace({ left, top, ready: true });
|
|
218
|
-
}
|
|
219
|
-
root.current?.querySelector("button:not(:disabled)")?.focus();
|
|
220
|
-
}, [x, y]);
|
|
201
|
+
if (!element) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const stop = pi.ui.attachMenu(element, { x, y, around }, onClose);
|
|
205
|
+
element.querySelector("button:not(:disabled)")?.focus();
|
|
206
|
+
return stop;
|
|
207
|
+
}, [x, y, around, onClose]);
|
|
221
208
|
React.useEffect(() => {
|
|
222
209
|
const close = (event) => {
|
|
223
210
|
if (!root.current?.contains(event.target)) {
|
|
@@ -249,7 +236,6 @@ function ContextMenu({ x, y, items, onClose }) {
|
|
|
249
236
|
ref: root,
|
|
250
237
|
className: "taw-menu",
|
|
251
238
|
role: "menu",
|
|
252
|
-
style: { left: place.left, top: place.top, visibility: place.ready ? "visible" : "hidden" },
|
|
253
239
|
onKeyDown,
|
|
254
240
|
onContextMenu: (event) => event.preventDefault()
|
|
255
241
|
}, items.map((item, index) => item === "-" ? /* @__PURE__ */ React.createElement("hr", {
|
|
@@ -462,6 +448,7 @@ var ZH = {
|
|
|
462
448
|
closeTabsToTheRight: "关闭右侧",
|
|
463
449
|
closeEnded: "关闭已退出的",
|
|
464
450
|
openCount: "{count} 个已打开",
|
|
451
|
+
workbench: "工作台",
|
|
465
452
|
explorer: "资源管理器",
|
|
466
453
|
openFiles: "打开的文件",
|
|
467
454
|
search: "搜索",
|
|
@@ -547,9 +534,7 @@ var ZH = {
|
|
|
547
534
|
save: "保存",
|
|
548
535
|
saveFailed: "保存失败:{message}",
|
|
549
536
|
changedOnDisk: "文件已在磁盘上更改。",
|
|
550
|
-
reload: "放弃我的更改"
|
|
551
|
-
fit: "适应窗口",
|
|
552
|
-
actualSize: "实际大小"
|
|
537
|
+
reload: "放弃我的更改"
|
|
553
538
|
};
|
|
554
539
|
var EN = {
|
|
555
540
|
newFile: "New File…",
|
|
@@ -658,6 +643,7 @@ var EN = {
|
|
|
658
643
|
closeTabsToTheRight: "Close to the Right",
|
|
659
644
|
closeEnded: "Close Exited",
|
|
660
645
|
openCount: "{count} open",
|
|
646
|
+
workbench: "Workbench",
|
|
661
647
|
explorer: "Explorer",
|
|
662
648
|
openFiles: "Open files",
|
|
663
649
|
search: "Search",
|
|
@@ -743,9 +729,7 @@ var EN = {
|
|
|
743
729
|
save: "Save",
|
|
744
730
|
saveFailed: "Could not save: {message}",
|
|
745
731
|
changedOnDisk: "The file changed on disk.",
|
|
746
|
-
reload: "Discard my changes"
|
|
747
|
-
fit: "Fit to window",
|
|
748
|
-
actualSize: "Actual size"
|
|
732
|
+
reload: "Discard my changes"
|
|
749
733
|
};
|
|
750
734
|
function t(key, vars = {}) {
|
|
751
735
|
const words = pi.ui.language === "zh-CN" ? ZH : EN;
|
|
@@ -2417,6 +2401,37 @@ function BrowserView() {
|
|
|
2417
2401
|
return pi.ui.supportsWebview ? /* @__PURE__ */ React.createElement(WebviewBrowser, null) : /* @__PURE__ */ React.createElement(FrameBrowser, null);
|
|
2418
2402
|
}
|
|
2419
2403
|
|
|
2404
|
+
// web-src/bytes.ts
|
|
2405
|
+
function useFileBytesUrl(url, version) {
|
|
2406
|
+
const [state, setState] = React.useState({});
|
|
2407
|
+
React.useEffect(() => {
|
|
2408
|
+
if (!url) {
|
|
2409
|
+
setState({});
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
let live = true;
|
|
2413
|
+
let made;
|
|
2414
|
+
pi.files.read(url).then((file) => {
|
|
2415
|
+
if (!live) {
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
made = URL.createObjectURL(new Blob([file.data], { type: file.type }));
|
|
2419
|
+
setState({ url: made, size: file.size });
|
|
2420
|
+
}, (error) => {
|
|
2421
|
+
if (live) {
|
|
2422
|
+
setState({ error: Host.message(error) });
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
return () => {
|
|
2426
|
+
live = false;
|
|
2427
|
+
if (made) {
|
|
2428
|
+
URL.revokeObjectURL(made);
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
}, [url, version]);
|
|
2432
|
+
return state;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2420
2435
|
// web-src/util/seti.ts
|
|
2421
2436
|
var SETI_ICONS = [
|
|
2422
2437
|
[57379, "#d4d7d6", "#bfc2c1"],
|
|
@@ -5261,6 +5276,8 @@ var parser = _Parser.parse;
|
|
|
5261
5276
|
var lexer = _Lexer.lex;
|
|
5262
5277
|
|
|
5263
5278
|
// web-src/util/preview.ts
|
|
5279
|
+
var PAGE_SANDBOX = "allow-scripts allow-forms allow-popups";
|
|
5280
|
+
var PAGE_CSP = "default-src 'none'; script-src 'unsafe-inline' blob:; style-src 'unsafe-inline' blob:; img-src data: blob:; media-src data: blob:; font-src data:; form-action 'none'; connect-src 'none'";
|
|
5264
5281
|
var KINDS = {
|
|
5265
5282
|
md: "markdown",
|
|
5266
5283
|
markdown: "markdown",
|
|
@@ -5331,6 +5348,18 @@ var PreviewUtil;
|
|
|
5331
5348
|
return count ? `${base}-${count}` : base;
|
|
5332
5349
|
}
|
|
5333
5350
|
PreviewUtil.slug = slug;
|
|
5351
|
+
function pageDocument(html2) {
|
|
5352
|
+
const meta = `<meta http-equiv="Content-Security-Policy" content="${PAGE_CSP}">`;
|
|
5353
|
+
const head = /<head[^>]*>/i.exec(html2);
|
|
5354
|
+
if (head) {
|
|
5355
|
+
const at2 = head.index + head[0].length;
|
|
5356
|
+
return html2.slice(0, at2) + meta + html2.slice(at2);
|
|
5357
|
+
}
|
|
5358
|
+
const doctype = /<!doctype[^>]*>/i.exec(html2);
|
|
5359
|
+
const at = doctype ? doctype.index + doctype[0].length : 0;
|
|
5360
|
+
return html2.slice(0, at) + meta + html2.slice(at);
|
|
5361
|
+
}
|
|
5362
|
+
PreviewUtil.pageDocument = pageDocument;
|
|
5334
5363
|
function markdownDocument(body, style) {
|
|
5335
5364
|
return `<!doctype html><html><head><meta charset="utf-8"><style>${style}</style></head><body><article class="markdown">${body}</article></body></html>`;
|
|
5336
5365
|
}
|
|
@@ -5338,7 +5367,6 @@ var PreviewUtil;
|
|
|
5338
5367
|
})(PreviewUtil ||= {});
|
|
5339
5368
|
|
|
5340
5369
|
// web-src/preview.tsx
|
|
5341
|
-
var PAGE_SANDBOX = "allow-scripts allow-forms allow-popups allow-modals allow-downloads";
|
|
5342
5370
|
var MARKDOWN_SANDBOX = "allow-same-origin allow-popups allow-popups-to-escape-sandbox";
|
|
5343
5371
|
var LINKED = [
|
|
5344
5372
|
["img", "src"],
|
|
@@ -5410,32 +5438,35 @@ function MarkdownPreview({ text, url }) {
|
|
|
5410
5438
|
});
|
|
5411
5439
|
}
|
|
5412
5440
|
function ImagePreview({ url, size, onInfo }) {
|
|
5413
|
-
|
|
5414
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
5415
|
-
className: `taw-preview-media taw-preview-image ${actual ? "taw-actual" : ""}`
|
|
5416
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
5417
|
-
type: "button",
|
|
5418
|
-
className: "taw-image-toggle",
|
|
5419
|
-
title: t(actual ? "fit" : "actualSize"),
|
|
5420
|
-
onClick: () => setActual((value) => !value)
|
|
5421
|
-
}, /* @__PURE__ */ React.createElement("img", {
|
|
5441
|
+
return /* @__PURE__ */ React.createElement(pi.ui.ImageViewer, {
|
|
5422
5442
|
src: url,
|
|
5423
|
-
|
|
5424
|
-
onLoad: (
|
|
5425
|
-
|
|
5426
|
-
onInfo(`${image.naturalWidth} × ${image.naturalHeight} · ${WorkspaceUtil.size(size)}`);
|
|
5427
|
-
}
|
|
5428
|
-
})));
|
|
5443
|
+
className: "taw-preview-image",
|
|
5444
|
+
onLoad: (image) => onInfo(`${image.width} × ${image.height} · ${WorkspaceUtil.size(size)}`)
|
|
5445
|
+
});
|
|
5429
5446
|
}
|
|
5430
|
-
function
|
|
5447
|
+
function PagePreview({ url, text }) {
|
|
5448
|
+
if (url) {
|
|
5449
|
+
return /* @__PURE__ */ React.createElement("iframe", {
|
|
5450
|
+
className: "taw-preview-frame taw-preview-page",
|
|
5451
|
+
title: "HTML",
|
|
5452
|
+
sandbox: PAGE_SANDBOX,
|
|
5453
|
+
src: url
|
|
5454
|
+
});
|
|
5455
|
+
}
|
|
5456
|
+
return /* @__PURE__ */ React.createElement("iframe", {
|
|
5457
|
+
className: "taw-preview-frame taw-preview-page",
|
|
5458
|
+
title: "HTML",
|
|
5459
|
+
sandbox: PAGE_SANDBOX,
|
|
5460
|
+
srcDoc: PreviewUtil.pageDocument(text)
|
|
5461
|
+
});
|
|
5462
|
+
}
|
|
5463
|
+
function MediaPreview({
|
|
5464
|
+
kind,
|
|
5465
|
+
url,
|
|
5466
|
+
size,
|
|
5467
|
+
onInfo
|
|
5468
|
+
}) {
|
|
5431
5469
|
switch (kind) {
|
|
5432
|
-
case "html":
|
|
5433
|
-
return /* @__PURE__ */ React.createElement("iframe", {
|
|
5434
|
-
className: "taw-preview-frame taw-preview-page",
|
|
5435
|
-
title: "HTML",
|
|
5436
|
-
sandbox: PAGE_SANDBOX,
|
|
5437
|
-
src: url
|
|
5438
|
-
});
|
|
5439
5470
|
case "pdf":
|
|
5440
5471
|
return /* @__PURE__ */ React.createElement("iframe", {
|
|
5441
5472
|
className: "taw-preview-frame",
|
|
@@ -5604,6 +5635,21 @@ var TaLocation;
|
|
|
5604
5635
|
return name || (remote === null || remote === undefined ? undefined : remote.host) || location2;
|
|
5605
5636
|
}
|
|
5606
5637
|
TaLocation2.basename = basename;
|
|
5638
|
+
function homeRelative(location2) {
|
|
5639
|
+
var _a;
|
|
5640
|
+
const remote = parse(location2);
|
|
5641
|
+
const path2 = remote ? remote.path ? remote.path.slice(1) : "~" : location2;
|
|
5642
|
+
const match = /^~(?:[\\/]+(.*))?$/.exec(path2);
|
|
5643
|
+
return match ? ((_a = match[1]) !== null && _a !== undefined ? _a : "").replace(/[\\/]+$/, "") : undefined;
|
|
5644
|
+
}
|
|
5645
|
+
TaLocation2.homeRelative = homeRelative;
|
|
5646
|
+
function isAbsolute(location2) {
|
|
5647
|
+
if (homeRelative(location2) !== undefined) {
|
|
5648
|
+
return false;
|
|
5649
|
+
}
|
|
5650
|
+
return isRemote(location2) || /^([\\/]|[A-Za-z]:)/.test(location2);
|
|
5651
|
+
}
|
|
5652
|
+
TaLocation2.isAbsolute = isAbsolute;
|
|
5607
5653
|
function parentPath(path2) {
|
|
5608
5654
|
const trimmed = path2.replace(/[\\/]+$/, "");
|
|
5609
5655
|
const at = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
|
|
@@ -5670,6 +5716,37 @@ ${message}`;
|
|
|
5670
5716
|
}
|
|
5671
5717
|
TaMessageContext2.strip = strip;
|
|
5672
5718
|
})(TaMessageContext || (TaMessageContext = {}));
|
|
5719
|
+
var TaImageNote;
|
|
5720
|
+
(function(TaImageNote2) {
|
|
5721
|
+
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
5722
|
+
function strip(text) {
|
|
5723
|
+
const lines = text.split(`
|
|
5724
|
+
`);
|
|
5725
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
5726
|
+
if (kept.length === lines.length) {
|
|
5727
|
+
return text;
|
|
5728
|
+
}
|
|
5729
|
+
return kept.join(`
|
|
5730
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
5731
|
+
}
|
|
5732
|
+
TaImageNote2.strip = strip;
|
|
5733
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
5734
|
+
var TaAgentSummary;
|
|
5735
|
+
(function(TaAgentSummary2) {
|
|
5736
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
5737
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
5738
|
+
function read(text) {
|
|
5739
|
+
if (!START.test(text)) {
|
|
5740
|
+
return;
|
|
5741
|
+
}
|
|
5742
|
+
return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
5743
|
+
}
|
|
5744
|
+
TaAgentSummary2.read = read;
|
|
5745
|
+
function strip(text) {
|
|
5746
|
+
return text.replace(BLOCK, "");
|
|
5747
|
+
}
|
|
5748
|
+
TaAgentSummary2.strip = strip;
|
|
5749
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
5673
5750
|
var TaSkillUse;
|
|
5674
5751
|
(function(TaSkillUse2) {
|
|
5675
5752
|
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
@@ -6520,6 +6597,9 @@ function FileEditor({ id, cwd, path }) {
|
|
|
6520
6597
|
const file = useLoad(async () => textual ? pi.workspace.readFile(path, cwd) : undefined, [cwd, path, changed]);
|
|
6521
6598
|
const url = useLoad(() => kind ? pi.workspace.fileUrl(path, cwd) : Promise.resolve(undefined), [cwd, path]);
|
|
6522
6599
|
const { version, size } = useVersion(kind && kind !== "markdown" ? url.value : undefined);
|
|
6600
|
+
const byUrl = pi.files.byUrl;
|
|
6601
|
+
const media = !byUrl && !!kind && kind !== "markdown" && kind !== "html";
|
|
6602
|
+
const bytes = useFileBytesUrl(media ? url.value : undefined, changed);
|
|
6523
6603
|
const [info, setInfo] = React.useState();
|
|
6524
6604
|
const [draft, setDraft] = React.useState();
|
|
6525
6605
|
const [base, setBase] = React.useState();
|
|
@@ -6595,6 +6675,7 @@ function FileEditor({ id, cwd, path }) {
|
|
|
6595
6675
|
onChange: setMode
|
|
6596
6676
|
}));
|
|
6597
6677
|
const fileUrl = url.value && PreviewUtil.versioned(url.value, version);
|
|
6678
|
+
const shownUrl = byUrl ? fileUrl : bytes.url;
|
|
6598
6679
|
return /* @__PURE__ */ React.createElement("div", {
|
|
6599
6680
|
className: "taw-editor"
|
|
6600
6681
|
}, /* @__PURE__ */ React.createElement(Header, {
|
|
@@ -6603,13 +6684,18 @@ function FileEditor({ id, cwd, path }) {
|
|
|
6603
6684
|
}), showPreview && fileUrl && kind === "markdown" && /* @__PURE__ */ React.createElement(MarkdownPreview, {
|
|
6604
6685
|
text: draft ?? text ?? "",
|
|
6605
6686
|
url: fileUrl
|
|
6606
|
-
}), showPreview &&
|
|
6607
|
-
|
|
6687
|
+
}), showPreview && kind === "html" && /* @__PURE__ */ React.createElement(PagePreview, {
|
|
6688
|
+
url: byUrl ? fileUrl : undefined,
|
|
6689
|
+
text: draft ?? text ?? ""
|
|
6690
|
+
}), showPreview && kind && kind !== "markdown" && kind !== "html" && shownUrl && /* @__PURE__ */ React.createElement(MediaPreview, {
|
|
6691
|
+
key: shownUrl,
|
|
6608
6692
|
kind,
|
|
6609
|
-
url:
|
|
6610
|
-
size: file.value?.size ?? size ?? 0,
|
|
6693
|
+
url: shownUrl,
|
|
6694
|
+
size: file.value?.size ?? bytes.size ?? size ?? 0,
|
|
6611
6695
|
onInfo: setInfo
|
|
6612
|
-
}),
|
|
6696
|
+
}), showPreview && kind && kind !== "markdown" && kind !== "html" && !shownUrl && /* @__PURE__ */ React.createElement(Message, {
|
|
6697
|
+
tone: bytes.error ? "error" : undefined
|
|
6698
|
+
}, bytes.error ?? t("loading")), !showPreview && /* @__PURE__ */ React.createElement(pi.ui.CodeEditor, {
|
|
6613
6699
|
path,
|
|
6614
6700
|
value: draft ?? text ?? "",
|
|
6615
6701
|
readOnly,
|
|
@@ -7835,6 +7921,47 @@ function Guides({ depth }) {
|
|
|
7835
7921
|
})));
|
|
7836
7922
|
}
|
|
7837
7923
|
|
|
7924
|
+
// web-src/launcher.tsx
|
|
7925
|
+
var TOOLS = [
|
|
7926
|
+
{ name: "explorer", icon: "Files" },
|
|
7927
|
+
{ name: "search", icon: "Search" },
|
|
7928
|
+
{ name: "scm", icon: "GitBranch" },
|
|
7929
|
+
{ name: "terminal", icon: "SquareTerminal" }
|
|
7930
|
+
];
|
|
7931
|
+
function showTool(name) {
|
|
7932
|
+
pi.ui.showView(`${PACKAGE}/${name}`);
|
|
7933
|
+
}
|
|
7934
|
+
function LauncherTools() {
|
|
7935
|
+
const cwd = pi.ui.useCwd();
|
|
7936
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
7937
|
+
className: "taw-launch"
|
|
7938
|
+
}, /* @__PURE__ */ React.createElement("header", {
|
|
7939
|
+
className: "taw-launch-head"
|
|
7940
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
7941
|
+
className: "taw-launch-label"
|
|
7942
|
+
}, t("workbench")), /* @__PURE__ */ React.createElement("span", {
|
|
7943
|
+
className: "taw-launch-cwd",
|
|
7944
|
+
title: cwd
|
|
7945
|
+
}, /* @__PURE__ */ React.createElement(Glyph, {
|
|
7946
|
+
name: "Folder",
|
|
7947
|
+
size: 13
|
|
7948
|
+
}), /* @__PURE__ */ React.createElement("span", null, WorkspaceUtil.basename(cwd)))), /* @__PURE__ */ React.createElement("div", {
|
|
7949
|
+
className: "taw-launch-row"
|
|
7950
|
+
}, TOOLS.map((tool) => /* @__PURE__ */ React.createElement("button", {
|
|
7951
|
+
key: tool.name,
|
|
7952
|
+
type: "button",
|
|
7953
|
+
className: `taw-launch-tile taw-launch-${tool.name}`,
|
|
7954
|
+
onClick: () => showTool(tool.name)
|
|
7955
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
7956
|
+
className: "taw-launch-icon"
|
|
7957
|
+
}, /* @__PURE__ */ React.createElement(Glyph, {
|
|
7958
|
+
name: tool.icon,
|
|
7959
|
+
size: 24
|
|
7960
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
7961
|
+
className: "taw-launch-name"
|
|
7962
|
+
}, t(tool.name))))));
|
|
7963
|
+
}
|
|
7964
|
+
|
|
7838
7965
|
// web-src/open-files.tsx
|
|
7839
7966
|
function close(files) {
|
|
7840
7967
|
for (const file of files) {
|
|
@@ -8297,7 +8424,7 @@ var STYLE = `
|
|
|
8297
8424
|
.taw-name-input .taw-input-message { position: absolute; z-index: 5; top: 100%; left: 0; right: 0; margin-top: 1px; box-shadow: var(--ta-shadow-pop); }
|
|
8298
8425
|
.taw-input-message.taw-error { background: color-mix(in srgb, var(--ta-red) 16%, var(--ta-card)); border: 1px solid var(--ta-red); color: var(--ta-text); }
|
|
8299
8426
|
.taw-input-message.taw-warning { background: color-mix(in srgb, var(--ta-yellow) 16%, var(--ta-card)); border: 1px solid var(--ta-yellow); color: var(--ta-text); }
|
|
8300
|
-
.taw-menu { position: fixed; z-index: 80; min-width: 210px; max-width: 320px; display: flex; flex-direction: column; gap: 1px; padding: 6px; border-radius: 12px; border: 1px solid var(--ta-border); background: var(--ta-side); box-shadow: var(--ta-shadow-pop); animation: taw-fade 100ms ease-out; }
|
|
8427
|
+
.taw-menu { position: fixed; left: 0; top: 0; z-index: 80; min-width: 210px; max-width: 320px; display: flex; flex-direction: column; gap: 1px; padding: 6px; border-radius: 12px; border: 1px solid var(--ta-border); background: var(--ta-side); box-shadow: var(--ta-shadow-pop); animation: taw-fade 100ms ease-out; }
|
|
8301
8428
|
.taw-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex: none; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); text-align: left; cursor: pointer; outline: none; }
|
|
8302
8429
|
.taw-menu-item:hover:not(:disabled), .taw-menu-item:focus-visible { background: var(--ta-hover); }
|
|
8303
8430
|
.taw-menu-item:disabled { opacity: 0.45; cursor: default; }
|
|
@@ -8425,12 +8552,6 @@ var STYLE = `
|
|
|
8425
8552
|
.taw-preview-media video { max-width: 100%; max-height: 100%; border-radius: 8px; background: #000; outline: none; }
|
|
8426
8553
|
.taw-preview-media audio { width: min(480px, 100%); }
|
|
8427
8554
|
.taw-preview-image { background-color: var(--ta-code); background-image: linear-gradient(45deg, var(--ta-chip) 25%, transparent 25%, transparent 75%, var(--ta-chip) 75%), linear-gradient(45deg, var(--ta-chip) 25%, transparent 25%, transparent 75%, var(--ta-chip) 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
|
|
8428
|
-
.taw-image-toggle { display: flex; align-items: center; justify-content: center; max-width: 100%; max-height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
|
|
8429
|
-
.taw-image-toggle:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: 2px; }
|
|
8430
|
-
.taw-preview-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
|
|
8431
|
-
.taw-preview-image.taw-actual { align-items: flex-start; justify-content: flex-start; }
|
|
8432
|
-
.taw-preview-image.taw-actual .taw-image-toggle { max-width: none; max-height: none; margin: auto; cursor: zoom-out; }
|
|
8433
|
-
.taw-preview-image.taw-actual img { max-width: none; max-height: none; }
|
|
8434
8555
|
.taw-message { padding: 16px; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
|
|
8435
8556
|
.taw-code { flex: 1; min-height: 0; overflow: auto; padding: 6px 0; background: var(--ta-code); font-family: var(--ta-mono); font-size: calc(12px * var(--ta-font-scale)); line-height: calc(20px * var(--ta-font-scale)); }
|
|
8436
8557
|
.taw-code-block { content-visibility: auto; }
|
|
@@ -8532,6 +8653,25 @@ var STYLE = `
|
|
|
8532
8653
|
:root[data-touch] .taw-terminal-tab-main { font-size: calc(13px * var(--ta-font-scale)); }
|
|
8533
8654
|
:root[data-touch] .taw-terminal-tab > .taw-action { width: 30px; height: 30px; }
|
|
8534
8655
|
:root[data-touch] .taw-terminal-tab:not(.taw-on) > .taw-action { display: none; }
|
|
8656
|
+
/* The tools of the workbench in the launcher, as the tiles of the launcher's own sections */
|
|
8657
|
+
.taw-launch { display: flex; flex-direction: column; }
|
|
8658
|
+
.taw-launch-head { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0 2px 10px; }
|
|
8659
|
+
.taw-launch-label { flex: 1; min-width: 0; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); line-height: calc(18px * var(--ta-font-scale)); font-weight: 500; }
|
|
8660
|
+
.taw-launch-cwd { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 55%; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
8661
|
+
.taw-launch-cwd > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
8662
|
+
.taw-launch-cwd > svg { flex: none; }
|
|
8663
|
+
.taw-launch-explorer { --taw-hue: 212; }
|
|
8664
|
+
.taw-launch-search { --taw-hue: 32; }
|
|
8665
|
+
.taw-launch-scm { --taw-hue: 152; }
|
|
8666
|
+
.taw-launch-terminal { --taw-hue: 262; }
|
|
8667
|
+
.taw-launch-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 -2px; }
|
|
8668
|
+
.taw-launch-tile { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; padding: 4px 2px; border: 0; border-radius: 14px; background: none; color: var(--ta-text); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; }
|
|
8669
|
+
.taw-launch-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: hsl(var(--taw-hue) 70% 94%); color: hsl(var(--taw-hue) 52% 36%); box-shadow: inset 0 0 0 1px hsl(var(--taw-hue) 40% 50% / 0.08); transition: transform 160ms var(--ta-ease), filter 160ms; }
|
|
8670
|
+
:root[data-theme='dark'] .taw-launch-icon { background: hsl(var(--taw-hue) 26% 21%); color: hsl(var(--taw-hue) 72% 76%); box-shadow: inset 0 0 0 1px hsl(var(--taw-hue) 40% 70% / 0.1); }
|
|
8671
|
+
.taw-launch-tile:hover .taw-launch-icon { filter: brightness(0.97); }
|
|
8672
|
+
.taw-launch-tile:active .taw-launch-icon { transform: scale(0.92); }
|
|
8673
|
+
.taw-launch-tile:focus-visible { outline: 1px solid var(--ta-border-focus); outline-offset: -1px; }
|
|
8674
|
+
.taw-launch-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ta-body); font-size: calc(12px * var(--ta-font-scale)); line-height: calc(16px * var(--ta-font-scale)); }
|
|
8535
8675
|
`;
|
|
8536
8676
|
function injectStyle() {
|
|
8537
8677
|
const element = document.createElement("style");
|
|
@@ -9181,6 +9321,23 @@ function TerminalEditor({
|
|
|
9181
9321
|
}));
|
|
9182
9322
|
}
|
|
9183
9323
|
|
|
9324
|
+
// web-src/util/keys.ts
|
|
9325
|
+
var WorkspaceKeys;
|
|
9326
|
+
((WorkspaceKeys) => {
|
|
9327
|
+
const LETTERS = { e: "explorer", f: "search", g: "scm" };
|
|
9328
|
+
function tool(event, mac) {
|
|
9329
|
+
if (event.altKey) {
|
|
9330
|
+
return;
|
|
9331
|
+
}
|
|
9332
|
+
if (event.ctrlKey && !event.metaKey && !event.shiftKey && (event.code === "Backquote" || event.key === "`")) {
|
|
9333
|
+
return "terminal";
|
|
9334
|
+
}
|
|
9335
|
+
const mod = mac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
|
|
9336
|
+
return mod && event.shiftKey ? LETTERS[event.key.toLowerCase()] : undefined;
|
|
9337
|
+
}
|
|
9338
|
+
WorkspaceKeys.tool = tool;
|
|
9339
|
+
})(WorkspaceKeys ||= {});
|
|
9340
|
+
|
|
9184
9341
|
// web-src/index.tsx
|
|
9185
9342
|
function openLink(pi2, link2) {
|
|
9186
9343
|
if (link2.type === "file") {
|
|
@@ -9216,9 +9373,20 @@ function activate(pi2) {
|
|
|
9216
9373
|
if (pi2.ui.debugWebview) {
|
|
9217
9374
|
pi2.registerTool(AgentBrowser.TOOL);
|
|
9218
9375
|
}
|
|
9376
|
+
pi2.registerView("launcher", { title: label("workbench"), icon: Host.icon("SquareTerminal"), render: LauncherTools, location: "launcher", order: -10 });
|
|
9377
|
+
const onKey = (event) => {
|
|
9378
|
+
const tool = WorkspaceKeys.tool(event, MAC);
|
|
9379
|
+
if (tool) {
|
|
9380
|
+
event.preventDefault();
|
|
9381
|
+
event.stopPropagation();
|
|
9382
|
+
showTool(tool);
|
|
9383
|
+
}
|
|
9384
|
+
};
|
|
9385
|
+
window.addEventListener("keydown", onKey, true);
|
|
9219
9386
|
const stopTerminals = pi2.onTerminalData((terminalId, data, exitCode) => Terminals.receive(terminalId, data, exitCode));
|
|
9220
9387
|
OpenFiles.restore();
|
|
9221
9388
|
return () => {
|
|
9389
|
+
window.removeEventListener("keydown", onKey, true);
|
|
9222
9390
|
stopTerminals();
|
|
9223
9391
|
removeStyle();
|
|
9224
9392
|
};
|