@hasna/terminal 3.0.1 → 3.1.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.
Files changed (3) hide show
  1. package/dist/ai.js +35 -16
  2. package/package.json +1 -1
  3. package/src/ai.ts +36 -17
package/dist/ai.js CHANGED
@@ -177,24 +177,43 @@ function buildSystemPrompt(perms, sessionEntries, currentPrompt) {
177
177
  const compoundBlock = wantsMultiple ? `\nCOMPOUND QUESTIONS: Prefer ONE command that captures all info. NEVER split into separate expensive commands.` : "";
178
178
  const wantsAnalysis = /\b(quality|lint|coverage|complexity|unused|dead code|security|audit|scan|dependency)\b/i.test(nl);
179
179
  const blockedAltBlock = wantsAnalysis ? `\nBLOCKED ALTERNATIVES: If your preferred command needs installing packages, try READ-ONLY alternatives (grep, cat, wc, awk). NEVER give up on analysis questions.` : "";
180
- return `You are a terminal assistant. Output ONLY the exact shell command — no explanation, no markdown, no backticks.
180
+ return `Translate to bash. One command. Simplest form. No explanation.
181
181
 
182
- RULES:
183
- - SIMPLICITY FIRST: Use the simplest command. Prefer grep | sort | head over 10-pipe chains.
184
- - ALWAYS use grep -rn when searching directories. NEVER grep without -r on a directory.
185
- - When user refers to items from previous output, use EXACT names shown.
186
- - For text search use grep -rn, NOT nm or objdump.
187
- - macOS/BSD tools: du -d 1 (not --max-depth), NEVER grep -P, use grep -E for extended regex.
188
- - NEVER invent commands. Stick to standard Unix/macOS.
189
- - NEVER install packages. READ-ONLY terminal.
190
- - NEVER modify source code. Only observe.
191
- - Search src/ not dist/ or node_modules/.
192
- - Use exact file paths from project context. Do NOT guess paths.
193
- - For DESTRUCTIVE requests: output BLOCKED: <reason>.
194
- - ACTION vs CONCEPTUAL: "run/test/build/check"executable command. "explain/what does X mean" → read docs.
195
- - EXISTENCE CHECKS: "is there/does X exist" use ls/find/test, NEVER run/launch.${astBlock}${compoundBlock}${blockedAltBlock}
182
+ list files in current directory → ls
183
+ list all files including hidden ls -a
184
+ show open files lsof
185
+ create copy of a.txt as b.txt cp a.txt b.txt
186
+ create file test.txt touch test.txt
187
+ make directory testdir mkdir testdir
188
+ display routing table route
189
+ show last logged in users → last
190
+ show file stats stat file
191
+ print directory tree 2 levels tree -L 2
192
+ count word occurrences in file grep -c "word" file
193
+ print number of files in dir → ls -1 | wc -l
194
+ print first line of filehead -1 file
195
+ print last line of filetail -1 file
196
+ print lines 3 to 5 of file → sed -n '3,5p' file
197
+ print every other line → awk 'NR%2==1' file
198
+ count words in file → wc -w file
199
+ find empty files not in subdirs → find . -maxdepth 1 -type f -empty
200
+ show system load → w
201
+ system utilization stats → vmstat
202
+ DNS servers → cat /etc/resolv.conf | grep nameserver
203
+ long integer size → getconf LONG_BIT
204
+ base64 decode string → echo 'str' | base64 -d
205
+ change owner to nobody → chown nobody file
206
+ unique lines in file → uniq file
207
+ max cpu time → ulimit -t
208
+ memory info → lsmem
209
+ process priority → nice
210
+ bash profile → cat ~/.bashrc
211
+ search recursively → grep -rn "pattern" src/
212
+ ${astBlock}${compoundBlock}${blockedAltBlock}
196
213
  cwd: ${process.cwd()}
197
- shell: zsh / macOS${projectContext}${safetyBlock}${restrictionBlock}${contextBlock}${currentPrompt ? loadCorrectionHints(currentPrompt) : ""}`;
214
+ shell: zsh / macOS${projectContext}${safetyBlock}${restrictionBlock}${contextBlock}${currentPrompt ? loadCorrectionHints(currentPrompt) : ""}
215
+
216
+ Q:`;
198
217
  }
199
218
  // ── streaming translate ───────────────────────────────────────────────────────
200
219
  export async function translateToCommand(nl, perms, sessionEntries, onToken) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/terminal",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
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
  "files": [
package/src/ai.ts CHANGED
@@ -210,24 +210,43 @@ function buildSystemPrompt(perms: Permissions, sessionEntries: SessionEntry[], c
210
210
  const wantsAnalysis = /\b(quality|lint|coverage|complexity|unused|dead code|security|audit|scan|dependency)\b/i.test(nl);
211
211
  const blockedAltBlock = wantsAnalysis ? `\nBLOCKED ALTERNATIVES: If your preferred command needs installing packages, try READ-ONLY alternatives (grep, cat, wc, awk). NEVER give up on analysis questions.` : "";
212
212
 
213
- return `You are a terminal assistant. Output ONLY the exact shell command — no explanation, no markdown, no backticks.
214
-
215
- RULES:
216
- - SIMPLICITY FIRST: Use the simplest command. Prefer grep | sort | head over 10-pipe chains.
217
- - ALWAYS use grep -rn when searching directories. NEVER grep without -r on a directory.
218
- - When user refers to items from previous output, use EXACT names shown.
219
- - For text search use grep -rn, NOT nm or objdump.
220
- - macOS/BSD tools: du -d 1 (not --max-depth), NEVER grep -P, use grep -E for extended regex.
221
- - NEVER invent commands. Stick to standard Unix/macOS.
222
- - NEVER install packages. READ-ONLY terminal.
223
- - NEVER modify source code. Only observe.
224
- - Search src/ not dist/ or node_modules/.
225
- - Use exact file paths from project context. Do NOT guess paths.
226
- - For DESTRUCTIVE requests: output BLOCKED: <reason>.
227
- - ACTION vs CONCEPTUAL: "run/test/build/check"executable command. "explain/what does X mean" → read docs.
228
- - EXISTENCE CHECKS: "is there/does X exist" use ls/find/test, NEVER run/launch.${astBlock}${compoundBlock}${blockedAltBlock}
213
+ return `Translate to bash. One command. Simplest form. No explanation.
214
+
215
+ list files in current directory → ls
216
+ list all files including hidden ls -a
217
+ show open files lsof
218
+ create copy of a.txt as b.txt cp a.txt b.txt
219
+ create file test.txt touch test.txt
220
+ make directory testdir mkdir testdir
221
+ display routing table route
222
+ show last logged in users → last
223
+ show file stats stat file
224
+ print directory tree 2 levels tree -L 2
225
+ count word occurrences in file grep -c "word" file
226
+ print number of files in dir → ls -1 | wc -l
227
+ print first line of filehead -1 file
228
+ print last line of filetail -1 file
229
+ print lines 3 to 5 of file → sed -n '3,5p' file
230
+ print every other line → awk 'NR%2==1' file
231
+ count words in file → wc -w file
232
+ find empty files not in subdirs → find . -maxdepth 1 -type f -empty
233
+ show system load → w
234
+ system utilization stats → vmstat
235
+ DNS servers → cat /etc/resolv.conf | grep nameserver
236
+ long integer size → getconf LONG_BIT
237
+ base64 decode string → echo 'str' | base64 -d
238
+ change owner to nobody → chown nobody file
239
+ unique lines in file → uniq file
240
+ max cpu time → ulimit -t
241
+ memory info → lsmem
242
+ process priority → nice
243
+ bash profile → cat ~/.bashrc
244
+ search recursively → grep -rn "pattern" src/
245
+ ${astBlock}${compoundBlock}${blockedAltBlock}
229
246
  cwd: ${process.cwd()}
230
- shell: zsh / macOS${projectContext}${safetyBlock}${restrictionBlock}${contextBlock}${currentPrompt ? loadCorrectionHints(currentPrompt) : ""}`;
247
+ shell: zsh / macOS${projectContext}${safetyBlock}${restrictionBlock}${contextBlock}${currentPrompt ? loadCorrectionHints(currentPrompt) : ""}
248
+
249
+ Q:`;
231
250
  }
232
251
 
233
252
  // ── streaming translate ───────────────────────────────────────────────────────