@agtd/agent 0.1.0 → 0.1.1
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/dist/cli.js +49 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,11 @@ import {
|
|
|
5
5
|
startAgent
|
|
6
6
|
} from "./chunk-24ORBJSI.js";
|
|
7
7
|
|
|
8
|
+
// src/cli.ts
|
|
9
|
+
import { execSync } from "child_process";
|
|
10
|
+
import { createInterface as createInterface2 } from "readline/promises";
|
|
11
|
+
import { platform as platform2 } from "os";
|
|
12
|
+
|
|
8
13
|
// src/init.ts
|
|
9
14
|
import { createInterface } from "readline/promises";
|
|
10
15
|
import { mkdirSync, writeFileSync } from "fs";
|
|
@@ -125,12 +130,56 @@ Config is loaded from (in order):
|
|
|
125
130
|
5. Interactive setup (if none found)
|
|
126
131
|
`);
|
|
127
132
|
}
|
|
133
|
+
function hasTmux() {
|
|
134
|
+
try {
|
|
135
|
+
execSync("which tmux", { stdio: "ignore" });
|
|
136
|
+
return true;
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function ensureTmux() {
|
|
142
|
+
if (hasTmux()) return;
|
|
143
|
+
const os = platform2();
|
|
144
|
+
let installCmd;
|
|
145
|
+
if (os === "darwin") {
|
|
146
|
+
installCmd = "brew install tmux";
|
|
147
|
+
} else if (os === "linux") {
|
|
148
|
+
installCmd = "sudo apt install -y tmux";
|
|
149
|
+
} else {
|
|
150
|
+
console.error(
|
|
151
|
+
"tmux is required but not installed. Please install it manually."
|
|
152
|
+
);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
156
|
+
try {
|
|
157
|
+
const answer = await rl.question(
|
|
158
|
+
`tmux is required but not installed. Install with "${installCmd}"? (Y/n) `
|
|
159
|
+
);
|
|
160
|
+
if (answer.toLowerCase() === "n") {
|
|
161
|
+
console.error("tmux is required to run the agent.");
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
} finally {
|
|
165
|
+
rl.close();
|
|
166
|
+
}
|
|
167
|
+
console.log(`Running: ${installCmd}`);
|
|
168
|
+
try {
|
|
169
|
+
execSync(installCmd, { stdio: "inherit" });
|
|
170
|
+
console.log("tmux installed successfully.\n");
|
|
171
|
+
} catch {
|
|
172
|
+
console.error("Failed to install tmux. Please install it manually.");
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
128
176
|
async function main() {
|
|
129
177
|
const args = parseArgs(process.argv);
|
|
130
178
|
if (args.help) {
|
|
131
179
|
printHelp();
|
|
132
180
|
return;
|
|
133
181
|
}
|
|
182
|
+
await ensureTmux();
|
|
134
183
|
if (args.init) {
|
|
135
184
|
const config = await runInitWizard();
|
|
136
185
|
await startAgent(config);
|