@hasna/terminal 0.1.2 → 0.1.3

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/App.js CHANGED
@@ -42,7 +42,7 @@ export default function App() {
42
42
  });
43
43
  const allNl = [...nlHistory, ...sessionNl];
44
44
  const finishOnboarding = (perms) => {
45
- const next = { onboarded: true, permissions: perms };
45
+ const next = { onboarded: true, confirm: false, permissions: perms };
46
46
  setConfig(next);
47
47
  saveConfig(next);
48
48
  };
@@ -141,6 +141,11 @@ export default function App() {
141
141
  return;
142
142
  }
143
143
  const danger = isIrreversible(command);
144
+ // skip confirm unless user opted in OR command is dangerous
145
+ if (!config.confirm && !danger) {
146
+ await runPhase(nl, command, false);
147
+ return;
148
+ }
144
149
  setPhase({ type: "confirm", nl, command, raw: false, danger });
145
150
  }
146
151
  catch (e) {
@@ -212,6 +217,10 @@ export default function App() {
212
217
  try {
213
218
  const fixed = await fixCommand(nl, command, errorOutput, config.permissions, sessionCmds);
214
219
  const danger = isIrreversible(fixed);
220
+ if (!config.confirm && !danger) {
221
+ await runPhase(nl, fixed, false);
222
+ return;
223
+ }
215
224
  setPhase({ type: "confirm", nl, command: fixed, raw: false, danger });
216
225
  }
217
226
  catch (e) {
package/dist/history.js CHANGED
@@ -13,6 +13,7 @@ export const DEFAULT_PERMISSIONS = {
13
13
  };
14
14
  export const DEFAULT_CONFIG = {
15
15
  onboarded: false,
16
+ confirm: false,
16
17
  permissions: DEFAULT_PERMISSIONS,
17
18
  };
18
19
  function ensureDir() {
@@ -47,6 +48,7 @@ export function loadConfig() {
47
48
  return {
48
49
  ...DEFAULT_CONFIG,
49
50
  ...saved,
51
+ confirm: saved.confirm ?? false,
50
52
  permissions: { ...DEFAULT_PERMISSIONS, ...(saved.permissions ?? {}) },
51
53
  };
52
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/terminal",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Natural language terminal — speak plain English, get shell commands",
5
5
  "type": "module",
6
6
  "bin": {
package/src/App.tsx CHANGED
@@ -80,7 +80,7 @@ export default function App() {
80
80
  const allNl = [...nlHistory, ...sessionNl];
81
81
 
82
82
  const finishOnboarding = (perms: Permissions) => {
83
- const next = { onboarded: true, permissions: perms };
83
+ const next = { onboarded: true, confirm: false, permissions: perms };
84
84
  setConfig(next);
85
85
  saveConfig(next);
86
86
  };
@@ -185,6 +185,11 @@ export default function App() {
185
185
  return;
186
186
  }
187
187
  const danger = isIrreversible(command);
188
+ // skip confirm unless user opted in OR command is dangerous
189
+ if (!config.confirm && !danger) {
190
+ await runPhase(nl, command, false);
191
+ return;
192
+ }
188
193
  setPhase({ type: "confirm", nl, command, raw: false, danger });
189
194
  } catch (e: any) {
190
195
  setPhase({ type: "error", message: e.message });
@@ -247,6 +252,10 @@ export default function App() {
247
252
  try {
248
253
  const fixed = await fixCommand(nl, command, errorOutput, config.permissions, sessionCmds);
249
254
  const danger = isIrreversible(fixed);
255
+ if (!config.confirm && !danger) {
256
+ await runPhase(nl, fixed, false);
257
+ return;
258
+ }
250
259
  setPhase({ type: "confirm", nl, command: fixed, raw: false, danger });
251
260
  } catch (e: any) {
252
261
  setPhase({ type: "error", message: e.message });
package/src/history.ts CHANGED
@@ -29,6 +29,7 @@ export interface Permissions {
29
29
 
30
30
  export interface Config {
31
31
  onboarded: boolean;
32
+ confirm: boolean; // ask before running — false = run immediately
32
33
  permissions: Permissions;
33
34
  }
34
35
 
@@ -42,6 +43,7 @@ export const DEFAULT_PERMISSIONS: Permissions = {
42
43
 
43
44
  export const DEFAULT_CONFIG: Config = {
44
45
  onboarded: false,
46
+ confirm: false,
45
47
  permissions: DEFAULT_PERMISSIONS,
46
48
  };
47
49
 
@@ -77,6 +79,7 @@ export function loadConfig(): Config {
77
79
  return {
78
80
  ...DEFAULT_CONFIG,
79
81
  ...saved,
82
+ confirm: saved.confirm ?? false,
80
83
  permissions: { ...DEFAULT_PERMISSIONS, ...(saved.permissions ?? {}) },
81
84
  };
82
85
  } catch {