@hasna/terminal 1.6.5 → 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.
package/README.md CHANGED
@@ -183,12 +183,44 @@ Every command through `terminal exec` goes through:
183
183
  6. **Structured Parsing** — JSON instead of text
184
184
  - Git status/log, test results, build output, npm install, errors
185
185
 
186
+ ## Best Practices for 95%+ Reliability
187
+
188
+ Tested across 149 queries by 3 independent agents on 3 different repos:
189
+
190
+ ```bash
191
+ # Session start (100% reliable)
192
+ terminal repo # Git status + recent commits
193
+ terminal "ls packages/" # Package overview (monorepo)
194
+ terminal symbols src/main.ts # Key file structure
195
+
196
+ # Code exploration (use path hints!)
197
+ terminal "in src/lib, what functions are exported" # Path hint = 80%+ reliability
198
+ terminal "grep -rn 'pattern' src/" # Command passthrough works too
199
+ terminal symbols src/db/tasks.ts # 100% reliable on valid files
200
+
201
+ # Git queries (100% reliable, any phrasing)
202
+ terminal "what changed in the last 3 commits"
203
+ terminal "who made the most recent change"
204
+
205
+ # System queries (100% reliable)
206
+ terminal "how many typescript files"
207
+ terminal "what testing framework is used"
208
+ terminal "show me the package.json scripts"
209
+ ```
210
+
211
+ **Key rules:**
212
+ - Include package/directory paths in your query for best results
213
+ - Use `terminal symbols <file>` for file outlines (100% reliable)
214
+ - Use `terminal repo` at session start (replaces 3 git commands)
215
+ - For literal commands: `terminal "grep -rn pattern src/"` works with answer framing
216
+ - Git and system queries work with any phrasing
217
+
186
218
  ## CLI Commands
187
219
 
188
220
  ```
189
- terminal Launch NL terminal (TUI)
190
- terminal exec <command> Smart execution with full pipeline
191
- terminal repo Git repo state in one call
221
+ terminal "your request" NL AI runs command → smart answer
222
+ terminal Launch interactive NL terminal (TUI)
223
+ terminal repo Git status + diff + log in one call
192
224
  terminal symbols <file> File outline (functions, classes, exports)
193
225
  terminal stats Token economy dashboard
194
226
  terminal sessions List recent sessions
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.5",
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);