@celljs/ta-harness 0.0.0-stage → 4.5.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 +13 -2
- package/esm/node/brand-extension.d.ts +15 -0
- package/esm/node/brand-extension.js +37 -0
- package/esm/node/brand-extension.js.map +1 -0
- package/esm/node/bug-report.d.ts +19 -0
- package/esm/node/bug-report.js +38 -0
- package/esm/node/bug-report.js.map +1 -0
- package/esm/node/dino-logo.d.ts +18 -0
- package/esm/node/dino-logo.js +66 -0
- package/esm/node/dino-logo.js.map +1 -0
- package/esm/node/exec-extension.d.ts +15 -0
- package/esm/node/exec-extension.js +28 -0
- package/esm/node/exec-extension.js.map +1 -0
- package/esm/node/exec-mcp-transport.d.ts +27 -0
- package/esm/node/exec-mcp-transport.js +76 -0
- package/esm/node/exec-mcp-transport.js.map +1 -0
- package/esm/node/exec-operations.d.ts +22 -0
- package/esm/node/exec-operations.js +95 -0
- package/esm/node/exec-operations.js.map +1 -0
- package/esm/node/extensions.d.ts +24 -0
- package/esm/node/extensions.js +61 -0
- package/esm/node/extensions.js.map +1 -0
- package/esm/node/glob-util.d.ts +7 -0
- package/esm/node/glob-util.js +57 -0
- package/esm/node/glob-util.js.map +1 -0
- package/esm/node/index.d.ts +13 -0
- package/esm/node/index.js +14 -0
- package/esm/node/index.js.map +1 -0
- package/esm/node/pi-types.d.ts +13 -0
- package/esm/node/pi-types.js +2 -0
- package/esm/node/pi-types.js.map +1 -0
- package/esm/node/session-lock.d.ts +27 -0
- package/esm/node/session-lock.js +96 -0
- package/esm/node/session-lock.js.map +1 -0
- package/esm/node/ta-brand.d.ts +14 -0
- package/esm/node/ta-brand.js +44 -0
- package/esm/node/ta-brand.js.map +1 -0
- package/esm/node/ta-cli.d.ts +13 -0
- package/esm/node/ta-cli.js +50 -0
- package/esm/node/ta-cli.js.map +1 -0
- package/esm/node/ta-header.d.ts +61 -0
- package/esm/node/ta-header.js +149 -0
- package/esm/node/ta-header.js.map +1 -0
- package/esm/package.json +3 -0
- package/lib/node/brand-extension.d.ts +16 -0
- package/lib/node/brand-extension.d.ts.map +1 -0
- package/lib/node/brand-extension.js +41 -0
- package/lib/node/brand-extension.js.map +1 -0
- package/lib/node/brand-extension.spec.d.ts +2 -0
- package/lib/node/brand-extension.spec.d.ts.map +1 -0
- package/lib/node/brand-extension.spec.js +57 -0
- package/lib/node/brand-extension.spec.js.map +1 -0
- package/lib/node/bug-report.d.ts +20 -0
- package/lib/node/bug-report.d.ts.map +1 -0
- package/lib/node/bug-report.js +41 -0
- package/lib/node/bug-report.js.map +1 -0
- package/lib/node/dino-logo.d.ts +19 -0
- package/lib/node/dino-logo.d.ts.map +1 -0
- package/lib/node/dino-logo.js +69 -0
- package/lib/node/dino-logo.js.map +1 -0
- package/lib/node/exec-extension.d.ts +16 -0
- package/lib/node/exec-extension.d.ts.map +1 -0
- package/lib/node/exec-extension.js +32 -0
- package/lib/node/exec-extension.js.map +1 -0
- package/lib/node/exec-mcp-transport.d.ts +28 -0
- package/lib/node/exec-mcp-transport.d.ts.map +1 -0
- package/lib/node/exec-mcp-transport.js +80 -0
- package/lib/node/exec-mcp-transport.js.map +1 -0
- package/lib/node/exec-operations.d.ts +23 -0
- package/lib/node/exec-operations.d.ts.map +1 -0
- package/lib/node/exec-operations.js +99 -0
- package/lib/node/exec-operations.js.map +1 -0
- package/lib/node/exec-operations.spec.d.ts +2 -0
- package/lib/node/exec-operations.spec.d.ts.map +1 -0
- package/lib/node/exec-operations.spec.js +76 -0
- package/lib/node/exec-operations.spec.js.map +1 -0
- package/lib/node/extensions.d.ts +25 -0
- package/lib/node/extensions.d.ts.map +1 -0
- package/lib/node/extensions.js +65 -0
- package/lib/node/extensions.js.map +1 -0
- package/lib/node/extensions.spec.d.ts +2 -0
- package/lib/node/extensions.spec.d.ts.map +1 -0
- package/lib/node/extensions.spec.js +94 -0
- package/lib/node/extensions.spec.js.map +1 -0
- package/lib/node/glob-util.d.ts +8 -0
- package/lib/node/glob-util.d.ts.map +1 -0
- package/lib/node/glob-util.js +60 -0
- package/lib/node/glob-util.js.map +1 -0
- package/lib/node/glob-util.spec.d.ts +2 -0
- package/lib/node/glob-util.spec.d.ts.map +1 -0
- package/lib/node/glob-util.spec.js +27 -0
- package/lib/node/glob-util.spec.js.map +1 -0
- package/lib/node/index.d.ts +14 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +30 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/pi-types.d.ts +14 -0
- package/lib/node/pi-types.d.ts.map +1 -0
- package/lib/node/pi-types.js +3 -0
- package/lib/node/pi-types.js.map +1 -0
- package/lib/node/session-lock.d.ts +28 -0
- package/lib/node/session-lock.d.ts.map +1 -0
- package/lib/node/session-lock.js +100 -0
- package/lib/node/session-lock.js.map +1 -0
- package/lib/node/session-lock.spec.d.ts +2 -0
- package/lib/node/session-lock.spec.d.ts.map +1 -0
- package/lib/node/session-lock.spec.js +53 -0
- package/lib/node/session-lock.spec.js.map +1 -0
- package/lib/node/ta-brand.d.ts +15 -0
- package/lib/node/ta-brand.d.ts.map +1 -0
- package/lib/node/ta-brand.js +47 -0
- package/lib/node/ta-brand.js.map +1 -0
- package/lib/node/ta-brand.spec.d.ts +2 -0
- package/lib/node/ta-brand.spec.d.ts.map +1 -0
- package/lib/node/ta-brand.spec.js +43 -0
- package/lib/node/ta-brand.spec.js.map +1 -0
- package/lib/node/ta-cli.d.ts +14 -0
- package/lib/node/ta-cli.d.ts.map +1 -0
- package/lib/node/ta-cli.js +53 -0
- package/lib/node/ta-cli.js.map +1 -0
- package/lib/node/ta-header.d.ts +62 -0
- package/lib/node/ta-header.d.ts.map +1 -0
- package/lib/node/ta-header.js +153 -0
- package/lib/node/ta-header.js.map +1 -0
- package/lib/node/ta-header.spec.d.ts +2 -0
- package/lib/node/ta-header.spec.d.ts.map +1 -0
- package/lib/node/ta-header.spec.js +67 -0
- package/lib/node/ta-header.spec.js.map +1 -0
- package/package.json +57 -4
- package/src/node/brand-extension.spec.ts +63 -0
- package/src/node/brand-extension.ts +43 -0
- package/src/node/bug-report.ts +48 -0
- package/src/node/dino-logo.ts +70 -0
- package/src/node/exec-extension.ts +33 -0
- package/src/node/exec-mcp-transport.ts +89 -0
- package/src/node/exec-operations.spec.ts +83 -0
- package/src/node/exec-operations.ts +106 -0
- package/src/node/extensions.spec.ts +110 -0
- package/src/node/extensions.ts +69 -0
- package/src/node/glob-util.spec.ts +29 -0
- package/src/node/glob-util.ts +47 -0
- package/src/node/index.ts +13 -0
- package/src/node/pi-types.ts +15 -0
- package/src/node/session-lock.spec.ts +56 -0
- package/src/node/session-lock.ts +105 -0
- package/src/node/ta-brand.spec.ts +46 -0
- package/src/node/ta-brand.ts +41 -0
- package/src/node/ta-cli.ts +58 -0
- package/src/node/ta-header.spec.ts +74 -0
- package/src/node/ta-header.ts +192 -0
package/README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cell - ta Harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ta 在 pi 之上的运行时部件,`ta` 命令和 ta serve 共用。这里的代码不依赖 Cell 容器,`ta` 命令因此不加载 Cell。
|
|
4
|
+
|
|
5
|
+
| 导出 | 作用 |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `TaCli.run(argv, options)` | `ta` 命令:`serve` 启动服务端,其余参数原样交给 pi 的 `main()` |
|
|
8
|
+
| `TaBrand` | 在加载 pi 之前把它改名为 ta(`PI_PACKAGE_DIR` 指向带 `piConfig` 的目录);`agentDir()` 不加载 pi 就能算出 `~/.ta/agent` |
|
|
9
|
+
| `SessionLock` / `SessionLockExtension`(`ta:session-lock`) | 会话文件旁的锁文件(先写草稿再硬链接,原子创建);进程不在了锁即失效;`/resume` 到被占用的会话会被取消,启动时打开被占用的会话则提示后退出 |
|
|
10
|
+
| `BrandExtension`(`ta:brand`) | 终端界面的启动头部 `TaHeader`(像素恐龙 `DinoLogo`、版本、按键;随宽度换行,窄终端和 Apple Terminal 不画恐龙),并把 system prompt 里 pi 自称的句子改成 ta 的 |
|
|
11
|
+
| `ExecExtension`(`ta:exec`) | 执行环境不在本机时,用同名工具替换 read / bash / edit / write / ls / find 并接管 `!` 命令;pi 的 grep 总在本机跑 ripgrep,所以停用它(模型会通过 bash 用 rg) |
|
|
12
|
+
| `ExecOperations` | 把 `ExecEnvironment` 适配成 pi 工具的 `*Operations` |
|
|
13
|
+
| `ExecMcpTransport` | 在执行环境里启动 stdio MCP 服务,交给 pi 的 `createMcpExtension({ createTransport })` |
|
|
14
|
+
| `TaExtension` / `TaExtensionUtil` | ta 的内置扩展形状:普通对象;`bundle()` 把内置扩展合成一个,pi 的已加载扩展列表里显示为 `ta` |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TaExtension } from './extensions.js';
|
|
2
|
+
import type { ExtensionAPI, PiSdk } from './pi-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* What ta adds to its patched pi to look and act as ta: the startup header of the terminal UI, and
|
|
5
|
+
* `/bug`, which opens an issue for ta instead of reporting to pi's developers. The rest of what says
|
|
6
|
+
* ta is in the patch of pi (patches/ at the root of the repository).
|
|
7
|
+
*/
|
|
8
|
+
export declare class BrandExtension implements TaExtension {
|
|
9
|
+
protected readonly sdk: Pick<PiSdk, 'VERSION' | 'keyText' | 'SettingsManager' | 'getAgentDir'>;
|
|
10
|
+
readonly name = "ta:brand";
|
|
11
|
+
constructor(sdk: Pick<PiSdk, 'VERSION' | 'keyText' | 'SettingsManager' | 'getAgentDir'>);
|
|
12
|
+
register(pi: ExtensionAPI): void;
|
|
13
|
+
/** `quietStartup: true` hides pi's header; it hides this one too. */
|
|
14
|
+
protected isQuiet(cwd: string): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BugReport } from './bug-report.js';
|
|
2
|
+
import { TaHeader } from './ta-header.js';
|
|
3
|
+
/**
|
|
4
|
+
* What ta adds to its patched pi to look and act as ta: the startup header of the terminal UI, and
|
|
5
|
+
* `/bug`, which opens an issue for ta instead of reporting to pi's developers. The rest of what says
|
|
6
|
+
* ta is in the patch of pi (patches/ at the root of the repository).
|
|
7
|
+
*/
|
|
8
|
+
export class BrandExtension {
|
|
9
|
+
constructor(sdk) {
|
|
10
|
+
this.sdk = sdk;
|
|
11
|
+
this.name = 'ta:brand';
|
|
12
|
+
}
|
|
13
|
+
register(pi) {
|
|
14
|
+
pi.on('session_start', (_event, ctx) => {
|
|
15
|
+
if (ctx.mode === 'tui' && !this.isQuiet(ctx.cwd)) {
|
|
16
|
+
const keyText = this.sdk.keyText;
|
|
17
|
+
ctx.ui.setHeader((_tui, theme) => new TaHeader(theme, { version: this.sdk.VERSION, keyText }));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
pi.registerCommand('bug', {
|
|
21
|
+
description: 'Open an issue for ta on GitHub',
|
|
22
|
+
handler: async (args, ctx) => {
|
|
23
|
+
const url = BugReport.issueUrl(args, BugReport.currentEnvironment(this.sdk.VERSION, ctx.model));
|
|
24
|
+
// In the terminal UI the browser is on this machine; a client of ta serve shows the link itself.
|
|
25
|
+
if (ctx.mode === 'tui') {
|
|
26
|
+
BugReport.open(url);
|
|
27
|
+
}
|
|
28
|
+
ctx.ui.notify(`A new issue for ta, with its version, the model and the platform and nothing else, opens in the browser. If it did not:\n${url}`, 'info');
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** `quietStartup: true` hides pi's header; it hides this one too. */
|
|
33
|
+
isQuiet(cwd) {
|
|
34
|
+
return this.sdk.SettingsManager.create(cwd, this.sdk.getAgentDir()).getQuietStartup() === true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=brand-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-extension.js","sourceRoot":"","sources":["../../src/node/brand-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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AM,CACT,CAAC;YACN,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED,qEAAqE;IAC3D,OAAO,CAAC,GAAW;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC;IACnG,CAAC;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** What a bug report on ta says about where it happened; no keys, paths or conversation. */
|
|
2
|
+
export interface BugReportEnvironment {
|
|
3
|
+
version: string;
|
|
4
|
+
/** `<provider>/<model id>`. */
|
|
5
|
+
model?: string;
|
|
6
|
+
platform: string;
|
|
7
|
+
node: string;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace BugReport {
|
|
10
|
+
const ISSUES_URL = "https://github.com/cellbang/cell/issues/new";
|
|
11
|
+
/** A new issue on GitHub, filled in with the description and the environment. */
|
|
12
|
+
function issueUrl(description: string, environment: BugReportEnvironment): string;
|
|
13
|
+
function currentEnvironment(version: string, model?: {
|
|
14
|
+
provider: string;
|
|
15
|
+
id: string;
|
|
16
|
+
}): BugReportEnvironment;
|
|
17
|
+
/** Opens the link in the browser of this machine; nothing happens where there is none. */
|
|
18
|
+
function open(url: string): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export var BugReport;
|
|
3
|
+
(function (BugReport) {
|
|
4
|
+
BugReport.ISSUES_URL = 'https://github.com/cellbang/cell/issues/new';
|
|
5
|
+
/** A new issue on GitHub, filled in with the description and the environment. */
|
|
6
|
+
function issueUrl(description, environment) {
|
|
7
|
+
var _a;
|
|
8
|
+
const url = new URL(BugReport.ISSUES_URL);
|
|
9
|
+
url.searchParams.set('title', `[ta] ${description.trim() || 'Describe the bug'}`);
|
|
10
|
+
url.searchParams.set('labels', 'ta');
|
|
11
|
+
url.searchParams.set('body', [
|
|
12
|
+
'## What happened',
|
|
13
|
+
'',
|
|
14
|
+
description.trim() || '<!-- What did you do, what did you expect, what happened instead? -->',
|
|
15
|
+
'',
|
|
16
|
+
'## Environment',
|
|
17
|
+
'',
|
|
18
|
+
`- ta ${environment.version}`,
|
|
19
|
+
`- model: ${(_a = environment.model) !== null && _a !== void 0 ? _a : 'none'}`,
|
|
20
|
+
`- ${environment.platform}, Node.js ${environment.node}`,
|
|
21
|
+
].join('\n'));
|
|
22
|
+
return url.href;
|
|
23
|
+
}
|
|
24
|
+
BugReport.issueUrl = issueUrl;
|
|
25
|
+
function currentEnvironment(version, model) {
|
|
26
|
+
return { version, model: model && `${model.provider}/${model.id}`, platform: `${process.platform} ${process.arch}`, node: process.versions.node };
|
|
27
|
+
}
|
|
28
|
+
BugReport.currentEnvironment = currentEnvironment;
|
|
29
|
+
/** Opens the link in the browser of this machine; nothing happens where there is none. */
|
|
30
|
+
function open(url) {
|
|
31
|
+
const [command, ...args] = process.platform === 'darwin' ? ['open'] : process.platform === 'win32' ? ['cmd', '/c', 'start', '""'] : ['xdg-open'];
|
|
32
|
+
const child = spawn(command, [...args, url], { detached: true, stdio: 'ignore' });
|
|
33
|
+
child.on('error', () => undefined);
|
|
34
|
+
child.unref();
|
|
35
|
+
}
|
|
36
|
+
BugReport.open = open;
|
|
37
|
+
})(BugReport || (BugReport = {}));
|
|
38
|
+
//# sourceMappingURL=bug-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bug-report.js","sourceRoot":"","sources":["../../src/node/bug-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAW3C,MAAM,KAAW,SAAS,CAoCzB;AApCD,WAAiB,SAAS;IACT,oBAAU,GAAG,6CAA6C,CAAC;IAExE,iFAAiF;IACjF,SAAgB,QAAQ,CAAC,WAAmB,EAAE,WAAiC;;QAC3E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC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CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QACjJ,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAClF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACnC,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IALe,UAAA,IAAI,OAKnB,CAAA;AACL,CAAC,EApCgB,SAAS,KAAT,SAAS,QAoCzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The terminal color depths pi renders for. */
|
|
2
|
+
export type ColorMode = '256color' | 'truecolor';
|
|
3
|
+
/**
|
|
4
|
+
* Cell's dinosaur (assets/logo.svg) as pixel art: 16 by 16 pixels, drawn with half blocks as 16
|
|
5
|
+
* columns and 8 lines. Its green stays the same across themes, as a brand color does.
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace DinoLogo {
|
|
8
|
+
const WIDTH: number;
|
|
9
|
+
const HEIGHT: number;
|
|
10
|
+
function lines(mode: ColorMode): string[];
|
|
11
|
+
/** Text in the green of the logo. */
|
|
12
|
+
function paint(mode: ColorMode, text: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Apple's Terminal leaves gaps between lines and misaligns half blocks, which breaks the picture: pi
|
|
15
|
+
* shows a text logo there too.
|
|
16
|
+
*/
|
|
17
|
+
function isSupported(env?: NodeJS.ProcessEnv): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cell's dinosaur (assets/logo.svg) as pixel art: 16 by 16 pixels, drawn with half blocks as 16
|
|
3
|
+
* columns and 8 lines. Its green stays the same across themes, as a brand color does.
|
|
4
|
+
*/
|
|
5
|
+
export var DinoLogo;
|
|
6
|
+
(function (DinoLogo) {
|
|
7
|
+
const PIXELS = [
|
|
8
|
+
'........######..',
|
|
9
|
+
'.......########.',
|
|
10
|
+
'.......##.######',
|
|
11
|
+
'.......#########',
|
|
12
|
+
'#......#########',
|
|
13
|
+
'#......####.....',
|
|
14
|
+
'##.....#######..',
|
|
15
|
+
'##....#######...',
|
|
16
|
+
'###..########...',
|
|
17
|
+
'.###########.##.',
|
|
18
|
+
'..##########..#.',
|
|
19
|
+
'...########.....',
|
|
20
|
+
'....######......',
|
|
21
|
+
'....##..##......',
|
|
22
|
+
'....##..##......',
|
|
23
|
+
'...###..###.....',
|
|
24
|
+
];
|
|
25
|
+
DinoLogo.WIDTH = PIXELS[0].length;
|
|
26
|
+
DinoLogo.HEIGHT = PIXELS.length / 2;
|
|
27
|
+
/** #10B981, and the nearest color of the 256-color palette. */
|
|
28
|
+
const GREEN = { truecolor: '\x1b[38;2;16;185;129m', '256color': '\x1b[38;5;36m' };
|
|
29
|
+
const RESET = '\x1b[39m';
|
|
30
|
+
function lines(mode) {
|
|
31
|
+
const lines = [];
|
|
32
|
+
for (let row = 0; row < PIXELS.length; row += 2) {
|
|
33
|
+
let line = '';
|
|
34
|
+
for (let column = 0; column < DinoLogo.WIDTH; column++) {
|
|
35
|
+
line += cell(PIXELS[row][column] === '#', PIXELS[row + 1][column] === '#');
|
|
36
|
+
}
|
|
37
|
+
lines.push(paint(mode, line));
|
|
38
|
+
}
|
|
39
|
+
return lines;
|
|
40
|
+
}
|
|
41
|
+
DinoLogo.lines = lines;
|
|
42
|
+
/** Text in the green of the logo. */
|
|
43
|
+
function paint(mode, text) {
|
|
44
|
+
return `${GREEN[mode]}${text}${RESET}`;
|
|
45
|
+
}
|
|
46
|
+
DinoLogo.paint = paint;
|
|
47
|
+
/** Two pixels, one above the other, in one character. */
|
|
48
|
+
function cell(top, bottom) {
|
|
49
|
+
if (top && bottom) {
|
|
50
|
+
return '█';
|
|
51
|
+
}
|
|
52
|
+
if (top) {
|
|
53
|
+
return '▀';
|
|
54
|
+
}
|
|
55
|
+
return bottom ? '▄' : ' ';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Apple's Terminal leaves gaps between lines and misaligns half blocks, which breaks the picture: pi
|
|
59
|
+
* shows a text logo there too.
|
|
60
|
+
*/
|
|
61
|
+
function isSupported(env = process.env) {
|
|
62
|
+
return env.TERM_PROGRAM !== 'Apple_Terminal';
|
|
63
|
+
}
|
|
64
|
+
DinoLogo.isSupported = isSupported;
|
|
65
|
+
})(DinoLogo || (DinoLogo = {}));
|
|
66
|
+
//# sourceMappingURL=dino-logo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dino-logo.js","sourceRoot":"","sources":["../../src/node/dino-logo.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,KAAW,QAAQ,CA8DxB;AA9DD,WAAiB,QAAQ;IACrB,MAAM,MAAM,GAAG;QACX,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;KACrB,CAAC;IAEW,cAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACzB,eAAM,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAExC,+DAA+D;IAC/D,MAAM,KAAK,GAA8B,EAAE,SAAS,EAAE,uBAAuB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;IAC7G,MAAM,KAAK,GAAG,UAAU,CAAC;IAEzB,SAAgB,KAAK,CAAC,IAAe;QACjC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,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import type { ExecEnvironment } from '@celljs/ta-exec';
|
|
2
|
+
import type { TaExtension } from './extensions.js';
|
|
3
|
+
import type { ExtensionAPI, PiSdk } from './pi-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Sends pi's built-in tools and `!` commands to an environment that is not this machine, by registering
|
|
6
|
+
* tools of the same names, as pi's documentation describes. Only for those: a local environment keeps
|
|
7
|
+
* pi's own tools, which do the same work.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ExecExtension implements TaExtension {
|
|
10
|
+
protected readonly environment: ExecEnvironment;
|
|
11
|
+
protected readonly sdk: PiSdk;
|
|
12
|
+
readonly name = "ta:exec";
|
|
13
|
+
constructor(environment: ExecEnvironment, sdk: PiSdk);
|
|
14
|
+
register(pi: ExtensionAPI): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ExecOperations } from './exec-operations.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sends pi's built-in tools and `!` commands to an environment that is not this machine, by registering
|
|
4
|
+
* tools of the same names, as pi's documentation describes. Only for those: a local environment keeps
|
|
5
|
+
* pi's own tools, which do the same work.
|
|
6
|
+
*/
|
|
7
|
+
export class ExecExtension {
|
|
8
|
+
constructor(environment, sdk) {
|
|
9
|
+
this.environment = environment;
|
|
10
|
+
this.sdk = sdk;
|
|
11
|
+
this.name = 'ta:exec';
|
|
12
|
+
}
|
|
13
|
+
register(pi) {
|
|
14
|
+
const { cwd } = this.environment;
|
|
15
|
+
const operations = new ExecOperations(this.environment);
|
|
16
|
+
pi.registerTool(this.sdk.createReadToolDefinition(cwd, { operations: operations.read }));
|
|
17
|
+
pi.registerTool(this.sdk.createBashToolDefinition(cwd, { operations: operations.bash }));
|
|
18
|
+
pi.registerTool(this.sdk.createEditToolDefinition(cwd, { operations: operations.edit }));
|
|
19
|
+
pi.registerTool(this.sdk.createWriteToolDefinition(cwd, { operations: operations.write }));
|
|
20
|
+
pi.registerTool(this.sdk.createLsToolDefinition(cwd, { operations: operations.ls }));
|
|
21
|
+
pi.registerTool(this.sdk.createFindToolDefinition(cwd, { operations: operations.find }));
|
|
22
|
+
pi.on('user_bash', () => ({ operations: operations.bash }));
|
|
23
|
+
// pi's grep always runs ripgrep on this machine, whatever its operations say: without the tool the
|
|
24
|
+
// model searches with rg through bash, in the environment.
|
|
25
|
+
pi.on('session_start', () => pi.setActiveTools(pi.getActiveTools().filter(name => name !== 'grep')));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=exec-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-extension.js","sourceRoot":"","sources":["../../src/node/exec-extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAGtB,YACuB,WAA4B,EAC5B,GAAU;QADV,gBAAW,GAAX,WAAW,CAAiB;QAC5B,QAAG,GAAH,GAAG,CAAO;QAJxB,SAAI,GAAG,SAAS,CAAC;IAKvB,CAAC;IAEJ,QAAQ,CAAC,EAAgB;QACrB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;QACjC,MAAM,UAAU,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxD,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzF,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzF,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzF,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC3F,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACrF,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzF,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5D,mGAAmG;QACnG,2DAA2D;QAC3D,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;IACzG,CAAC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ExecEnvironment, ExecProcess } from '@celljs/ta-exec';
|
|
2
|
+
import type { JsonRpcMessage, McpServerEntry, McpTransport } from './pi-types.js';
|
|
3
|
+
type Listener<T extends unknown[]> = (...args: T) => void;
|
|
4
|
+
/** An MCP server over stdio, started in an {@link ExecEnvironment}: one JSON message per line. */
|
|
5
|
+
export declare class ExecMcpTransport implements McpTransport {
|
|
6
|
+
protected readonly environment: ExecEnvironment;
|
|
7
|
+
protected readonly entry: McpServerEntry;
|
|
8
|
+
protected process?: ExecProcess;
|
|
9
|
+
protected buffer: string;
|
|
10
|
+
protected readonly decoder: TextDecoder;
|
|
11
|
+
protected readonly messageListeners: Set<Listener<[import("@earendil-works/pi-mcp").JsonRpcMessage]>>;
|
|
12
|
+
protected readonly errorListeners: Set<Listener<[Error]>>;
|
|
13
|
+
protected readonly closeListeners: Set<Listener<[]>>;
|
|
14
|
+
constructor(environment: ExecEnvironment, entry: McpServerEntry);
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
send(message: JsonRpcMessage): Promise<void>;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
onMessage(listener: Listener<[JsonRpcMessage]>): () => void;
|
|
19
|
+
onError(listener: Listener<[Error]>): () => void;
|
|
20
|
+
onClose(listener: Listener<[]>): () => void;
|
|
21
|
+
protected listen<T extends unknown[]>(listeners: Set<Listener<T>>, listener: Listener<T>): () => void;
|
|
22
|
+
protected emit<T extends unknown[]>(listeners: Set<Listener<T>>, ...args: T): void;
|
|
23
|
+
protected receive(data: Uint8Array): void;
|
|
24
|
+
protected dispatch(line: string): void;
|
|
25
|
+
protected closed(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** An MCP server over stdio, started in an {@link ExecEnvironment}: one JSON message per line. */
|
|
2
|
+
export class ExecMcpTransport {
|
|
3
|
+
constructor(environment, entry) {
|
|
4
|
+
this.environment = environment;
|
|
5
|
+
this.entry = entry;
|
|
6
|
+
this.buffer = '';
|
|
7
|
+
this.decoder = new TextDecoder();
|
|
8
|
+
this.messageListeners = new Set();
|
|
9
|
+
this.errorListeners = new Set();
|
|
10
|
+
this.closeListeners = new Set();
|
|
11
|
+
}
|
|
12
|
+
async start() {
|
|
13
|
+
var _a;
|
|
14
|
+
const config = this.entry.config;
|
|
15
|
+
if ('url' in config) {
|
|
16
|
+
throw new Error(`The MCP server ${this.entry.name} has a URL: it needs no process in the execution environment.`);
|
|
17
|
+
}
|
|
18
|
+
const child = this.environment.spawn(config.command, (_a = config.args) !== null && _a !== void 0 ? _a : [], { cwd: config.cwd, env: { ...process.env, ...config.env } });
|
|
19
|
+
child.onStdout(data => this.receive(data));
|
|
20
|
+
child.onExit(() => this.closed());
|
|
21
|
+
this.process = child;
|
|
22
|
+
}
|
|
23
|
+
async send(message) {
|
|
24
|
+
if (!this.process) {
|
|
25
|
+
throw new Error(`The MCP server ${this.entry.name} is not running.`);
|
|
26
|
+
}
|
|
27
|
+
this.process.write(`${JSON.stringify(message)}\n`);
|
|
28
|
+
}
|
|
29
|
+
async close() {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = this.process) === null || _a === void 0 ? void 0 : _a.kill();
|
|
32
|
+
}
|
|
33
|
+
onMessage(listener) {
|
|
34
|
+
return this.listen(this.messageListeners, listener);
|
|
35
|
+
}
|
|
36
|
+
onError(listener) {
|
|
37
|
+
return this.listen(this.errorListeners, listener);
|
|
38
|
+
}
|
|
39
|
+
onClose(listener) {
|
|
40
|
+
return this.listen(this.closeListeners, listener);
|
|
41
|
+
}
|
|
42
|
+
listen(listeners, listener) {
|
|
43
|
+
listeners.add(listener);
|
|
44
|
+
return () => listeners.delete(listener);
|
|
45
|
+
}
|
|
46
|
+
emit(listeners, ...args) {
|
|
47
|
+
for (const listener of listeners) {
|
|
48
|
+
listener(...args);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
receive(data) {
|
|
52
|
+
var _a;
|
|
53
|
+
const lines = (this.buffer + this.decoder.decode(data, { stream: true })).split('\n');
|
|
54
|
+
this.buffer = (_a = lines.pop()) !== null && _a !== void 0 ? _a : '';
|
|
55
|
+
for (const line of lines) {
|
|
56
|
+
if (line.trim()) {
|
|
57
|
+
this.dispatch(line);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
dispatch(line) {
|
|
62
|
+
try {
|
|
63
|
+
const message = JSON.parse(line);
|
|
64
|
+
this.emit(this.messageListeners, message);
|
|
65
|
+
}
|
|
66
|
+
catch (cause) {
|
|
67
|
+
const error = new Error(`The MCP server ${this.entry.name} sent something that is not JSON: ${line}`, { cause });
|
|
68
|
+
this.emit(this.errorListeners, error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
closed() {
|
|
72
|
+
this.process = undefined;
|
|
73
|
+
this.emit(this.closeListeners);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=exec-mcp-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-mcp-transport.js","sourceRoot":"","sources":["../../src/node/exec-mcp-transport.ts"],"names":[],"mappings":"AAKA,kGAAkG;AAClG,MAAM,OAAO,gBAAgB;IAQzB,YACuB,WAA4B,EAC5B,KAAqB;QADrB,gBAAW,GAAX,WAAW,CAAiB;QAC5B,UAAK,GAAL,KAAK,CAAgB;QARlC,WAAM,GAAG,EAAE,CAAC;QACH,YAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAC5B,qBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;QACzD,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC9C,mBAAc,GAAG,IAAI,GAAG,EAAgB,CAAC;IAKzD,CAAC;IAEJ,KAAK,CAAC,KAAK;;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,KAAK,CAAC,IAAI,+DAA+D,CAAC,CAAC;QACtH,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,QAAE,MAAM,CAAC,IAAI,mCAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACrI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAA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CAAC;QACtB,CAAC;IACL,CAAC;IAES,OAAO,CAAC,IAAgB;;QAC9B,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtF,IAAI,CAAC,MAAM,SAAG,KAAK,CAAC,GAAG,EAAE,mCAAI,EAAE,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;gBACd,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;QACL,CAAC;IACL,CAAC;IAES,QAAQ,CAAC,IAAY;QAC3B,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,KAAK,CAAC,IAAI,qCAAqC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACjH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAES,MAAM;QACZ,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExecEnvironment } from '@celljs/ta-exec';
|
|
2
|
+
import type { BashOperations, EditOperations, FindOperations, LsOperations, ReadOperations, WriteOperations } from './pi-types.js';
|
|
3
|
+
/** The file and process operations of pi's built-in tools, on an {@link ExecEnvironment}. */
|
|
4
|
+
export declare class ExecOperations {
|
|
5
|
+
protected readonly environment: ExecEnvironment;
|
|
6
|
+
constructor(environment: ExecEnvironment);
|
|
7
|
+
readonly bash: BashOperations;
|
|
8
|
+
readonly read: ReadOperations;
|
|
9
|
+
readonly write: WriteOperations;
|
|
10
|
+
readonly edit: EditOperations;
|
|
11
|
+
readonly ls: LsOperations;
|
|
12
|
+
readonly find: FindOperations;
|
|
13
|
+
protected readBuffer(path: string): Promise<Buffer>;
|
|
14
|
+
protected access(path: string): Promise<void>;
|
|
15
|
+
protected exists(path: string): Promise<boolean>;
|
|
16
|
+
protected notFound(path: string): NodeJS.ErrnoException;
|
|
17
|
+
/**
|
|
18
|
+
* Lists the files with `find`, the one tool every environment has, and matches them here. Stops the
|
|
19
|
+
* listing at `limit` matches, so that a huge tree costs no more than the answer needs.
|
|
20
|
+
*/
|
|
21
|
+
protected glob(pattern: string, cwd: string, ignore: string[], limit: number): Promise<string[]>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { join, relative } from 'node:path';
|
|
2
|
+
import { GlobUtil } from './glob-util.js';
|
|
3
|
+
/** The file and process operations of pi's built-in tools, on an {@link ExecEnvironment}. */
|
|
4
|
+
export class ExecOperations {
|
|
5
|
+
constructor(environment) {
|
|
6
|
+
this.environment = environment;
|
|
7
|
+
this.bash = {
|
|
8
|
+
exec: (command, cwd, options) => this.environment.exec(command, {
|
|
9
|
+
cwd,
|
|
10
|
+
env: options.env,
|
|
11
|
+
signal: options.signal,
|
|
12
|
+
// pi's timeouts are in seconds.
|
|
13
|
+
timeout: options.timeout ? options.timeout * 1000 : undefined,
|
|
14
|
+
onData: data => options.onData(Buffer.from(data)),
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
this.read = {
|
|
18
|
+
readFile: path => this.readBuffer(path),
|
|
19
|
+
access: path => this.access(path),
|
|
20
|
+
};
|
|
21
|
+
this.write = {
|
|
22
|
+
writeFile: (path, content) => this.environment.writeFile(path, content),
|
|
23
|
+
mkdir: dir => this.environment.mkdir(dir),
|
|
24
|
+
};
|
|
25
|
+
this.edit = {
|
|
26
|
+
readFile: path => this.readBuffer(path),
|
|
27
|
+
writeFile: (path, content) => this.environment.writeFile(path, content),
|
|
28
|
+
access: path => this.access(path),
|
|
29
|
+
};
|
|
30
|
+
this.ls = {
|
|
31
|
+
exists: path => this.exists(path),
|
|
32
|
+
stat: async (path) => {
|
|
33
|
+
const info = await this.environment.stat(path);
|
|
34
|
+
if (!info) {
|
|
35
|
+
throw this.notFound(path);
|
|
36
|
+
}
|
|
37
|
+
return { isDirectory: () => info.isDirectory };
|
|
38
|
+
},
|
|
39
|
+
readdir: async (path) => (await this.environment.readdir(path)).map(entry => entry.name),
|
|
40
|
+
};
|
|
41
|
+
this.find = {
|
|
42
|
+
exists: path => this.exists(path),
|
|
43
|
+
glob: (pattern, cwd, options) => this.glob(pattern, cwd, options.ignore, options.limit),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async readBuffer(path) {
|
|
47
|
+
return Buffer.from(await this.environment.readFile(path));
|
|
48
|
+
}
|
|
49
|
+
async access(path) {
|
|
50
|
+
if (!(await this.exists(path))) {
|
|
51
|
+
throw this.notFound(path);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async exists(path) {
|
|
55
|
+
return (await this.environment.stat(path)) !== undefined;
|
|
56
|
+
}
|
|
57
|
+
notFound(path) {
|
|
58
|
+
return Object.assign(new Error(`ENOENT: no such file or directory, '${path}'`), { code: 'ENOENT' });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Lists the files with `find`, the one tool every environment has, and matches them here. Stops the
|
|
62
|
+
* listing at `limit` matches, so that a huge tree costs no more than the answer needs.
|
|
63
|
+
*/
|
|
64
|
+
async glob(pattern, cwd, ignore, limit) {
|
|
65
|
+
const matches = GlobUtil.matcher(pattern);
|
|
66
|
+
const ignored = ignore.map(GlobUtil.matcher);
|
|
67
|
+
const found = [];
|
|
68
|
+
const stop = new AbortController();
|
|
69
|
+
let rest = '';
|
|
70
|
+
const accept = (line) => {
|
|
71
|
+
const path = relative('.', line);
|
|
72
|
+
if (found.length < limit && path && matches(path) && !ignored.some(isIgnored => isIgnored(path))) {
|
|
73
|
+
found.push(join(cwd, path));
|
|
74
|
+
if (found.length === limit) {
|
|
75
|
+
stop.abort();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
await this.environment.exec('find . -type f -not -path "*/.git/*"', {
|
|
80
|
+
cwd,
|
|
81
|
+
signal: stop.signal,
|
|
82
|
+
onData: data => {
|
|
83
|
+
var _a;
|
|
84
|
+
const lines = (rest + Buffer.from(data).toString()).split('\n');
|
|
85
|
+
rest = (_a = lines.pop()) !== null && _a !== void 0 ? _a : '';
|
|
86
|
+
lines.forEach(accept);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
if (rest) {
|
|
90
|
+
accept(rest);
|
|
91
|
+
}
|
|
92
|
+
return found;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=exec-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-operations.js","sourceRoot":"","sources":["../../src/node/exec-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,6FAA6F;AAC7F,MAAM,OAAO,cAAc;IACvB,YAA+B,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;QAElD,SAAI,GAAmB;YAC5B,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,CAC5B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE;gBAC3B,GAAG;gBACH,GAAG,EAAE,OAAO,C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,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAChE,IAAI,SAAG,KAAK,CAAC,GAAG,EAAE,mCAAI,EAAE,CAAC;gBACzB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;SACJ,CAAC,CAAC;QACH,IAAI,IAAI,EAAE,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext, InlineExtension } from './pi-types.js';
|
|
2
|
+
import type { SessionLock } from './session-lock.js';
|
|
3
|
+
/** A pi extension of ta. A plain object: the `ta` command runs without a Cell container. */
|
|
4
|
+
export interface TaExtension {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
register(pi: ExtensionAPI): void;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace TaExtensionUtil {
|
|
9
|
+
function toInline(extension: TaExtension): InlineExtension;
|
|
10
|
+
/** ta's built-in extensions as one, listed by pi as `ta` among the loaded extensions. */
|
|
11
|
+
function bundle(extensions: TaExtension[]): InlineExtension;
|
|
12
|
+
}
|
|
13
|
+
/** Holds the lock of the session file that is open. See {@link SessionLock}. */
|
|
14
|
+
export declare class SessionLockExtension implements TaExtension {
|
|
15
|
+
protected readonly lock: SessionLock;
|
|
16
|
+
readonly name = "ta:session-lock";
|
|
17
|
+
constructor(lock: SessionLock);
|
|
18
|
+
register(pi: ExtensionAPI): void;
|
|
19
|
+
/**
|
|
20
|
+
* pi has opened the session by the time an extension can see it (`--continue`, `--resume`), so this
|
|
21
|
+
* can only end the process. `ctx.shutdown` restores the terminal; print modes do not act on it.
|
|
22
|
+
*/
|
|
23
|
+
protected refuse(file: string, ctx: ExtensionContext): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export var TaExtensionUtil;
|
|
2
|
+
(function (TaExtensionUtil) {
|
|
3
|
+
function toInline(extension) {
|
|
4
|
+
return { name: extension.name, factory: pi => extension.register(pi) };
|
|
5
|
+
}
|
|
6
|
+
TaExtensionUtil.toInline = toInline;
|
|
7
|
+
/** ta's built-in extensions as one, listed by pi as `ta` among the loaded extensions. */
|
|
8
|
+
function bundle(extensions) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'ta',
|
|
11
|
+
factory: pi => {
|
|
12
|
+
for (const extension of extensions) {
|
|
13
|
+
extension.register(pi);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
TaExtensionUtil.bundle = bundle;
|
|
19
|
+
})(TaExtensionUtil || (TaExtensionUtil = {}));
|
|
20
|
+
/** Holds the lock of the session file that is open. See {@link SessionLock}. */
|
|
21
|
+
export class SessionLockExtension {
|
|
22
|
+
constructor(lock) {
|
|
23
|
+
this.lock = lock;
|
|
24
|
+
this.name = 'ta:session-lock';
|
|
25
|
+
}
|
|
26
|
+
register(pi) {
|
|
27
|
+
pi.on('session_before_switch', event => {
|
|
28
|
+
if (event.targetSessionFile && this.lock.isHeldByOther(event.targetSessionFile)) {
|
|
29
|
+
return { cancel: true };
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
});
|
|
33
|
+
pi.on('session_start', (_event, ctx) => {
|
|
34
|
+
const file = ctx.sessionManager.getSessionFile();
|
|
35
|
+
if (file && !this.lock.acquire(file)) {
|
|
36
|
+
this.refuse(file, ctx);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
pi.on('session_shutdown', (_event, ctx) => {
|
|
40
|
+
const file = ctx.sessionManager.getSessionFile();
|
|
41
|
+
if (file) {
|
|
42
|
+
this.lock.release(file);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* pi has opened the session by the time an extension can see it (`--continue`, `--resume`), so this
|
|
48
|
+
* can only end the process. `ctx.shutdown` restores the terminal; print modes do not act on it.
|
|
49
|
+
*/
|
|
50
|
+
refuse(file, ctx) {
|
|
51
|
+
const message = `This session is open in another ta process. If that process is gone, delete ${this.lock.path(file)}.`;
|
|
52
|
+
if (ctx.mode === 'tui') {
|
|
53
|
+
ctx.ui.notify(message, 'error');
|
|
54
|
+
ctx.shutdown();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
process.stderr.write(`${message}\n`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../src/node/extensions.ts"],"names":[],"mappings":"AASA,MAAM,KAAW,eAAe,CAgB/B;AAhBD,WAAiB,eAAe;IAC5B,SAAgB,QAAQ,CAAC,SAAsB;QAC3C,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3E,CAAC;IAFe,gBAAA,QAAQ,WAEvB,CAAA;IAED,yFAAyF;IACzF,SAAgB,MAAM,CAAC,UAAyB;QAC5C,OAAO;YACH,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,CAAC,EAAE;gBACV,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;oBACjC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAC3B,CAAC;YACL,CAAC;SACJ,CAAC;IACN,CAAC;IATe,gBAAA,MAAM,SASrB,CAAA;AACL,CAAC,EAhBgB,eAAe,KAAf,eAAe,QAgB/B;AAED,gFAAgF;AAChF,MAAM,OAAO,oBAAoB;IAG7B,YAA+B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAFvC,SAAI,GAAG,iBAA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AAC,QAAQ,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare namespace GlobUtil {
|
|
2
|
+
/**
|
|
3
|
+
* A matcher for the glob syntax of fd, which pi's find tool documents: `*`, `?`, `**`, `{a,b}` and
|
|
4
|
+
* `[...]`. A pattern without `/` matches the name of the file at any depth.
|
|
5
|
+
*/
|
|
6
|
+
function matcher(pattern: string): (path: string) => boolean;
|
|
7
|
+
}
|