autohand-cli 0.3.0 → 0.5.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.
@@ -0,0 +1,104 @@
1
+ // src/commands/permissions.ts
2
+ import chalk from "chalk";
3
+ import enquirer from "enquirer";
4
+ async function permissions(ctx) {
5
+ const whitelist = ctx.permissionManager.getWhitelist();
6
+ const blacklist = ctx.permissionManager.getBlacklist();
7
+ const settings = ctx.permissionManager.getSettings();
8
+ console.log();
9
+ console.log(chalk.bold.cyan("Permissions"));
10
+ console.log(chalk.gray("\u2500".repeat(50)));
11
+ console.log(chalk.gray(`Mode: ${settings.mode || "interactive"}`));
12
+ console.log();
13
+ if (whitelist.length === 0 && blacklist.length === 0) {
14
+ console.log(chalk.gray("No saved permissions yet."));
15
+ console.log();
16
+ console.log(chalk.gray("When you approve or deny a tool/command, it will be saved here."));
17
+ console.log(chalk.gray("Approved items are auto-allowed; denied items are auto-blocked."));
18
+ return null;
19
+ }
20
+ if (whitelist.length > 0) {
21
+ console.log(chalk.bold.green("Approved (Whitelist)"));
22
+ console.log();
23
+ whitelist.forEach((pattern, index) => {
24
+ console.log(chalk.green(` ${index + 1}. ${pattern}`));
25
+ });
26
+ console.log();
27
+ }
28
+ if (blacklist.length > 0) {
29
+ console.log(chalk.bold.red("Denied (Blacklist)"));
30
+ console.log();
31
+ blacklist.forEach((pattern, index) => {
32
+ console.log(chalk.red(` ${index + 1}. ${pattern}`));
33
+ });
34
+ console.log();
35
+ }
36
+ console.log(chalk.gray("\u2500".repeat(50)));
37
+ console.log(chalk.gray(`Total: ${whitelist.length} approved, ${blacklist.length} denied`));
38
+ console.log();
39
+ const { action } = await enquirer.prompt({
40
+ type: "select",
41
+ name: "action",
42
+ message: "What would you like to do?",
43
+ choices: [
44
+ { name: "done", message: "Done" },
45
+ { name: "remove_approved", message: "Remove an approved item" },
46
+ { name: "remove_denied", message: "Remove a denied item" },
47
+ { name: "clear_all", message: "Clear all permissions" }
48
+ ]
49
+ });
50
+ if (action === "done") {
51
+ return null;
52
+ }
53
+ if (action === "remove_approved" && whitelist.length > 0) {
54
+ const { pattern } = await enquirer.prompt({
55
+ type: "select",
56
+ name: "pattern",
57
+ message: "Select item to remove from approved list:",
58
+ choices: whitelist.map((p) => ({ name: p, message: p }))
59
+ });
60
+ await ctx.permissionManager.removeFromWhitelist(pattern);
61
+ console.log(chalk.yellow(`Removed "${pattern}" from approved list.`));
62
+ } else if (action === "remove_denied" && blacklist.length > 0) {
63
+ const { pattern } = await enquirer.prompt({
64
+ type: "select",
65
+ name: "pattern",
66
+ message: "Select item to remove from denied list:",
67
+ choices: blacklist.map((p) => ({ name: p, message: p }))
68
+ });
69
+ await ctx.permissionManager.removeFromBlacklist(pattern);
70
+ console.log(chalk.yellow(`Removed "${pattern}" from denied list.`));
71
+ } else if (action === "clear_all") {
72
+ const { confirm } = await enquirer.prompt({
73
+ type: "confirm",
74
+ name: "confirm",
75
+ message: "Clear all saved permissions? This cannot be undone.",
76
+ initial: false
77
+ });
78
+ if (confirm) {
79
+ for (const pattern of [...whitelist]) {
80
+ await ctx.permissionManager.removeFromWhitelist(pattern);
81
+ }
82
+ for (const pattern of [...blacklist]) {
83
+ await ctx.permissionManager.removeFromBlacklist(pattern);
84
+ }
85
+ console.log(chalk.yellow("All permissions cleared."));
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+ var metadata = {
91
+ command: "/permissions",
92
+ description: "view and manage tool/command approvals",
93
+ implemented: true
94
+ };
95
+
96
+ export {
97
+ permissions,
98
+ metadata
99
+ };
100
+ /**
101
+ * @license
102
+ * Copyright 2025 Autohand AI LLC
103
+ * SPDX-License-Identifier: Apache-2.0
104
+ */
@@ -5,7 +5,7 @@ import readline from "readline";
5
5
  // package.json
6
6
  var package_default = {
7
7
  name: "autohand-cli",
8
- version: "0.3.0",
8
+ version: "0.5.0",
9
9
  description: "Autohand interactive coding agent CLI powered by LLMs.",
10
10
  type: "module",
11
11
  bin: {