@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.
- package/dist/ai.js +35 -16
- package/package.json +1 -1
- 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 `
|
|
180
|
+
return `Translate to bash. One command. Simplest form. No explanation.
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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 file → head -1 file
|
|
195
|
+
print last line of file → tail -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
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 `
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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 file → head -1 file
|
|
228
|
+
print last line of file → tail -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 ───────────────────────────────────────────────────────
|