autohand-cli 0.6.1 → 0.6.2
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/agents-32JB7KMB.js +9 -0
- package/dist/agents-3K6PHXQ6.js +9 -0
- package/dist/agents-A7AUMVQD.js +8 -0
- package/dist/agents-AHFECO5Q.js +9 -0
- package/dist/agents-DQFYBMJG.js +8 -0
- package/dist/agents-GX6L7BXZ.js +9 -0
- package/dist/agents-IWJJ7YJM.js +8 -0
- package/dist/agents-J2QLDVOP.js +9 -0
- package/dist/agents-OWTSY74S.js +9 -0
- package/dist/agents-RB34F4XE.js +9 -0
- package/dist/agents-XL27P67O.js +9 -0
- package/dist/agents-new-5I3B2W2I.js +9 -0
- package/dist/agents-new-CHV2AV34.js +9 -0
- package/dist/agents-new-F6F2VMDB.js +9 -0
- package/dist/agents-new-FDMUH7NL.js +9 -0
- package/dist/agents-new-GBF6JJIA.js +9 -0
- package/dist/agents-new-GCZEY4TE.js +8 -0
- package/dist/agents-new-OCIB72NU.js +9 -0
- package/dist/agents-new-PQGD47BZ.js +9 -0
- package/dist/agents-new-V6BNVJAB.js +9 -0
- package/dist/agents-new-WQUEZ2XH.js +8 -0
- package/dist/chunk-2DEJU7WQ.js +373 -0
- package/dist/chunk-2EPIFDFM.js +68 -0
- package/dist/chunk-2FUWKZFN.js +68 -0
- package/dist/chunk-2HIILNYH.js +197 -0
- package/dist/chunk-2QAL3HH4.js +79 -0
- package/dist/chunk-3FRM7HJY.js +57 -0
- package/dist/chunk-4LDR3Y3A.js +79 -0
- package/dist/{chunk-PDF2U23T.js → chunk-4LLTISFP.js} +1 -1
- package/dist/chunk-4UISIRMD.js +288 -0
- package/dist/chunk-4VWPX2X3.js +131 -0
- package/dist/chunk-7FMMKTRG.js +64 -0
- package/dist/chunk-7MFSCH7E.js +382 -0
- package/dist/chunk-7TV5KURP.js +79 -0
- package/dist/chunk-7WBK33MM.js +57 -0
- package/dist/chunk-7XN6PAKV.js +79 -0
- package/dist/chunk-A7HRTONQ.js +382 -0
- package/dist/chunk-ALMJANSA.js +197 -0
- package/dist/chunk-CD7GNBIE.js +288 -0
- package/dist/chunk-CV3LEQRD.js +57 -0
- package/dist/chunk-DAHMHLM6.js +102 -0
- package/dist/chunk-DAMLAWGE.js +68 -0
- package/dist/chunk-F4YPGOQJ.js +105 -0
- package/dist/chunk-FQDXFNOI.js +57 -0
- package/dist/chunk-FQI7EJY2.js +105 -0
- package/dist/chunk-GAJCZDZ5.js +286 -0
- package/dist/chunk-GEOP77H3.js +79 -0
- package/dist/chunk-GRX3IQHC.js +131 -0
- package/dist/chunk-GX24PC3L.js +288 -0
- package/dist/chunk-H53NQAC2.js +131 -0
- package/dist/chunk-HJYISR7Y.js +382 -0
- package/dist/chunk-HLSI4HQM.js +105 -0
- package/dist/chunk-IAOMCEYU.js +68 -0
- package/dist/chunk-J7RENRJG.js +382 -0
- package/dist/chunk-JUDX6E53.js +105 -0
- package/dist/chunk-JZQKOM7X.js +382 -0
- package/dist/chunk-K75NWR5V.js +108 -0
- package/dist/chunk-KCMWJB53.js +288 -0
- package/dist/chunk-KERHTHMK.js +302 -0
- package/dist/chunk-KJ4M6KAK.js +57 -0
- package/dist/chunk-L3JXU574.js +77 -0
- package/dist/chunk-LR2XPUPT.js +236 -0
- package/dist/chunk-MCWNGAZG.js +198 -0
- package/dist/chunk-MQTBFYEG.js +288 -0
- package/dist/chunk-NCUJWSGP.js +287 -0
- package/dist/chunk-NWEUBPSG.js +79 -0
- package/dist/chunk-OJ5EBWOQ.js +232 -0
- package/dist/chunk-PKQZWNS2.js +131 -0
- package/dist/chunk-PQJIQBQ5.js +57 -0
- package/dist/chunk-PX5AGAEX.js +105 -0
- package/dist/chunk-Q7HX4VZD.js +197 -0
- package/dist/chunk-QE5RKNVN.js +30 -0
- package/dist/chunk-QLVXFPE3.js +145 -0
- package/dist/chunk-QUC577LO.js +79 -0
- package/dist/chunk-RAL2W5UX.js +55 -0
- package/dist/chunk-RANNBYFJ.js +105 -0
- package/dist/chunk-RCSSFUGL.js +131 -0
- package/dist/chunk-RUQVXU6K.js +131 -0
- package/dist/chunk-RZ7TASUI.js +57 -0
- package/dist/chunk-SN7D2PJO.js +68 -0
- package/dist/chunk-T4WQUJAE.js +79 -0
- package/dist/chunk-U2Z5BABG.js +57 -0
- package/dist/chunk-UHC4DIK5.js +105 -0
- package/dist/chunk-UNS4S6J3.js +197 -0
- package/dist/chunk-UW2LYWIM.js +131 -0
- package/dist/chunk-VRCQBFSX.js +102 -0
- package/dist/chunk-W76N6IZV.js +197 -0
- package/dist/chunk-WTEZYXD2.js +67 -0
- package/dist/chunk-X7EWON4T.js +105 -0
- package/dist/chunk-XARAKKJ4.js +197 -0
- package/dist/chunk-Y6JDGDEE.js +197 -0
- package/dist/chunk-Y7FSNXMR.js +382 -0
- package/dist/chunk-YPZMUIB5.js +50 -0
- package/dist/chunk-ZMDUVLR4.js +148 -0
- package/dist/chunk-ZRFAICDG.js +382 -0
- package/dist/export-HEFUNSR4.js +8 -0
- package/dist/feedback-3U2WYQK6.js +9 -0
- package/dist/feedback-5IIX372K.js +9 -0
- package/dist/feedback-6S6DWGIU.js +9 -0
- package/dist/feedback-7DEOY2AP.js +9 -0
- package/dist/feedback-BBQT42R6.js +9 -0
- package/dist/feedback-CGCSAWQT.js +9 -0
- package/dist/feedback-NEDFOKMA.js +9 -0
- package/dist/feedback-OXGGJVNA.js +9 -0
- package/dist/feedback-ZJECE2FS.js +8 -0
- package/dist/help-NQUZ7TNJ.js +10 -0
- package/dist/index.cjs +16 -2
- package/dist/index.js +2 -2
- package/dist/login-D53NQ7UY.js +10 -0
- package/dist/login-GPXDNB2F.js +10 -0
- package/dist/login-HDF4GSTP.js +10 -0
- package/dist/login-SDAZTJAK.js +10 -0
- package/dist/login-SM6LEDDA.js +10 -0
- package/dist/login-TDI7HBRZ.js +10 -0
- package/dist/login-Y7XXSNOZ.js +10 -0
- package/dist/logout-32RNT7G2.js +10 -0
- package/dist/logout-43W7N6JU.js +10 -0
- package/dist/logout-BMHTSXIY.js +10 -0
- package/dist/logout-JNNJJYYL.js +10 -0
- package/dist/logout-LW42QASH.js +10 -0
- package/dist/logout-QLWM6P26.js +10 -0
- package/dist/logout-TL7GLGWU.js +10 -0
- package/dist/memory-GVYG653L.js +8 -0
- package/dist/new-MCN36AOD.js +8 -0
- package/dist/{status-5UF37IH2.js → status-DCVSUWZG.js} +1 -1
- package/dist/status-F6TQOCON.js +8 -0
- package/dist/status-IT5CYW37.js +8 -0
- package/dist/status-MRJOSVE3.js +8 -0
- package/dist/status-MWFV2DZG.js +8 -0
- package/dist/status-N3PMJRSB.js +8 -0
- package/dist/status-NK7YSBXZ.js +8 -0
- package/dist/status-QLQ5ZKJ3.js +8 -0
- package/dist/status-SQEFMII5.js +8 -0
- package/dist/status-U33PEUBO.js +8 -0
- package/dist/status-XAJH67SE.js +8 -0
- package/package.json +16 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTOHAND_PATHS
|
|
3
|
+
} from "./chunk-WTEZYXD2.js";
|
|
4
|
+
|
|
5
|
+
// src/commands/agents-new.ts
|
|
6
|
+
import path from "path";
|
|
7
|
+
import fs from "fs-extra";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import enquirer from "enquirer";
|
|
10
|
+
var metadata = {
|
|
11
|
+
command: "/agents new",
|
|
12
|
+
description: "create a new sub-agent from a description",
|
|
13
|
+
implemented: true,
|
|
14
|
+
prd: "prd/sub_agents_architecture.md"
|
|
15
|
+
};
|
|
16
|
+
async function createAgent(ctx) {
|
|
17
|
+
const answers = await enquirer.prompt([
|
|
18
|
+
{
|
|
19
|
+
type: "input",
|
|
20
|
+
name: "name",
|
|
21
|
+
message: "Agent name (e.g., Researcher, QA Tester)",
|
|
22
|
+
validate: (val) => typeof val === "string" && val.trim() ? true : "Name is required"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "input",
|
|
26
|
+
name: "description",
|
|
27
|
+
message: "Briefly describe what the agent should do"
|
|
28
|
+
}
|
|
29
|
+
]);
|
|
30
|
+
const name = answers.name.trim();
|
|
31
|
+
const description = answers.description.trim();
|
|
32
|
+
if (!name) {
|
|
33
|
+
console.log(chalk.gray("Canceled: no name provided."));
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const filename = await ensureUniqueFilename(name);
|
|
37
|
+
const filePath = path.join(getAgentsDir(), filename);
|
|
38
|
+
const prompt = buildPrompt(name, description);
|
|
39
|
+
let content;
|
|
40
|
+
try {
|
|
41
|
+
const completion = await ctx.llm.complete({
|
|
42
|
+
messages: [
|
|
43
|
+
{
|
|
44
|
+
role: "system",
|
|
45
|
+
content: "You generate concise markdown definitions for sub-agents. Output only markdown with no code fences. Keep it short but complete."
|
|
46
|
+
},
|
|
47
|
+
{ role: "user", content: prompt }
|
|
48
|
+
],
|
|
49
|
+
maxTokens: 600
|
|
50
|
+
});
|
|
51
|
+
content = completion.content.trim();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(chalk.red(`Failed to generate agent: ${error.message}`));
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await fs.ensureDir(getAgentsDir());
|
|
58
|
+
await fs.writeFile(filePath, content + "\n", "utf8");
|
|
59
|
+
console.log(chalk.green(`Saved new agent to ${filePath}`));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error(chalk.red(`Failed to save agent: ${error.message}`));
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
function buildPrompt(name, description) {
|
|
67
|
+
return [
|
|
68
|
+
`Create a sub-agent markdown file for "${name}".`,
|
|
69
|
+
description ? `Agent description: ${description}` : "",
|
|
70
|
+
"Structure it as:",
|
|
71
|
+
"# <Name>",
|
|
72
|
+
"## Purpose",
|
|
73
|
+
"## Operating Mode (bullet list)",
|
|
74
|
+
"## Tools (bullet list; mention existing CLI tools and constraints briefly)",
|
|
75
|
+
"## Output Contract (what to return to main agent)",
|
|
76
|
+
"Be concise, 120-160 words total."
|
|
77
|
+
].filter(Boolean).join("\n");
|
|
78
|
+
}
|
|
79
|
+
function getAgentsDir() {
|
|
80
|
+
return AUTOHAND_PATHS.agents;
|
|
81
|
+
}
|
|
82
|
+
function slugify(input) {
|
|
83
|
+
return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "agent";
|
|
84
|
+
}
|
|
85
|
+
async function ensureUniqueFilename(name) {
|
|
86
|
+
const base = slugify(name);
|
|
87
|
+
const dir = getAgentsDir();
|
|
88
|
+
let candidate = `${base}.md`;
|
|
89
|
+
let counter = 1;
|
|
90
|
+
while (await fs.pathExists(path.join(dir, candidate))) {
|
|
91
|
+
candidate = `${base}-${counter}.md`;
|
|
92
|
+
counter += 1;
|
|
93
|
+
}
|
|
94
|
+
return candidate;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
metadata,
|
|
99
|
+
createAgent
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* @license
|
|
103
|
+
* Copyright 2025 Autohand AI LLC
|
|
104
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
105
|
+
*/
|
|
@@ -0,0 +1,286 @@
|
|
|
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.1.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
|
+
enquirer: "^2.4.1",
|
|
48
|
+
"fs-extra": "^11.3.2",
|
|
49
|
+
ignore: "^5.3.1",
|
|
50
|
+
ink: "^4.4.1",
|
|
51
|
+
ora: "^9.0.0",
|
|
52
|
+
react: "^18.2.0",
|
|
53
|
+
"terminal-link": "^3.0.0",
|
|
54
|
+
yaml: "^2.8.2",
|
|
55
|
+
zod: "^4.1.12"
|
|
56
|
+
},
|
|
57
|
+
devDependencies: {
|
|
58
|
+
"@types/diff": "^8.0.0",
|
|
59
|
+
"@types/fs-extra": "^11.0.4",
|
|
60
|
+
"@types/node": "^24.10.1",
|
|
61
|
+
"@types/react": "^18.3.3",
|
|
62
|
+
"@types/terminal-link": "^1.2.0",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
64
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
65
|
+
eslint: "^9.39.1",
|
|
66
|
+
"react-devtools-core": "^7.0.1",
|
|
67
|
+
tsup: "^8.5.1",
|
|
68
|
+
tsx: "^4.20.6",
|
|
69
|
+
typescript: "^5.9.3",
|
|
70
|
+
vitest: "^1.6.0"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/commands/status.ts
|
|
75
|
+
var metadata = {
|
|
76
|
+
command: "/status",
|
|
77
|
+
description: "Show Autohand status including version, model, API connectivity, and usage",
|
|
78
|
+
implemented: true
|
|
79
|
+
};
|
|
80
|
+
async function status(ctx) {
|
|
81
|
+
const data = await gatherStatusData(ctx);
|
|
82
|
+
await renderStatusUI(data);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
async function gatherStatusData(ctx) {
|
|
86
|
+
const currentSession = ctx.sessionManager.getCurrentSession();
|
|
87
|
+
const allSessions = await ctx.sessionManager.listSessions();
|
|
88
|
+
let apiConnected = false;
|
|
89
|
+
try {
|
|
90
|
+
apiConnected = await ctx.llm.isAvailable();
|
|
91
|
+
} catch {
|
|
92
|
+
apiConnected = false;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
version: package_default.version,
|
|
96
|
+
sessionId: currentSession?.metadata.sessionId ?? null,
|
|
97
|
+
cwd: ctx.workspaceRoot,
|
|
98
|
+
provider: ctx.provider ?? "openrouter",
|
|
99
|
+
model: ctx.model,
|
|
100
|
+
apiConnected,
|
|
101
|
+
sessionsCount: allSessions.length,
|
|
102
|
+
contextPercentLeft: ctx.getContextPercentLeft?.() ?? 100,
|
|
103
|
+
totalTokensUsed: ctx.getTotalTokensUsed?.() ?? 0,
|
|
104
|
+
config: ctx.config
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function renderStatusUI(data) {
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
const tabs = ["Status", "Config", "Usage"];
|
|
110
|
+
let currentTab = 0;
|
|
111
|
+
const input = process.stdin;
|
|
112
|
+
const isTTY = input.isTTY;
|
|
113
|
+
const wasRaw = input.isRaw;
|
|
114
|
+
const wasPaused = typeof input.isPaused === "function" ? input.isPaused() : false;
|
|
115
|
+
if (wasPaused && typeof input.resume === "function") {
|
|
116
|
+
input.resume();
|
|
117
|
+
}
|
|
118
|
+
if (isTTY) {
|
|
119
|
+
readline.emitKeypressEvents(input);
|
|
120
|
+
if (!wasRaw && typeof input.setRawMode === "function") {
|
|
121
|
+
input.setRawMode(true);
|
|
122
|
+
}
|
|
123
|
+
if (typeof input.setEncoding === "function") {
|
|
124
|
+
input.setEncoding("utf8");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const render = () => {
|
|
128
|
+
process.stdout.write("\x1B[2J\x1B[H");
|
|
129
|
+
renderTabHeader(tabs, currentTab);
|
|
130
|
+
renderTabContent(tabs[currentTab], data);
|
|
131
|
+
console.log(chalk.gray("\nEsc to exit"));
|
|
132
|
+
};
|
|
133
|
+
let buffer = "";
|
|
134
|
+
const handler = (chunk) => {
|
|
135
|
+
buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
136
|
+
const processNext = () => {
|
|
137
|
+
if (!buffer.length) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
const first = buffer[0];
|
|
141
|
+
if (first === "\x1B") {
|
|
142
|
+
if (buffer.length === 1) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (buffer[1] === "[") {
|
|
146
|
+
if (buffer.length < 3) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
const seq = buffer.slice(0, 3);
|
|
150
|
+
buffer = buffer.slice(3);
|
|
151
|
+
handleSequence(seq);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
buffer = buffer.slice(1);
|
|
155
|
+
handleSequence("\x1B");
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
buffer = buffer.slice(1);
|
|
159
|
+
handleSequence(first);
|
|
160
|
+
return true;
|
|
161
|
+
};
|
|
162
|
+
while (processNext()) {
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const handleSequence = (sequence) => {
|
|
166
|
+
switch (sequence) {
|
|
167
|
+
case "\x1B":
|
|
168
|
+
// ESC
|
|
169
|
+
case "":
|
|
170
|
+
cleanup();
|
|
171
|
+
resolve();
|
|
172
|
+
return;
|
|
173
|
+
case " ":
|
|
174
|
+
// Tab
|
|
175
|
+
case "\x1B[C":
|
|
176
|
+
currentTab = (currentTab + 1) % tabs.length;
|
|
177
|
+
render();
|
|
178
|
+
return;
|
|
179
|
+
case "\x1B[Z":
|
|
180
|
+
// Shift+Tab
|
|
181
|
+
case "\x1B[D":
|
|
182
|
+
currentTab = (currentTab - 1 + tabs.length) % tabs.length;
|
|
183
|
+
render();
|
|
184
|
+
return;
|
|
185
|
+
default:
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const cleanup = () => {
|
|
190
|
+
input.off("data", handler);
|
|
191
|
+
if (isTTY && !wasRaw && typeof input.setRawMode === "function") {
|
|
192
|
+
input.setRawMode(false);
|
|
193
|
+
}
|
|
194
|
+
if (wasPaused && typeof input.pause === "function") {
|
|
195
|
+
input.pause();
|
|
196
|
+
}
|
|
197
|
+
process.stdout.write("\x1B[2J\x1B[H");
|
|
198
|
+
};
|
|
199
|
+
input.on("data", handler);
|
|
200
|
+
render();
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function renderTabHeader(tabs, currentIndex) {
|
|
204
|
+
const header = tabs.map((tab, i) => {
|
|
205
|
+
return i === currentIndex ? chalk.bgWhite.black(` ${tab} `) : chalk.gray(` ${tab} `);
|
|
206
|
+
}).join(" ");
|
|
207
|
+
console.log(`Settings: ${header} ${chalk.gray("(tab to cycle)")}
|
|
208
|
+
`);
|
|
209
|
+
}
|
|
210
|
+
function renderTabContent(tab, data) {
|
|
211
|
+
switch (tab) {
|
|
212
|
+
case "Status":
|
|
213
|
+
renderStatusTab(data);
|
|
214
|
+
break;
|
|
215
|
+
case "Config":
|
|
216
|
+
renderConfigTab(data);
|
|
217
|
+
break;
|
|
218
|
+
case "Usage":
|
|
219
|
+
renderUsageTab(data);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function renderStatusTab(data) {
|
|
224
|
+
console.log(chalk.bold("Version:"), data.version);
|
|
225
|
+
console.log(chalk.bold("Session ID:"), data.sessionId ?? chalk.gray("none"));
|
|
226
|
+
console.log(chalk.bold("cwd:"), data.cwd);
|
|
227
|
+
console.log(chalk.bold("Provider:"), data.provider);
|
|
228
|
+
console.log(chalk.bold("Model:"), data.model);
|
|
229
|
+
console.log();
|
|
230
|
+
console.log(
|
|
231
|
+
chalk.bold("API Status:"),
|
|
232
|
+
data.apiConnected ? chalk.green("Connected") : chalk.red("Disconnected")
|
|
233
|
+
);
|
|
234
|
+
console.log(chalk.bold("Sessions:"), `${data.sessionsCount} total`);
|
|
235
|
+
console.log(chalk.bold("Memory:"), "user (~/.autohand/memory/), project (.autohand/memory/)");
|
|
236
|
+
}
|
|
237
|
+
function renderConfigTab(data) {
|
|
238
|
+
const config = data.config;
|
|
239
|
+
console.log(chalk.bold("Autohand preferences\n"));
|
|
240
|
+
const settings = [
|
|
241
|
+
["Theme", config?.ui?.theme ?? "dark"],
|
|
242
|
+
["Auto-confirm", config?.ui?.autoConfirm ? "true" : "false"],
|
|
243
|
+
["Show thinking", config?.ui?.showThinking !== false ? "true" : "false"],
|
|
244
|
+
["Show completion notification", config?.ui?.showCompletionNotification !== false ? "true" : "false"],
|
|
245
|
+
["Permission mode", config?.permissions?.mode ?? "interactive"],
|
|
246
|
+
["Telemetry", config?.telemetry?.enabled !== false ? "true" : "false"],
|
|
247
|
+
["Network retries", String(config?.network?.maxRetries ?? 3)],
|
|
248
|
+
["Network timeout", `${config?.network?.timeout ?? 3e4}ms`]
|
|
249
|
+
];
|
|
250
|
+
for (const [name, value] of settings) {
|
|
251
|
+
console.log(` ${chalk.cyan(name.padEnd(30))} ${value}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function renderUsageTab(data) {
|
|
255
|
+
const contextUsed = 100 - data.contextPercentLeft;
|
|
256
|
+
console.log(chalk.bold("Current session\n"));
|
|
257
|
+
renderProgressBar("Context used", contextUsed, 100);
|
|
258
|
+
console.log();
|
|
259
|
+
console.log(chalk.bold("Tokens used:"), formatTokens(data.totalTokensUsed));
|
|
260
|
+
}
|
|
261
|
+
function renderProgressBar(label, value, max) {
|
|
262
|
+
const width = 30;
|
|
263
|
+
const filled = Math.round(value / max * width);
|
|
264
|
+
const empty = width - filled;
|
|
265
|
+
const bar = chalk.cyan("\u2588".repeat(filled)) + chalk.gray("\u2591".repeat(empty));
|
|
266
|
+
const percent = Math.round(value / max * 100);
|
|
267
|
+
console.log(label);
|
|
268
|
+
console.log(`${bar} ${percent}% used`);
|
|
269
|
+
}
|
|
270
|
+
function formatTokens(tokens) {
|
|
271
|
+
if (tokens >= 1e3) {
|
|
272
|
+
return `${(tokens / 1e3).toFixed(1)}k tokens`;
|
|
273
|
+
}
|
|
274
|
+
return `${tokens} tokens`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export {
|
|
278
|
+
package_default,
|
|
279
|
+
metadata,
|
|
280
|
+
status
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* @license
|
|
284
|
+
* Copyright 2025 Autohand AI LLC
|
|
285
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
286
|
+
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTOHAND_FILES
|
|
3
|
+
} from "./chunk-IAOMCEYU.js";
|
|
4
|
+
|
|
5
|
+
// src/commands/feedback.ts
|
|
6
|
+
import fs from "fs-extra";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import enquirer from "enquirer";
|
|
9
|
+
var metadata = {
|
|
10
|
+
command: "/feedback",
|
|
11
|
+
description: "share feedback with environment details",
|
|
12
|
+
implemented: true
|
|
13
|
+
};
|
|
14
|
+
async function feedback(_ctx) {
|
|
15
|
+
const answer = await enquirer.prompt([
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "feedback",
|
|
19
|
+
message: "What worked? What broke?"
|
|
20
|
+
}
|
|
21
|
+
]);
|
|
22
|
+
if (!answer.feedback?.trim()) {
|
|
23
|
+
console.log(chalk.gray("Feedback discarded (empty)."));
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
27
|
+
const runtimeError = getLastRuntimeError();
|
|
28
|
+
const payload = {
|
|
29
|
+
timestamp: now,
|
|
30
|
+
feedback: answer.feedback.trim(),
|
|
31
|
+
env: {
|
|
32
|
+
platform: `${process.platform}-${process.arch}`,
|
|
33
|
+
node: process.version,
|
|
34
|
+
bun: process.versions?.bun,
|
|
35
|
+
cwd: process.cwd(),
|
|
36
|
+
shell: process.env.SHELL
|
|
37
|
+
},
|
|
38
|
+
runtimeError: runtimeError ? formatError(runtimeError) : null
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
const feedbackPath = AUTOHAND_FILES.feedbackLog;
|
|
42
|
+
await fs.ensureFile(feedbackPath);
|
|
43
|
+
await fs.appendFile(feedbackPath, JSON.stringify(payload) + "\n", "utf8");
|
|
44
|
+
console.log(chalk.green("Feedback recorded."));
|
|
45
|
+
console.log(chalk.gray(`Saved to ${feedbackPath}`));
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(chalk.red(`Failed to save feedback: ${error.message}`));
|
|
48
|
+
}
|
|
49
|
+
if (runtimeError) {
|
|
50
|
+
console.log(chalk.yellow("Detected a recent runtime error; included in feedback payload."));
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function getLastRuntimeError() {
|
|
55
|
+
const globalAny = globalThis;
|
|
56
|
+
return globalAny.__autohandLastError ?? null;
|
|
57
|
+
}
|
|
58
|
+
function formatError(err) {
|
|
59
|
+
if (!err) return {};
|
|
60
|
+
if (err instanceof Error) {
|
|
61
|
+
return { message: err.message, stack: err.stack };
|
|
62
|
+
}
|
|
63
|
+
if (typeof err === "object") {
|
|
64
|
+
const message = "message" in err ? String(err.message) : void 0;
|
|
65
|
+
const stack = "stack" in err ? String(err.stack) : void 0;
|
|
66
|
+
return { message, stack };
|
|
67
|
+
}
|
|
68
|
+
return { message: String(err) };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
metadata,
|
|
73
|
+
feedback
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* @license
|
|
77
|
+
* Copyright 2025 Autohand AI LLC
|
|
78
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
79
|
+
*/
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAuthClient,
|
|
3
|
+
saveConfig
|
|
4
|
+
} from "./chunk-HJYISR7Y.js";
|
|
5
|
+
import {
|
|
6
|
+
AUTH_CONFIG
|
|
7
|
+
} from "./chunk-DAMLAWGE.js";
|
|
8
|
+
|
|
9
|
+
// src/commands/login.ts
|
|
10
|
+
import chalk from "chalk";
|
|
11
|
+
import enquirer from "enquirer";
|
|
12
|
+
var metadata = {
|
|
13
|
+
command: "/login",
|
|
14
|
+
description: "sign in to your Autohand account",
|
|
15
|
+
implemented: true
|
|
16
|
+
};
|
|
17
|
+
async function openBrowser(url) {
|
|
18
|
+
try {
|
|
19
|
+
const open = await import("open").then((m) => m.default).catch(() => null);
|
|
20
|
+
if (open) {
|
|
21
|
+
await open(url);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const { exec } = await import("child_process");
|
|
25
|
+
const { promisify } = await import("util");
|
|
26
|
+
const execAsync = promisify(exec);
|
|
27
|
+
const platform = process.platform;
|
|
28
|
+
let command;
|
|
29
|
+
if (platform === "darwin") {
|
|
30
|
+
command = `open "${url}"`;
|
|
31
|
+
} else if (platform === "win32") {
|
|
32
|
+
command = `start "" "${url}"`;
|
|
33
|
+
} else {
|
|
34
|
+
command = `xdg-open "${url}"`;
|
|
35
|
+
}
|
|
36
|
+
await execAsync(command);
|
|
37
|
+
return true;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function sleep(ms) {
|
|
43
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
44
|
+
}
|
|
45
|
+
async function login(ctx) {
|
|
46
|
+
const config = ctx.config;
|
|
47
|
+
if (config?.auth?.token && config?.auth?.user) {
|
|
48
|
+
const { continueLogin } = await enquirer.prompt({
|
|
49
|
+
type: "confirm",
|
|
50
|
+
name: "continueLogin",
|
|
51
|
+
message: `Already logged in as ${chalk.cyan(config.auth.user.email)}. Log in with a different account?`,
|
|
52
|
+
initial: false
|
|
53
|
+
});
|
|
54
|
+
if (!continueLogin) {
|
|
55
|
+
console.log(chalk.gray("Login cancelled."));
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const authClient = getAuthClient();
|
|
60
|
+
console.log(chalk.gray("Initiating authentication..."));
|
|
61
|
+
const initResult = await authClient.initiateDeviceAuth();
|
|
62
|
+
if (!initResult.success || !initResult.deviceCode || !initResult.userCode) {
|
|
63
|
+
console.log(chalk.red(`Failed to start login: ${initResult.error || "Unknown error"}`));
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
console.log();
|
|
67
|
+
console.log(chalk.bold("To sign in, visit:"));
|
|
68
|
+
console.log(chalk.cyan.underline(initResult.verificationUriComplete || `${AUTH_CONFIG.authorizationUrl}?code=${initResult.userCode}`));
|
|
69
|
+
console.log();
|
|
70
|
+
console.log(chalk.gray("Or enter this code manually:"));
|
|
71
|
+
console.log(chalk.bold.yellow(` ${initResult.userCode}`));
|
|
72
|
+
console.log();
|
|
73
|
+
const browserOpened = await openBrowser(
|
|
74
|
+
initResult.verificationUriComplete || `${AUTH_CONFIG.authorizationUrl}?code=${initResult.userCode}`
|
|
75
|
+
);
|
|
76
|
+
if (browserOpened) {
|
|
77
|
+
console.log(chalk.gray("Browser opened. Complete the login in your browser."));
|
|
78
|
+
} else {
|
|
79
|
+
console.log(chalk.yellow("Could not open browser automatically. Please visit the URL above."));
|
|
80
|
+
}
|
|
81
|
+
console.log();
|
|
82
|
+
console.log(chalk.gray("Waiting for authorization..."));
|
|
83
|
+
console.log(chalk.gray("(Press Ctrl+C to cancel)"));
|
|
84
|
+
const startTime = Date.now();
|
|
85
|
+
const timeout = AUTH_CONFIG.authTimeout;
|
|
86
|
+
const pollInterval = initResult.interval ? initResult.interval * 1e3 : AUTH_CONFIG.pollInterval;
|
|
87
|
+
let dots = 0;
|
|
88
|
+
const maxDots = 3;
|
|
89
|
+
while (Date.now() - startTime < timeout) {
|
|
90
|
+
process.stdout.write(`\r${chalk.gray("Waiting" + ".".repeat(dots + 1) + " ".repeat(maxDots - dots))}`);
|
|
91
|
+
dots = (dots + 1) % (maxDots + 1);
|
|
92
|
+
await sleep(pollInterval);
|
|
93
|
+
const pollResult = await authClient.pollDeviceAuth(initResult.deviceCode);
|
|
94
|
+
if (pollResult.status === "authorized" && pollResult.token && pollResult.user) {
|
|
95
|
+
process.stdout.write("\r" + " ".repeat(20) + "\r");
|
|
96
|
+
const expiresAt = new Date(Date.now() + AUTH_CONFIG.sessionExpiryDays * 24 * 60 * 60 * 1e3).toISOString();
|
|
97
|
+
const updatedConfig = {
|
|
98
|
+
...config,
|
|
99
|
+
auth: {
|
|
100
|
+
token: pollResult.token,
|
|
101
|
+
user: pollResult.user,
|
|
102
|
+
expiresAt
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
await saveConfig(updatedConfig);
|
|
106
|
+
console.log();
|
|
107
|
+
console.log(chalk.green("Login successful!"));
|
|
108
|
+
console.log(chalk.cyan(`Welcome, ${pollResult.user.name || pollResult.user.email}!`));
|
|
109
|
+
console.log();
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (pollResult.status === "expired") {
|
|
113
|
+
process.stdout.write("\r" + " ".repeat(20) + "\r");
|
|
114
|
+
console.log(chalk.red("Authorization code expired. Please try again."));
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
process.stdout.write("\r" + " ".repeat(20) + "\r");
|
|
119
|
+
console.log(chalk.red("Authorization timed out. Please try again."));
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
metadata,
|
|
125
|
+
login
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* @license
|
|
129
|
+
* Copyright 2025 Autohand AI LLC
|
|
130
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
131
|
+
*/
|