autohand-cli 0.2.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.
Potentially problematic release.
This version of autohand-cli might be problematic. Click here for more details.
- package/README.md +134 -0
- package/dist/agents-RB34F4XE.js +9 -0
- package/dist/agents-new-5I3B2W2I.js +9 -0
- package/dist/chunk-2EPIFDFM.js +68 -0
- package/dist/chunk-2NUX2RAI.js +145 -0
- package/dist/chunk-2QAL3HH4.js +79 -0
- package/dist/chunk-4UISIRMD.js +288 -0
- package/dist/chunk-55DQY6B5.js +49 -0
- package/dist/chunk-A7HRTONQ.js +382 -0
- package/dist/chunk-ALMJANSA.js +197 -0
- package/dist/chunk-GSOEIEOU.js +19 -0
- package/dist/chunk-I4HVBWYF.js +55 -0
- package/dist/chunk-KZ7VMQTC.js +20 -0
- package/dist/chunk-OC5YDNFC.js +373 -0
- package/dist/chunk-PQJIQBQ5.js +57 -0
- package/dist/chunk-PX5AGAEX.js +105 -0
- package/dist/chunk-QJ53OSGF.js +60 -0
- package/dist/chunk-SVLBJMYO.js +33 -0
- package/dist/chunk-TAZJSKFD.js +57 -0
- package/dist/chunk-TVWTD63Y.js +50 -0
- package/dist/chunk-UW2LYWIM.js +131 -0
- package/dist/chunk-VRI7EXV6.js +20 -0
- package/dist/chunk-XDVG3NM4.js +339 -0
- package/dist/chunk-YWKZF2SA.js +364 -0
- package/dist/chunk-ZWS3KSMK.js +30 -0
- package/dist/completion-Y42FKDT3.js +10 -0
- package/dist/export-WJ5P6E5Z.js +8 -0
- package/dist/feedback-NEDFOKMA.js +9 -0
- package/dist/formatters-UG6VZJJ5.js +8 -0
- package/dist/help-CNOV6OXY.js +10 -0
- package/dist/index.cjs +13418 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10450 -0
- package/dist/init-DML7AOII.js +8 -0
- package/dist/lint-TA2ZHVLM.js +8 -0
- package/dist/login-GPXDNB2F.js +10 -0
- package/dist/logout-43W7N6JU.js +10 -0
- package/dist/memory-4GSP7NKV.js +8 -0
- package/dist/model-HKEFSH5E.js +8 -0
- package/dist/new-EEZC4XXV.js +8 -0
- package/dist/quit-RSYIERO5.js +8 -0
- package/dist/resume-2NERFSTD.js +8 -0
- package/dist/session-H5QWKE5E.js +8 -0
- package/dist/sessions-4KXIT76T.js +8 -0
- package/dist/status-XAJH67SE.js +8 -0
- package/dist/undo-7QJBXARS.js +8 -0
- package/package.json +69 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// src/commands/status.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import readline from "readline";
|
|
4
|
+
|
|
5
|
+
// package.json
|
|
6
|
+
var package_default = {
|
|
7
|
+
name: "autohand-cli",
|
|
8
|
+
version: "0.2.0",
|
|
9
|
+
description: "Autohand interactive coding agent CLI powered by LLMs.",
|
|
10
|
+
type: "module",
|
|
11
|
+
bin: {
|
|
12
|
+
autohand: "dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
main: "dist/index.js",
|
|
15
|
+
files: [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
scripts: {
|
|
19
|
+
go: 'bun run build && ./install-local.sh && echo "COMPLETED"',
|
|
20
|
+
build: "tsup src/index.ts --format esm,cjs --dts",
|
|
21
|
+
dev: "tsx src/index.ts",
|
|
22
|
+
typecheck: "tsc --noEmit",
|
|
23
|
+
lint: "eslint .",
|
|
24
|
+
test: "vitest run",
|
|
25
|
+
start: "node dist/index.js",
|
|
26
|
+
"compile:macos-arm64": "bun build ./src/index.ts --compile --target=bun-darwin-arm64 --outfile ./binaries/autohand-macos-arm64",
|
|
27
|
+
"compile:macos-x64": "bun build ./src/index.ts --compile --target=bun-darwin-x64 --outfile ./binaries/autohand-macos-x64",
|
|
28
|
+
"compile:linux-x64": "bun build ./src/index.ts --compile --target=bun-linux-x64 --outfile ./binaries/autohand-linux-x64",
|
|
29
|
+
"compile:linux-arm64": "bun build ./src/index.ts --compile --target=bun-linux-arm64 --outfile ./binaries/autohand-linux-arm64",
|
|
30
|
+
"compile:windows-x64": "bun build ./src/index.ts --compile --target=bun-windows-x64 --outfile ./binaries/autohand-windows-x64.exe",
|
|
31
|
+
"compile:all": "bun run compile:macos-arm64 && bun run compile:macos-x64 && bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64",
|
|
32
|
+
link: "bun link"
|
|
33
|
+
},
|
|
34
|
+
keywords: [
|
|
35
|
+
"cli",
|
|
36
|
+
"llm",
|
|
37
|
+
"agent",
|
|
38
|
+
"autohand"
|
|
39
|
+
],
|
|
40
|
+
engines: {
|
|
41
|
+
node: ">=18.17.0"
|
|
42
|
+
},
|
|
43
|
+
dependencies: {
|
|
44
|
+
chalk: "^5.6.2",
|
|
45
|
+
commander: "^14.0.2",
|
|
46
|
+
diff: "^8.0.2",
|
|
47
|
+
dotenv: "^17.2.3",
|
|
48
|
+
enquirer: "^2.4.1",
|
|
49
|
+
"fs-extra": "^11.3.2",
|
|
50
|
+
ignore: "^5.3.1",
|
|
51
|
+
ink: "^4.4.1",
|
|
52
|
+
open: "^10.1.0",
|
|
53
|
+
ora: "^9.0.0",
|
|
54
|
+
react: "^18.2.0",
|
|
55
|
+
"terminal-link": "^3.0.0",
|
|
56
|
+
yaml: "^2.8.2",
|
|
57
|
+
zod: "^4.1.12"
|
|
58
|
+
},
|
|
59
|
+
devDependencies: {
|
|
60
|
+
"@types/diff": "^8.0.0",
|
|
61
|
+
"@types/fs-extra": "^11.0.4",
|
|
62
|
+
"@types/node": "^24.10.1",
|
|
63
|
+
"@types/react": "^18.3.3",
|
|
64
|
+
"@types/terminal-link": "^1.2.0",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
66
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
67
|
+
eslint: "^9.39.1",
|
|
68
|
+
"react-devtools-core": "^7.0.1",
|
|
69
|
+
tsup: "^8.5.1",
|
|
70
|
+
tsx: "^4.20.6",
|
|
71
|
+
typescript: "^5.9.3",
|
|
72
|
+
vitest: "^1.6.0"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/commands/status.ts
|
|
77
|
+
var metadata = {
|
|
78
|
+
command: "/status",
|
|
79
|
+
description: "Show Autohand status including version, model, API connectivity, and usage",
|
|
80
|
+
implemented: true
|
|
81
|
+
};
|
|
82
|
+
async function status(ctx) {
|
|
83
|
+
const data = await gatherStatusData(ctx);
|
|
84
|
+
await renderStatusUI(data);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
async function gatherStatusData(ctx) {
|
|
88
|
+
const currentSession = ctx.sessionManager.getCurrentSession();
|
|
89
|
+
const allSessions = await ctx.sessionManager.listSessions();
|
|
90
|
+
let apiConnected = false;
|
|
91
|
+
try {
|
|
92
|
+
apiConnected = await ctx.llm.isAvailable();
|
|
93
|
+
} catch {
|
|
94
|
+
apiConnected = false;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
version: package_default.version,
|
|
98
|
+
sessionId: currentSession?.metadata.sessionId ?? null,
|
|
99
|
+
cwd: ctx.workspaceRoot,
|
|
100
|
+
provider: ctx.provider ?? "openrouter",
|
|
101
|
+
model: ctx.model,
|
|
102
|
+
apiConnected,
|
|
103
|
+
sessionsCount: allSessions.length,
|
|
104
|
+
contextPercentLeft: ctx.getContextPercentLeft?.() ?? 100,
|
|
105
|
+
totalTokensUsed: ctx.getTotalTokensUsed?.() ?? 0,
|
|
106
|
+
config: ctx.config
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function renderStatusUI(data) {
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
const tabs = ["Status", "Config", "Usage"];
|
|
112
|
+
let currentTab = 0;
|
|
113
|
+
const input = process.stdin;
|
|
114
|
+
const isTTY = input.isTTY;
|
|
115
|
+
const wasRaw = input.isRaw;
|
|
116
|
+
const wasPaused = typeof input.isPaused === "function" ? input.isPaused() : false;
|
|
117
|
+
if (wasPaused && typeof input.resume === "function") {
|
|
118
|
+
input.resume();
|
|
119
|
+
}
|
|
120
|
+
if (isTTY) {
|
|
121
|
+
readline.emitKeypressEvents(input);
|
|
122
|
+
if (!wasRaw && typeof input.setRawMode === "function") {
|
|
123
|
+
input.setRawMode(true);
|
|
124
|
+
}
|
|
125
|
+
if (typeof input.setEncoding === "function") {
|
|
126
|
+
input.setEncoding("utf8");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const render = () => {
|
|
130
|
+
process.stdout.write("\x1B[2J\x1B[H");
|
|
131
|
+
renderTabHeader(tabs, currentTab);
|
|
132
|
+
renderTabContent(tabs[currentTab], data);
|
|
133
|
+
console.log(chalk.gray("\nEsc to exit"));
|
|
134
|
+
};
|
|
135
|
+
let buffer = "";
|
|
136
|
+
const handler = (chunk) => {
|
|
137
|
+
buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
138
|
+
const processNext = () => {
|
|
139
|
+
if (!buffer.length) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const first = buffer[0];
|
|
143
|
+
if (first === "\x1B") {
|
|
144
|
+
if (buffer.length === 1) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (buffer[1] === "[") {
|
|
148
|
+
if (buffer.length < 3) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
const seq = buffer.slice(0, 3);
|
|
152
|
+
buffer = buffer.slice(3);
|
|
153
|
+
handleSequence(seq);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
buffer = buffer.slice(1);
|
|
157
|
+
handleSequence("\x1B");
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
buffer = buffer.slice(1);
|
|
161
|
+
handleSequence(first);
|
|
162
|
+
return true;
|
|
163
|
+
};
|
|
164
|
+
while (processNext()) {
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const handleSequence = (sequence) => {
|
|
168
|
+
switch (sequence) {
|
|
169
|
+
case "\x1B":
|
|
170
|
+
// ESC
|
|
171
|
+
case "":
|
|
172
|
+
cleanup();
|
|
173
|
+
resolve();
|
|
174
|
+
return;
|
|
175
|
+
case " ":
|
|
176
|
+
// Tab
|
|
177
|
+
case "\x1B[C":
|
|
178
|
+
currentTab = (currentTab + 1) % tabs.length;
|
|
179
|
+
render();
|
|
180
|
+
return;
|
|
181
|
+
case "\x1B[Z":
|
|
182
|
+
// Shift+Tab
|
|
183
|
+
case "\x1B[D":
|
|
184
|
+
currentTab = (currentTab - 1 + tabs.length) % tabs.length;
|
|
185
|
+
render();
|
|
186
|
+
return;
|
|
187
|
+
default:
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const cleanup = () => {
|
|
192
|
+
input.off("data", handler);
|
|
193
|
+
if (isTTY && !wasRaw && typeof input.setRawMode === "function") {
|
|
194
|
+
input.setRawMode(false);
|
|
195
|
+
}
|
|
196
|
+
if (wasPaused && typeof input.pause === "function") {
|
|
197
|
+
input.pause();
|
|
198
|
+
}
|
|
199
|
+
process.stdout.write("\x1B[2J\x1B[H");
|
|
200
|
+
};
|
|
201
|
+
input.on("data", handler);
|
|
202
|
+
render();
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function renderTabHeader(tabs, currentIndex) {
|
|
206
|
+
const header = tabs.map((tab, i) => {
|
|
207
|
+
return i === currentIndex ? chalk.bgWhite.black(` ${tab} `) : chalk.gray(` ${tab} `);
|
|
208
|
+
}).join(" ");
|
|
209
|
+
console.log(`Settings: ${header} ${chalk.gray("(tab to cycle)")}
|
|
210
|
+
`);
|
|
211
|
+
}
|
|
212
|
+
function renderTabContent(tab, data) {
|
|
213
|
+
switch (tab) {
|
|
214
|
+
case "Status":
|
|
215
|
+
renderStatusTab(data);
|
|
216
|
+
break;
|
|
217
|
+
case "Config":
|
|
218
|
+
renderConfigTab(data);
|
|
219
|
+
break;
|
|
220
|
+
case "Usage":
|
|
221
|
+
renderUsageTab(data);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function renderStatusTab(data) {
|
|
226
|
+
console.log(chalk.bold("Version:"), data.version);
|
|
227
|
+
console.log(chalk.bold("Session ID:"), data.sessionId ?? chalk.gray("none"));
|
|
228
|
+
console.log(chalk.bold("cwd:"), data.cwd);
|
|
229
|
+
console.log(chalk.bold("Provider:"), data.provider);
|
|
230
|
+
console.log(chalk.bold("Model:"), data.model);
|
|
231
|
+
console.log();
|
|
232
|
+
console.log(
|
|
233
|
+
chalk.bold("API Status:"),
|
|
234
|
+
data.apiConnected ? chalk.green("Connected") : chalk.red("Disconnected")
|
|
235
|
+
);
|
|
236
|
+
console.log(chalk.bold("Sessions:"), `${data.sessionsCount} total`);
|
|
237
|
+
console.log(chalk.bold("Memory:"), "user (~/.autohand/memory/), project (.autohand/memory/)");
|
|
238
|
+
}
|
|
239
|
+
function renderConfigTab(data) {
|
|
240
|
+
const config = data.config;
|
|
241
|
+
console.log(chalk.bold("Autohand preferences\n"));
|
|
242
|
+
const settings = [
|
|
243
|
+
["Theme", config?.ui?.theme ?? "dark"],
|
|
244
|
+
["Auto-confirm", config?.ui?.autoConfirm ? "true" : "false"],
|
|
245
|
+
["Show thinking", config?.ui?.showThinking !== false ? "true" : "false"],
|
|
246
|
+
["Show completion notification", config?.ui?.showCompletionNotification !== false ? "true" : "false"],
|
|
247
|
+
["Permission mode", config?.permissions?.mode ?? "interactive"],
|
|
248
|
+
["Telemetry", config?.telemetry?.enabled !== false ? "true" : "false"],
|
|
249
|
+
["Network retries", String(config?.network?.maxRetries ?? 3)],
|
|
250
|
+
["Network timeout", `${config?.network?.timeout ?? 3e4}ms`]
|
|
251
|
+
];
|
|
252
|
+
for (const [name, value] of settings) {
|
|
253
|
+
console.log(` ${chalk.cyan(name.padEnd(30))} ${value}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function renderUsageTab(data) {
|
|
257
|
+
const contextUsed = 100 - data.contextPercentLeft;
|
|
258
|
+
console.log(chalk.bold("Current session\n"));
|
|
259
|
+
renderProgressBar("Context used", contextUsed, 100);
|
|
260
|
+
console.log();
|
|
261
|
+
console.log(chalk.bold("Tokens used:"), formatTokens(data.totalTokensUsed));
|
|
262
|
+
}
|
|
263
|
+
function renderProgressBar(label, value, max) {
|
|
264
|
+
const width = 30;
|
|
265
|
+
const filled = Math.round(value / max * width);
|
|
266
|
+
const empty = width - filled;
|
|
267
|
+
const bar = chalk.cyan("\u2588".repeat(filled)) + chalk.gray("\u2591".repeat(empty));
|
|
268
|
+
const percent = Math.round(value / max * 100);
|
|
269
|
+
console.log(label);
|
|
270
|
+
console.log(`${bar} ${percent}% used`);
|
|
271
|
+
}
|
|
272
|
+
function formatTokens(tokens) {
|
|
273
|
+
if (tokens >= 1e3) {
|
|
274
|
+
return `${(tokens / 1e3).toFixed(1)}k tokens`;
|
|
275
|
+
}
|
|
276
|
+
return `${tokens} tokens`;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export {
|
|
280
|
+
package_default,
|
|
281
|
+
metadata,
|
|
282
|
+
status
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* @license
|
|
286
|
+
* Copyright 2025 Autohand AI LLC
|
|
287
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
288
|
+
*/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/commands/resume.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
var metadata = {
|
|
4
|
+
command: "/resume",
|
|
5
|
+
description: "resume a previous session",
|
|
6
|
+
implemented: true
|
|
7
|
+
};
|
|
8
|
+
async function resume(ctx) {
|
|
9
|
+
const sessionId = ctx.args[0];
|
|
10
|
+
if (!sessionId) {
|
|
11
|
+
console.log(chalk.red("Usage: /resume <session-id>"));
|
|
12
|
+
console.log(chalk.gray("Use /sessions to list available sessions"));
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const session = await ctx.sessionManager.loadSession(sessionId);
|
|
17
|
+
const messages = session.getMessages();
|
|
18
|
+
console.log(chalk.cyan(`
|
|
19
|
+
\u{1F4C2} Resuming session ${sessionId}`));
|
|
20
|
+
console.log(chalk.gray(` Project: ${session.metadata.projectPath}`));
|
|
21
|
+
console.log(chalk.gray(` Started: ${new Date(session.metadata.createdAt).toLocaleString()}`));
|
|
22
|
+
console.log(chalk.gray(` Messages: ${messages.length}`));
|
|
23
|
+
console.log();
|
|
24
|
+
if (messages.length > 0) {
|
|
25
|
+
console.log(chalk.cyan("Recent conversation:"));
|
|
26
|
+
const recentMessages = messages.slice(-3);
|
|
27
|
+
for (const msg of recentMessages) {
|
|
28
|
+
const role = msg.role === "user" ? chalk.green("You") : chalk.blue("Assistant");
|
|
29
|
+
const preview = msg.content.slice(0, 80) + (msg.content.length > 80 ? "..." : "");
|
|
30
|
+
console.log(`${role}: ${chalk.gray(preview)}`);
|
|
31
|
+
}
|
|
32
|
+
console.log();
|
|
33
|
+
}
|
|
34
|
+
return "SESSION_RESUMED";
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error(chalk.red(`Failed to resume session: ${error.message}`));
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
metadata,
|
|
43
|
+
resume
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @license
|
|
47
|
+
* Copyright 2025 Autohand AI LLC
|
|
48
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
49
|
+
*/
|