@hasna/terminal 1.6.6 → 1.6.7

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/cli.js +14 -10
  2. package/package.json +1 -1
  3. package/src/cli.tsx +15 -11
package/dist/cli.js CHANGED
@@ -421,20 +421,24 @@ else if (args.length > 0) {
421
421
  command = await translateToCommand(prompt, perms, []);
422
422
  }
423
423
  catch (e) {
424
- // If BLOCKED, try fallback: read README or package.json for conceptual questions
424
+ // If BLOCKED, try README fallback ONLY for conceptual questions (not file access)
425
425
  if (e.message?.startsWith("BLOCKED:")) {
426
- try {
427
- const { existsSync, readFileSync } = await import("fs");
428
- if (existsSync("README.md")) {
429
- const readme = readFileSync("README.md", "utf8").slice(0, 3000);
430
- const processed = await processOutput("cat README.md", readme, prompt);
431
- if (processed.aiProcessed) {
432
- console.log(processed.summary);
433
- process.exit(0);
426
+ const isConceptual = /\b(explain|why|what does|how does|describe|architecture|overview|summary)\b/i.test(prompt);
427
+ const isFileAccess = /\b(cat|show|read|find|ls|list)\b.*\b(\.\w+\/|src\/|packages\/)/i.test(prompt);
428
+ if (isConceptual && !isFileAccess) {
429
+ try {
430
+ const { existsSync, readFileSync } = await import("fs");
431
+ if (existsSync("README.md")) {
432
+ const readme = readFileSync("README.md", "utf8").slice(0, 3000);
433
+ const processed = await processOutput("cat README.md", readme, prompt);
434
+ if (processed.aiProcessed) {
435
+ console.log(processed.summary);
436
+ process.exit(0);
437
+ }
434
438
  }
435
439
  }
440
+ catch { }
436
441
  }
437
- catch { }
438
442
  }
439
443
  console.error(e.message);
440
444
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/terminal",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
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/cli.tsx CHANGED
@@ -402,19 +402,23 @@ else if (args.length > 0) {
402
402
  try {
403
403
  command = await translateToCommand(prompt, perms, []);
404
404
  } catch (e: any) {
405
- // If BLOCKED, try fallback: read README or package.json for conceptual questions
405
+ // If BLOCKED, try README fallback ONLY for conceptual questions (not file access)
406
406
  if (e.message?.startsWith("BLOCKED:")) {
407
- try {
408
- const { existsSync, readFileSync } = await import("fs");
409
- if (existsSync("README.md")) {
410
- const readme = readFileSync("README.md", "utf8").slice(0, 3000);
411
- const processed = await processOutput("cat README.md", readme, prompt);
412
- if (processed.aiProcessed) {
413
- console.log(processed.summary);
414
- process.exit(0);
407
+ const isConceptual = /\b(explain|why|what does|how does|describe|architecture|overview|summary)\b/i.test(prompt);
408
+ const isFileAccess = /\b(cat|show|read|find|ls|list)\b.*\b(\.\w+\/|src\/|packages\/)/i.test(prompt);
409
+ if (isConceptual && !isFileAccess) {
410
+ try {
411
+ const { existsSync, readFileSync } = await import("fs");
412
+ if (existsSync("README.md")) {
413
+ const readme = readFileSync("README.md", "utf8").slice(0, 3000);
414
+ const processed = await processOutput("cat README.md", readme, prompt);
415
+ if (processed.aiProcessed) {
416
+ console.log(processed.summary);
417
+ process.exit(0);
418
+ }
415
419
  }
416
- }
417
- } catch {}
420
+ } catch {}
421
+ }
418
422
  }
419
423
  console.error(e.message);
420
424
  process.exit(1);