terminal-tool-for-agents 0.1.5 → 0.1.6

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 CHANGED
@@ -31,12 +31,13 @@ Copy this block into your agent:
31
31
  Install tta CLI:
32
32
  npm install -g terminal-tool-for-agents
33
33
 
34
- Install the tta skill from:
35
- https://github.com/yanggggjie/terminal-tool-for-agents/tree/main/skills/tta
34
+ Install tta skills (English only — do NOT install *.zh.md):
35
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/SKILL.md
36
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/tta-agents-skill.md
36
37
 
37
- (includes bundled tta-agents-skill; no separate install)
38
+ tta-agents-skill ships with tta skill in the same folder; no separate install.
38
39
 
39
- Confirm both are installed.
40
+ Confirm CLI and both skill files are installed.
40
41
  ```
41
42
 
42
43
  Then ask your agent to run a task:
@@ -61,13 +62,11 @@ Copy this block into your agent:
61
62
  Update tta CLI:
62
63
  npm update -g terminal-tool-for-agents
63
64
 
64
- Update the tta skill from:
65
- https://github.com/yanggggjie/terminal-tool-for-agents/tree/main/skills/tta
65
+ Update tta skills (English only — do NOT install *.zh.md):
66
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/SKILL.md
67
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/tta-agents-skill.md
66
68
 
67
- Kill all tta sessions so the background service restarts on next use:
68
- tta sess killall
69
-
70
- Confirm both are updated.
69
+ Confirm CLI and both skills are updated.
71
70
  ```
72
71
 
73
72
  ## When to use tta vs shell
@@ -121,19 +120,26 @@ Operational details: [`skills/tta/SKILL.md`](./skills/tta/SKILL.md).
121
120
  ## Requirements
122
121
 
123
122
  - **Node.js** 22.x–26.x (`engines`: `>=22.0.0 <27.0.0`); repo includes `.nvmrc` (`24`) for local dev
124
- - After `npm install` or `npm install -g`, if npm warns about allow-scripts for `node-pty`, run `npm approve-scripts node-pty` or `npm approve-scripts --allow-scripts-pending`, then reinstall so the PTY native module installs correctly.
123
+ - Install runs `postinstall` automatically: copies node-pty prebuilds into `build/Release` and verifies the PTY works; no manual `approve-scripts` needed
125
124
 
126
125
  ## Development
127
126
 
127
+ After code changes, reinstall globally and test:
128
+
129
+ ```bash
130
+ just install
131
+ tta sess list
132
+ ```
133
+
134
+ Watch UI only (static files from `src/watch-ui/`):
135
+
128
136
  ```bash
129
137
  just dev
130
- just link # link for global testing
131
- just unlink # remove link after testing
132
- tta sess watch # open http://127.0.0.1:7654 to observe
138
+ tta sess watch # http://127.0.0.1:7654
133
139
  ```
134
140
 
135
- - **Backend** (`src/*.ts`): savetsc recompilesnodemon restarts server → refresh browser.
136
- - **Watch UI** (`src/watch-ui/*`): save → refresh browser (served from `src/` in dev).
141
+ - **Backend** (`src/*.ts`): change`just install`run `tta`
142
+ - **Watch UI** (`src/watch-ui/*`): under `just dev`, save → refresh browser
137
143
 
138
144
  ## License
139
145
 
package/README.zh.md CHANGED
@@ -31,12 +31,13 @@ Fork 自 [tui-use](https://github.com/onesuper/tui-use) 并改造为 `tta`。感
31
31
  Install tta CLI:
32
32
  npm install -g terminal-tool-for-agents
33
33
 
34
- Install the tta skill from:
35
- https://github.com/yanggggjie/terminal-tool-for-agents/tree/main/skills/tta
34
+ Install tta skills (English only — do NOT install *.zh.md):
35
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/SKILL.md
36
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/tta-agents-skill.md
36
37
 
37
- (includes bundled tta-agents-skill; no separate install)
38
+ tta-agents-skill ships with tta skill in the same folder; no separate install.
38
39
 
39
- Confirm both are installed.
40
+ Confirm CLI and both skill files are installed.
40
41
  ```
41
42
 
42
43
  然后让 Agent 执行任务:
@@ -61,13 +62,11 @@ tta sess watch
61
62
  Update tta CLI:
62
63
  npm update -g terminal-tool-for-agents
63
64
 
64
- Update the tta skill from:
65
- https://github.com/yanggggjie/terminal-tool-for-agents/tree/main/skills/tta
65
+ Update tta skills (English only — do NOT install *.zh.md):
66
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/SKILL.md
67
+ - https://raw.githubusercontent.com/yanggggjie/terminal-tool-for-agents/main/skills/tta/tta-agents-skill.md
66
68
 
67
- Kill all tta sessions so the background service restarts on next use:
68
- tta sess killall
69
-
70
- Confirm both are updated.
69
+ Confirm CLI and both skills are updated.
71
70
  ```
72
71
 
73
72
  ## 何时用 tta vs shell
@@ -121,19 +120,26 @@ tta sess start -> (tta act ... -> tta obs screen stable)* -> tta sess kill
121
120
  ## 环境要求
122
121
 
123
122
  - **Node.js** 22.x–26.x(`engines`:`>=22.0.0 <27.0.0`);仓库含 `.nvmrc`(`24`)供本地开发
124
- - `npm install` 或 `npm install -g` 后,若 npm 对 `node-pty` 提示 allow-scripts,请运行 `npm approve-scripts node-pty` `npm approve-scripts --allow-scripts-pending`,然后重新安装,以便 PTY 原生模块正确安装。
123
+ - 安装时会自动运行 `postinstall`,将 node-pty prebuild 复制到 `build/Release` 并验证 PTY 可用;无需手动 `approve-scripts`
125
124
 
126
125
  ## 开发
127
126
 
127
+ 改代码后重新全局安装再测:
128
+
129
+ ```bash
130
+ just install
131
+ tta sess list
132
+ ```
133
+
134
+ 仅开发 Watch UI 时(静态文件从 `src/watch-ui/` 提供):
135
+
128
136
  ```bash
129
- just dev
130
- just link # 链接以便全局测试
131
- just unlink # 测试完成删除链接
132
- tta sess watch # 打开 http://127.0.0.1:7654 观察
137
+ just dev
138
+ tta sess watch # http://127.0.0.1:7654
133
139
  ```
134
140
 
135
- - **后端**(`src/*.ts`):保存tsc 重编译nodemon 重启 server → 刷新浏览器。
136
- - **Watch UI**(`src/watch-ui/*`):保存 刷新浏览器(开发模式下直接从 `src/` 提供)。
141
+ - **后端**(`src/*.ts`):改完`just install`再跑 `tta`
142
+ - **Watch UI**(`src/watch-ui/*`):`just dev` 下保存 刷新浏览器
137
143
 
138
144
  ## 许可证
139
145
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAc/C,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAazD;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWjE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAU/C,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKzD;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWjE"}
package/dist/client.js CHANGED
@@ -48,17 +48,9 @@ const HEALTH_TIMEOUT_MS = 500;
48
48
  function info(msg) {
49
49
  process.stderr.write(`tta: ${msg}\n`);
50
50
  }
51
- function isDevMode() {
52
- return fs.existsSync(path.join(__dirname, "..", ".tta-dev"));
53
- }
54
51
  async function ensureServerRunning() {
55
52
  if (await isServerReachable())
56
53
  return;
57
- if (isDevMode()) {
58
- throw new Error("Dev server is not running.\n" +
59
- " Start it in the project root: just dev\n" +
60
- " Then run tta commands in another terminal.");
61
- }
62
54
  info("starting server...");
63
55
  await spawnServer();
64
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,kDAaC;AAED,kCAWC;AA/CD;;GAEG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,6DAA+C;AAC/C,qCAAsC;AAGtC,MAAM,uBAAuB,GAAG,IA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,MAAM,iBAAiB,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,iBAAiB,QAAQ,GAAG,uBAAuB,KAAK,CAAC,CAAC;YAC/D,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,gCAAgC,uBAAuB,MAAM;QAC3D,yDAAyD,CAC5D,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-tool-for-agents",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "terminal-tool-for-agents (tta) — terminal tool for AI agents. Command: tta. Package: terminal-tool-for-agents.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,6 +26,8 @@
26
26
  },
27
27
  "files": [
28
28
  "dist/",
29
+ ".npmrc",
30
+ "scripts/install.js",
29
31
  "skills/tta/SKILL.md",
30
32
  "skills/tta/tta-agents-skill.md",
31
33
  "src/watch-ui/logo.png",
@@ -37,6 +39,7 @@
37
39
  "dev": "node scripts/dev.mjs",
38
40
  "start": "node dist/cli.js",
39
41
  "test": "node scripts/verify.js",
42
+ "postinstall": "node scripts/install.js",
40
43
  "prepack": "npm run build",
41
44
  "prepublishOnly": "npm test",
42
45
  "release": "release-it"
@@ -60,8 +63,5 @@
60
63
  },
61
64
  "engines": {
62
65
  "node": ">=22.0.0 <27.0.0"
63
- },
64
- "allowScripts": {
65
- "node-pty@1.1.0": true
66
66
  }
67
67
  }
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Post-install: set up node-pty native bindings.
4
+ * Copies bundled prebuilds into build/Release (+ chmod on Unix), or rebuilds from source.
5
+ * Does not rely on node-pty install scripts (npm 11 may block dependency scripts).
6
+ */
7
+ const fs = require("fs");
8
+ const os = require("os");
9
+ const path = require("path");
10
+ const { execSync } = require("child_process");
11
+
12
+ const PKG = "tta";
13
+ const root = path.join(__dirname, "..");
14
+ const platformKey = `${process.platform}-${process.arch}`;
15
+
16
+ function findNodePtyRoot(fromDir = root) {
17
+ try {
18
+ return path.dirname(require.resolve("node-pty/package.json", { paths: [fromDir] }));
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+
24
+ function log(msg) {
25
+ process.stdout.write(`[${PKG}] ${msg}\n`);
26
+ }
27
+
28
+ function testNodePty(nodePtyDir) {
29
+ const tmpScript = path.join(os.tmpdir(), `${PKG}-test-pty-${process.pid}.js`);
30
+ try {
31
+ fs.writeFileSync(
32
+ tmpScript,
33
+ `
34
+ const pty = require(${JSON.stringify(nodePtyDir)});
35
+ const shell = process.platform === "win32" ? (process.env.ComSpec || "cmd.exe") : "/bin/sh";
36
+ const args = process.platform === "win32" ? ["/c", "exit /b 0"] : ["-c", "exit 0"];
37
+ const p = pty.spawn(shell, args, { name: "xterm", cols: 80, rows: 24 });
38
+ p.kill();
39
+ `
40
+ );
41
+ execSync(`node ${JSON.stringify(tmpScript)}`, { stdio: "ignore" });
42
+ return true;
43
+ } catch {
44
+ return false;
45
+ } finally {
46
+ try {
47
+ fs.unlinkSync(tmpScript);
48
+ } catch {
49
+ // ignore
50
+ }
51
+ }
52
+ }
53
+
54
+ function copyEntry(src, dest, entry) {
55
+ if (entry.isDirectory()) {
56
+ fs.mkdirSync(dest, { recursive: true });
57
+ for (const child of fs.readdirSync(src, { withFileTypes: true })) {
58
+ copyEntry(path.join(src, child.name), path.join(dest, child.name), child);
59
+ }
60
+ return;
61
+ }
62
+ fs.copyFileSync(src, dest);
63
+ if (process.platform !== "win32") {
64
+ const mode = fs.statSync(dest).mode;
65
+ if ((mode & 0o111) === 0 && (entry.name.endsWith(".node") || entry.name === "spawn-helper")) {
66
+ fs.chmodSync(dest, mode | 0o755);
67
+ }
68
+ }
69
+ }
70
+
71
+ function installPrebuild(nodePtyDir) {
72
+ const prebuildDir = path.join(nodePtyDir, "prebuilds", platformKey);
73
+ const prebuildPty = path.join(prebuildDir, "pty.node");
74
+ if (!fs.existsSync(prebuildPty)) {
75
+ log(`No prebuild for ${platformKey}`);
76
+ return false;
77
+ }
78
+
79
+ const targetDir = path.join(nodePtyDir, "build", "Release");
80
+ try {
81
+ fs.mkdirSync(targetDir, { recursive: true });
82
+ for (const entry of fs.readdirSync(prebuildDir, { withFileTypes: true })) {
83
+ copyEntry(path.join(prebuildDir, entry.name), path.join(targetDir, entry.name), entry);
84
+ }
85
+ log(`Installed prebuilt binary for ${platformKey}`);
86
+ return true;
87
+ } catch (err) {
88
+ process.stderr.write(`[${PKG}] Failed to install prebuild: ${err.message}\n`);
89
+ return false;
90
+ }
91
+ }
92
+
93
+ function buildFromSource(nodePtyDir) {
94
+ log("Building node-pty from source (this may take a minute)...");
95
+ try {
96
+ execSync("npx node-gyp rebuild", { stdio: "inherit", cwd: nodePtyDir });
97
+ return true;
98
+ } catch {
99
+ return false;
100
+ }
101
+ }
102
+
103
+ function exitWithBuildError() {
104
+ const fixes = {
105
+ darwin: " xcode-select --install\n npm install -g terminal-tool-for-agents",
106
+ linux:
107
+ " sudo apt-get install build-essential python3 g++\n npm install -g terminal-tool-for-agents",
108
+ };
109
+ const fix = fixes[process.platform] ?? " npm install -g terminal-tool-for-agents";
110
+ process.stderr.write(
111
+ `[${PKG}] node-pty native binding failed to load.\n\n[${PKG}] To fix:\n${fix}\n`
112
+ );
113
+ process.exit(1);
114
+ }
115
+
116
+ function killallSessions() {
117
+ try {
118
+ execSync("tta sess killall", { stdio: "ignore" });
119
+ } catch {
120
+ // no server or nothing to kill
121
+ }
122
+ }
123
+
124
+ function ensureNodePty(nodePtyDir) {
125
+ log(`Platform: ${platformKey}`);
126
+
127
+ if (testNodePty(nodePtyDir)) {
128
+ log("node-pty is ready");
129
+ return;
130
+ }
131
+
132
+ if (installPrebuild(nodePtyDir) && testNodePty(nodePtyDir)) {
133
+ log("Prebuilt binary works");
134
+ return;
135
+ }
136
+
137
+ if (buildFromSource(nodePtyDir) && testNodePty(nodePtyDir)) {
138
+ log("node-pty built successfully");
139
+ return;
140
+ }
141
+
142
+ exitWithBuildError();
143
+ }
144
+
145
+ if (require.main === module) {
146
+ const nodePtyDir = findNodePtyRoot();
147
+ if (!nodePtyDir) {
148
+ process.stderr.write(`[${PKG}] node-pty not found\n`);
149
+ process.exit(1);
150
+ }
151
+ ensureNodePty(nodePtyDir);
152
+ killallSessions();
153
+ }
154
+
155
+ module.exports = { findNodePtyRoot, testNodePty, ensureNodePty, killallSessions };
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: tta
3
- version: 0.1.5
4
- description: Operate interactive CLI, TUI, and dev-server sessions through a PTY. Use when a command needs keystrokes, redraws a terminal UI, step-by-step screen reads, or for npm create, lazygit, npm run dev, etc. Not for plain non-interactive bash. APIs: sess, act, obs. Bundled tta-agents sub-skill when the user uses tta with coding agents.
3
+ version: 0.1.6
4
+ description: "Operate interactive CLI, TUI, and dev-server sessions through a PTY. Use when a command needs keystrokes, redraws a terminal UI, step-by-step screen reads, or for npm create, lazygit, npm run dev, etc. Not for plain non-interactive bash. APIs: sess, act, obs. Bundled tta-agents sub-skill when the user uses tta with coding agents."
5
5
  ---
6
6
 
7
7
  # tta - terminal tool for agents
@@ -40,7 +40,7 @@ All tta work happens inside a **session** (PTY-backed terminal instance): `tta s
40
40
  Follow in order; do not skip steps:
41
41
 
42
42
  1. **Pick the tool** — interactive / TUI / needs step-by-step screen reads → `tta`; otherwise shell
43
- 2. **Start and read** — `tta sess start` (see **Parameter quoting**), then `tta obs screen stable --sess=<name>`
43
+ 2. **Start and read** — `tta sess start` (see **Command writing** and **Parameter quoting**), then `tta obs screen stable --sess=<name>`
44
44
  3. **Choose input by screen**
45
45
  - TUI menu, numbered options, `[Y/n]` → `tta act send key` (keys only, not text)
46
46
  - Free-form shell input → quoted heredoc, then Enter:
@@ -93,6 +93,12 @@ Coding agent workers (multi-turn context) — see [`tta-agents-skill.md`](./tta-
93
93
  - Do not rely on `act` stdout; use `obs` to read the screen
94
94
  - Do not use `tta sess watch`
95
95
 
96
+ ## Command writing
97
+
98
+ - Each `tta` command on **one line**; do not use `\` line continuation
99
+ - **No shell variables** in `--cmd=`, `--cwd=`, etc. (`$VAR`); use absolute paths and full command literals
100
+ - `act send text` must use **`<<'EOF'`**; do not use `<<EOF`
101
+
96
102
  ## Parameter quoting
97
103
 
98
104
  | Flag | Used by | Quoting |
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: tta-agents
3
- version: 0.1.5
4
- description: Bundled tta sub-skill. When triggered: current agent is Orchestrator; serially schedules multiple workers (separated concerns, e.g. code/review/test). Workers cannot use tta; feedback relayed by Orchestrator. Must obey user permission scope. Use when driving coding agents via tta or when user mentions Orchestrator/Worker.
3
+ version: 0.1.6
4
+ description: "Bundled tta sub-skill. When triggered: current agent is Orchestrator; serially schedules multiple workers (separated concerns, e.g. code/review/test). Workers cannot use tta; feedback relayed by Orchestrator. Must obey user permission scope. Use when driving coding agents via tta or when user mentions Orchestrator/Worker."
5
5
  ---
6
6
 
7
7
  # tta-agents - orchestrate coding agents with tta