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.
Files changed (48) hide show
  1. package/README.md +134 -0
  2. package/dist/agents-RB34F4XE.js +9 -0
  3. package/dist/agents-new-5I3B2W2I.js +9 -0
  4. package/dist/chunk-2EPIFDFM.js +68 -0
  5. package/dist/chunk-2NUX2RAI.js +145 -0
  6. package/dist/chunk-2QAL3HH4.js +79 -0
  7. package/dist/chunk-4UISIRMD.js +288 -0
  8. package/dist/chunk-55DQY6B5.js +49 -0
  9. package/dist/chunk-A7HRTONQ.js +382 -0
  10. package/dist/chunk-ALMJANSA.js +197 -0
  11. package/dist/chunk-GSOEIEOU.js +19 -0
  12. package/dist/chunk-I4HVBWYF.js +55 -0
  13. package/dist/chunk-KZ7VMQTC.js +20 -0
  14. package/dist/chunk-OC5YDNFC.js +373 -0
  15. package/dist/chunk-PQJIQBQ5.js +57 -0
  16. package/dist/chunk-PX5AGAEX.js +105 -0
  17. package/dist/chunk-QJ53OSGF.js +60 -0
  18. package/dist/chunk-SVLBJMYO.js +33 -0
  19. package/dist/chunk-TAZJSKFD.js +57 -0
  20. package/dist/chunk-TVWTD63Y.js +50 -0
  21. package/dist/chunk-UW2LYWIM.js +131 -0
  22. package/dist/chunk-VRI7EXV6.js +20 -0
  23. package/dist/chunk-XDVG3NM4.js +339 -0
  24. package/dist/chunk-YWKZF2SA.js +364 -0
  25. package/dist/chunk-ZWS3KSMK.js +30 -0
  26. package/dist/completion-Y42FKDT3.js +10 -0
  27. package/dist/export-WJ5P6E5Z.js +8 -0
  28. package/dist/feedback-NEDFOKMA.js +9 -0
  29. package/dist/formatters-UG6VZJJ5.js +8 -0
  30. package/dist/help-CNOV6OXY.js +10 -0
  31. package/dist/index.cjs +13418 -0
  32. package/dist/index.d.cts +1 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +10450 -0
  35. package/dist/init-DML7AOII.js +8 -0
  36. package/dist/lint-TA2ZHVLM.js +8 -0
  37. package/dist/login-GPXDNB2F.js +10 -0
  38. package/dist/logout-43W7N6JU.js +10 -0
  39. package/dist/memory-4GSP7NKV.js +8 -0
  40. package/dist/model-HKEFSH5E.js +8 -0
  41. package/dist/new-EEZC4XXV.js +8 -0
  42. package/dist/quit-RSYIERO5.js +8 -0
  43. package/dist/resume-2NERFSTD.js +8 -0
  44. package/dist/session-H5QWKE5E.js +8 -0
  45. package/dist/sessions-4KXIT76T.js +8 -0
  46. package/dist/status-XAJH67SE.js +8 -0
  47. package/dist/undo-7QJBXARS.js +8 -0
  48. package/package.json +69 -0
@@ -0,0 +1,364 @@
1
+ // src/commands/completion.ts
2
+ import chalk2 from "chalk";
3
+ import enquirer from "enquirer";
4
+
5
+ // src/completions/index.ts
6
+ import fs from "fs-extra";
7
+ import path from "path";
8
+ import os from "os";
9
+ import chalk from "chalk";
10
+ var DEFAULT_CONFIG = {
11
+ commands: ["autohand"],
12
+ slashCommands: [
13
+ "/quit",
14
+ "/model",
15
+ "/session",
16
+ "/sessions",
17
+ "/resume",
18
+ "/new",
19
+ "/undo",
20
+ "/memory",
21
+ "/init",
22
+ "/agents",
23
+ "/agents-new",
24
+ "/feedback",
25
+ "/help",
26
+ "/formatters",
27
+ "/lint",
28
+ "/export"
29
+ ],
30
+ options: [
31
+ { flag: "--prompt", description: "Run a single instruction" },
32
+ { flag: "--path", description: "Set workspace path" },
33
+ { flag: "--yes", description: "Auto-confirm all prompts" },
34
+ { flag: "--dry-run", description: "Preview without applying changes" },
35
+ { flag: "--model", description: "Override the LLM model" },
36
+ { flag: "--config", description: "Path to config file" },
37
+ { flag: "--temperature", description: "Sampling temperature" },
38
+ { flag: "--unrestricted", description: "Skip all approval prompts" },
39
+ { flag: "--restricted", description: "Block all dangerous operations" },
40
+ { flag: "--help", description: "Show help" },
41
+ { flag: "--version", description: "Show version" }
42
+ ]
43
+ };
44
+ function generateBashCompletion(config = DEFAULT_CONFIG) {
45
+ const slashCmds = config.slashCommands.join(" ");
46
+ const opts = config.options.map((o) => o.flag).join(" ");
47
+ return `#!/bin/bash
48
+ # Autohand CLI Bash Completion
49
+ # Add to ~/.bashrc or ~/.bash_completion:
50
+ # source <(autohand completion bash)
51
+ # Or save to /etc/bash_completion.d/autohand
52
+
53
+ _autohand_completions() {
54
+ local cur prev opts slash_commands
55
+ COMPREPLY=()
56
+ cur="\${COMP_WORDS[COMP_CWORD]}"
57
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
58
+
59
+ # Command line options
60
+ opts="${opts}"
61
+
62
+ # Slash commands (for interactive mode)
63
+ slash_commands="${slashCmds}"
64
+
65
+ # Complete options
66
+ if [[ \${cur} == -* ]]; then
67
+ COMPREPLY=( $(compgen -W "\${opts}" -- \${cur}) )
68
+ return 0
69
+ fi
70
+
71
+ # Complete slash commands if input starts with /
72
+ if [[ \${cur} == /* ]]; then
73
+ COMPREPLY=( $(compgen -W "\${slash_commands}" -- \${cur}) )
74
+ return 0
75
+ fi
76
+
77
+ # Complete files for certain options
78
+ case "\${prev}" in
79
+ --path|--config)
80
+ COMPREPLY=( $(compgen -f -- \${cur}) )
81
+ return 0
82
+ ;;
83
+ --model)
84
+ # Could be extended to fetch available models
85
+ COMPREPLY=()
86
+ return 0
87
+ ;;
88
+ esac
89
+
90
+ # Default: complete with files
91
+ COMPREPLY=( $(compgen -f -- \${cur}) )
92
+ return 0
93
+ }
94
+
95
+ complete -F _autohand_completions autohand
96
+ `;
97
+ }
98
+ function generateZshCompletion(config = DEFAULT_CONFIG) {
99
+ const optLines = config.options.map((o) => ` '${o.flag}[${o.description}]'`).join(" \\\n");
100
+ const slashCmds = config.slashCommands.map((c) => `'${c}'`).join(" ");
101
+ return `#compdef autohand
102
+ # Autohand CLI Zsh Completion
103
+ # Add to ~/.zshrc:
104
+ # source <(autohand completion zsh)
105
+ # Or save to /usr/local/share/zsh/site-functions/_autohand
106
+
107
+ _autohand() {
108
+ local context state state_descr line
109
+ typeset -A opt_args
110
+
111
+ _arguments -C \\
112
+ ${optLines} \\
113
+ '*:file:_files'
114
+
115
+ # Handle slash command completion in interactive mode
116
+ if [[ "$words[CURRENT]" == /* ]]; then
117
+ local slash_commands=(${slashCmds})
118
+ _describe 'slash commands' slash_commands
119
+ return
120
+ fi
121
+ }
122
+
123
+ # Register the completion
124
+ compdef _autohand autohand
125
+
126
+ # Enable @ file mention completion
127
+ _autohand_file_mention() {
128
+ if [[ "$BUFFER" == *@* ]]; then
129
+ local prefix="\${BUFFER##*@}"
130
+ local files=($(git ls-files 2>/dev/null || find . -type f -maxdepth 3 2>/dev/null))
131
+ compadd -P '@' -S '' -- \${files[@]}
132
+ fi
133
+ }
134
+
135
+ # Bind file mention to @ key
136
+ zle -N _autohand_file_mention
137
+ `;
138
+ }
139
+ function generateFishCompletion(config = DEFAULT_CONFIG) {
140
+ const optLines = config.options.map((o) => {
141
+ const flag = o.flag.replace(/^--?/, "");
142
+ const short = flag.length === 1 ? `-s ${flag}` : `-l ${flag}`;
143
+ return `complete -c autohand ${short} -d '${o.description}'`;
144
+ }).join("\n");
145
+ const slashLines = config.slashCommands.map((c) => `complete -c autohand -a '${c}' -d 'Slash command'`).join("\n");
146
+ return `# Autohand CLI Fish Completion
147
+ # Save to ~/.config/fish/completions/autohand.fish
148
+ # Or run: autohand completion fish > ~/.config/fish/completions/autohand.fish
149
+
150
+ # Disable file completion by default
151
+ complete -c autohand -f
152
+
153
+ # Options
154
+ ${optLines}
155
+
156
+ # Slash commands
157
+ ${slashLines}
158
+
159
+ # File completion for specific options
160
+ complete -c autohand -l path -rF
161
+ complete -c autohand -l config -rF
162
+
163
+ # Enable file mention with @
164
+ function __autohand_file_mention
165
+ set -l files (git ls-files 2>/dev/null; or find . -type f -maxdepth 3 2>/dev/null)
166
+ for f in $files
167
+ echo "@$f"
168
+ end
169
+ end
170
+
171
+ complete -c autohand -a '(__autohand_file_mention)' -n '__fish_seen_argument -l prompt'
172
+ `;
173
+ }
174
+ function generateCompletion(shell, config) {
175
+ const cfg = config || DEFAULT_CONFIG;
176
+ switch (shell) {
177
+ case "bash":
178
+ return generateBashCompletion(cfg);
179
+ case "zsh":
180
+ return generateZshCompletion(cfg);
181
+ case "fish":
182
+ return generateFishCompletion(cfg);
183
+ default:
184
+ throw new Error(`Unsupported shell: ${shell}`);
185
+ }
186
+ }
187
+ function detectShell() {
188
+ const shell = process.env.SHELL || "";
189
+ if (shell.includes("bash")) return "bash";
190
+ if (shell.includes("zsh")) return "zsh";
191
+ if (shell.includes("fish")) return "fish";
192
+ return null;
193
+ }
194
+ function getCompletionInstallPath(shell) {
195
+ const home = os.homedir();
196
+ switch (shell) {
197
+ case "bash":
198
+ const bashCompDir = path.join(home, ".bash_completion.d");
199
+ return path.join(bashCompDir, "autohand");
200
+ case "zsh":
201
+ const zshCompDir = path.join(home, ".zsh", "completions");
202
+ return path.join(zshCompDir, "_autohand");
203
+ case "fish":
204
+ return path.join(home, ".config", "fish", "completions", "autohand.fish");
205
+ default:
206
+ throw new Error(`Unsupported shell: ${shell}`);
207
+ }
208
+ }
209
+ async function installCompletion(shell, config) {
210
+ const script = generateCompletion(shell, config);
211
+ const installPath = getCompletionInstallPath(shell);
212
+ await fs.ensureDir(path.dirname(installPath));
213
+ await fs.writeFile(installPath, script, "utf8");
214
+ return installPath;
215
+ }
216
+ function getInstallInstructions(shell) {
217
+ switch (shell) {
218
+ case "bash":
219
+ return `
220
+ ${chalk.cyan("Bash Completion Setup:")}
221
+
222
+ ${chalk.yellow("Option 1:")} Add to your ~/.bashrc:
223
+ ${chalk.green("source <(autohand completion bash)")}
224
+
225
+ ${chalk.yellow("Option 2:")} Save to completion directory:
226
+ ${chalk.green("autohand completion bash > ~/.bash_completion.d/autohand")}
227
+ ${chalk.green("source ~/.bash_completion.d/autohand")}
228
+
229
+ ${chalk.gray("Restart your shell or run: source ~/.bashrc")}
230
+ `;
231
+ case "zsh":
232
+ return `
233
+ ${chalk.cyan("Zsh Completion Setup:")}
234
+
235
+ ${chalk.yellow("Option 1:")} Add to your ~/.zshrc:
236
+ ${chalk.green("source <(autohand completion zsh)")}
237
+
238
+ ${chalk.yellow("Option 2:")} Save to fpath:
239
+ ${chalk.green("autohand completion zsh > ~/.zsh/completions/_autohand")}
240
+
241
+ Then add to ~/.zshrc (before compinit):
242
+ ${chalk.green("fpath=(~/.zsh/completions $fpath)")}
243
+ ${chalk.green("autoload -Uz compinit && compinit")}
244
+
245
+ ${chalk.gray("Restart your shell or run: source ~/.zshrc")}
246
+ `;
247
+ case "fish":
248
+ return `
249
+ ${chalk.cyan("Fish Completion Setup:")}
250
+
251
+ ${chalk.green("autohand completion fish > ~/.config/fish/completions/autohand.fish")}
252
+
253
+ ${chalk.gray("Fish will automatically load the completion on next shell start.")}
254
+ `;
255
+ default:
256
+ return `Unknown shell: ${shell}`;
257
+ }
258
+ }
259
+
260
+ // src/commands/completion.ts
261
+ var metadata = {
262
+ command: "/completion",
263
+ description: "Generate shell completion scripts",
264
+ implemented: true
265
+ };
266
+ async function execute(args) {
267
+ let shell = null;
268
+ if (args) {
269
+ const arg = args.trim().toLowerCase();
270
+ if (arg === "bash" || arg === "zsh" || arg === "fish") {
271
+ shell = arg;
272
+ }
273
+ }
274
+ if (!shell) {
275
+ const detected = detectShell();
276
+ if (detected) {
277
+ console.log(chalk2.gray(`Detected shell: ${detected}`));
278
+ }
279
+ const { Select: Select2 } = enquirer;
280
+ const prompt = new Select2({
281
+ name: "shell",
282
+ message: "Select your shell:",
283
+ choices: [
284
+ { name: "bash", message: "Bash" },
285
+ { name: "zsh", message: "Zsh" },
286
+ { name: "fish", message: "Fish" }
287
+ ],
288
+ initial: detected || "bash"
289
+ });
290
+ try {
291
+ shell = await prompt.run();
292
+ } catch {
293
+ console.log(chalk2.gray("Cancelled."));
294
+ return;
295
+ }
296
+ }
297
+ const { Select } = enquirer;
298
+ const actionPrompt = new Select({
299
+ name: "action",
300
+ message: "What would you like to do?",
301
+ choices: [
302
+ { name: "print", message: "Print completion script to terminal" },
303
+ { name: "install", message: "Install completion to default location" },
304
+ { name: "instructions", message: "Show installation instructions" }
305
+ ]
306
+ });
307
+ try {
308
+ const action = await actionPrompt.run();
309
+ switch (action) {
310
+ case "print":
311
+ console.log();
312
+ console.log(chalk2.cyan(`# ${shell} completion script for autohand`));
313
+ console.log(chalk2.cyan("# Copy and save to appropriate location"));
314
+ console.log();
315
+ console.log(generateCompletion(shell));
316
+ break;
317
+ case "install":
318
+ const installPath = await installCompletion(shell);
319
+ console.log();
320
+ console.log(chalk2.green("Completion script installed to:"));
321
+ console.log(chalk2.cyan(` ${installPath}`));
322
+ console.log();
323
+ console.log(getInstallInstructions(shell));
324
+ break;
325
+ case "instructions":
326
+ console.log(getInstallInstructions(shell));
327
+ break;
328
+ }
329
+ } catch {
330
+ console.log(chalk2.gray("Cancelled."));
331
+ }
332
+ }
333
+ async function runCompletionCommand(shell) {
334
+ if (!shell) {
335
+ console.error("Usage: autohand completion <bash|zsh|fish>");
336
+ process.exit(1);
337
+ }
338
+ const validShells = ["bash", "zsh", "fish"];
339
+ if (!validShells.includes(shell)) {
340
+ console.error(`Invalid shell: ${shell}`);
341
+ console.error(`Valid options: ${validShells.join(", ")}`);
342
+ process.exit(1);
343
+ }
344
+ console.log(generateCompletion(shell));
345
+ }
346
+
347
+ export {
348
+ metadata,
349
+ execute,
350
+ runCompletionCommand
351
+ };
352
+ /**
353
+ * @license
354
+ * Copyright 2025 Autohand AI LLC
355
+ * SPDX-License-Identifier: Apache-2.0
356
+ *
357
+ * Shell Completion Scripts Generator
358
+ * Supports bash, zsh, and fish
359
+ */
360
+ /**
361
+ * @license
362
+ * Copyright 2025 Autohand AI LLC
363
+ * SPDX-License-Identifier: Apache-2.0
364
+ */
@@ -0,0 +1,30 @@
1
+ // src/commands/new.ts
2
+ import chalk from "chalk";
3
+ async function newConversation(ctx) {
4
+ const currentSession = ctx.sessionManager.getCurrentSession();
5
+ if (currentSession) {
6
+ await ctx.sessionManager.closeSession("Session ended - new conversation started");
7
+ }
8
+ await ctx.resetConversation();
9
+ await ctx.sessionManager.createSession(ctx.workspaceRoot, ctx.model);
10
+ console.log();
11
+ console.log(chalk.cyan("New conversation started."));
12
+ console.log(chalk.gray("Previous session saved. Ready for new instructions."));
13
+ console.log();
14
+ return null;
15
+ }
16
+ var metadata = {
17
+ command: "/new",
18
+ description: "start a fresh conversation (saves current session)",
19
+ implemented: true
20
+ };
21
+
22
+ export {
23
+ newConversation,
24
+ metadata
25
+ };
26
+ /**
27
+ * @license
28
+ * Copyright 2025 Autohand AI LLC
29
+ * SPDX-License-Identifier: Apache-2.0
30
+ */
@@ -0,0 +1,10 @@
1
+ import {
2
+ execute,
3
+ metadata,
4
+ runCompletionCommand
5
+ } from "./chunk-YWKZF2SA.js";
6
+ export {
7
+ execute,
8
+ metadata,
9
+ runCompletionCommand
10
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ execute,
3
+ metadata
4
+ } from "./chunk-OC5YDNFC.js";
5
+ export {
6
+ execute,
7
+ metadata
8
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ feedback,
3
+ metadata
4
+ } from "./chunk-2QAL3HH4.js";
5
+ import "./chunk-2EPIFDFM.js";
6
+ export {
7
+ feedback,
8
+ metadata
9
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ execute,
3
+ metadata
4
+ } from "./chunk-XDVG3NM4.js";
5
+ export {
6
+ execute,
7
+ metadata
8
+ };
@@ -0,0 +1,10 @@
1
+ import {
2
+ aliasMetadata,
3
+ help,
4
+ metadata
5
+ } from "./chunk-TVWTD63Y.js";
6
+ export {
7
+ aliasMetadata,
8
+ help,
9
+ metadata
10
+ };