@hasna/terminal 1.3.2 → 1.3.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.
Files changed (3) hide show
  1. package/dist/ai.js +11 -3
  2. package/package.json +1 -1
  3. package/src/ai.ts +10 -2
package/dist/ai.js CHANGED
@@ -46,7 +46,15 @@ const IRREVERSIBLE_PATTERNS = [
46
46
  // File creation/modification (READ-ONLY terminal)
47
47
  /\btouch\b/, /\bmkdir\b/, /\becho\s.*>/, /\btee\b/, /\bcp\b/, /\bmv\b/,
48
48
  ];
49
+ // Commands that are ALWAYS safe (read-only git, etc.)
50
+ const SAFE_OVERRIDES = [
51
+ /^\s*git\s+(log|show|diff|branch|status|blame|tag|remote|stash\s+list)\b/,
52
+ /^\s*git\s+log\b/,
53
+ ];
49
54
  export function isIrreversible(command) {
55
+ // Safe overrides take priority
56
+ if (SAFE_OVERRIDES.some((r) => r.test(command)))
57
+ return false;
50
58
  return IRREVERSIBLE_PATTERNS.some((r) => r.test(command));
51
59
  }
52
60
  // ── permissions ───────────────────────────────────────────────────────────────
@@ -210,10 +218,10 @@ export async function translateToCommand(nl, perms, sessionEntries, onToken) {
210
218
  if (!t)
211
219
  return false;
212
220
  // Skip obvious reasoning lines
213
- if (/^(Based on|I |This |The |Let me|Here|Note:|Since|Looking|To )/.test(t))
221
+ if (/^(Based on|I |This |The |Let me|Here|Note:|Since|Looking|To |However|BLOCKED:)/.test(t))
214
222
  return false;
215
- if (/^[A-Z][a-z].*\.$/.test(t))
216
- return false; // English sentence ending with period
223
+ if (/^[A-Z][a-z].*[.;:]$/.test(t))
224
+ return false; // English sentence ending with period/semicolon/colon
217
225
  return true;
218
226
  });
219
227
  cleaned = commandLines.join("\n").trim() || cleaned;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/terminal",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Smart terminal wrapper for AI agents and humans — structured output, token compression, MCP server, natural language",
5
5
  "type": "module",
6
6
  "bin": {
package/src/ai.ts CHANGED
@@ -55,7 +55,15 @@ const IRREVERSIBLE_PATTERNS = [
55
55
  /\btouch\b/, /\bmkdir\b/, /\becho\s.*>/, /\btee\b/, /\bcp\b/, /\bmv\b/,
56
56
  ];
57
57
 
58
+ // Commands that are ALWAYS safe (read-only git, etc.)
59
+ const SAFE_OVERRIDES = [
60
+ /^\s*git\s+(log|show|diff|branch|status|blame|tag|remote|stash\s+list)\b/,
61
+ /^\s*git\s+log\b/,
62
+ ];
63
+
58
64
  export function isIrreversible(command: string): boolean {
65
+ // Safe overrides take priority
66
+ if (SAFE_OVERRIDES.some((r) => r.test(command))) return false;
59
67
  return IRREVERSIBLE_PATTERNS.some((r) => r.test(command));
60
68
  }
61
69
 
@@ -251,8 +259,8 @@ export async function translateToCommand(
251
259
  const t = l.trim();
252
260
  if (!t) return false;
253
261
  // Skip obvious reasoning lines
254
- if (/^(Based on|I |This |The |Let me|Here|Note:|Since|Looking|To )/.test(t)) return false;
255
- if (/^[A-Z][a-z].*\.$/.test(t)) return false; // English sentence ending with period
262
+ if (/^(Based on|I |This |The |Let me|Here|Note:|Since|Looking|To |However|BLOCKED:)/.test(t)) return false;
263
+ if (/^[A-Z][a-z].*[.;:]$/.test(t)) return false; // English sentence ending with period/semicolon/colon
256
264
  return true;
257
265
  });
258
266
  cleaned = commandLines.join("\n").trim() || cleaned;