@hasna/terminal 2.0.0 → 2.0.2
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 +8 -1
- package/package.json +1 -1
- package/src/ai.ts +7 -1
package/dist/ai.js
CHANGED
|
@@ -45,6 +45,8 @@ const IRREVERSIBLE_PATTERNS = [
|
|
|
45
45
|
/\bcodemod\b/, /\bsed\s+-i\b/, /\bawk\s.*>\s*\S+\.\w+/, /\bperl\s+-[pi]\b/,
|
|
46
46
|
// File creation/modification (READ-ONLY terminal)
|
|
47
47
|
/\btouch\b/, /\bmkdir\b/, /\becho\s.*>/, /\btee\b/, /\bcp\b/, /\bmv\b/,
|
|
48
|
+
// Starting servers/processes (dangerous from NL)
|
|
49
|
+
/\b(bun|npm|pnpm|yarn)\s+run\s+dev\b/, /\b(bun|npm)\s+start\b/,
|
|
48
50
|
];
|
|
49
51
|
// Commands that are ALWAYS safe (read-only git, etc.)
|
|
50
52
|
const SAFE_OVERRIDES = [
|
|
@@ -92,11 +94,14 @@ function detectProjectContext() {
|
|
|
92
94
|
if (existsSync(pkgPath)) {
|
|
93
95
|
try {
|
|
94
96
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
95
|
-
parts.push(`Project: Node.js/TypeScript
|
|
97
|
+
parts.push(`Project: ${pkg.name}@${pkg.version} (Node.js/TypeScript)`);
|
|
98
|
+
parts.push(`npm package: ${pkg.name} (use this name for npm view, npm info, etc.)`);
|
|
96
99
|
if (pkg.scripts) {
|
|
97
100
|
const scripts = Object.entries(pkg.scripts).map(([k, v]) => `${k}: ${v}`).slice(0, 8);
|
|
98
101
|
parts.push(`Available scripts: ${scripts.join(", ")}`);
|
|
99
102
|
}
|
|
103
|
+
if (pkg.dependencies)
|
|
104
|
+
parts.push(`Dependencies: ${Object.keys(pkg.dependencies).join(", ")}`);
|
|
100
105
|
parts.push(`Use npm/bun/pnpm commands, NOT maven/gradle/cargo.`);
|
|
101
106
|
}
|
|
102
107
|
catch { }
|
|
@@ -220,6 +225,8 @@ SEMANTIC MAPPING: When the user references a concept, search the file tree for R
|
|
|
220
225
|
|
|
221
226
|
ACTION vs CONCEPTUAL: If the prompt starts with "run", "execute", "check", "test", "build", "show output of" — ALWAYS generate an executable command. NEVER read README for action requests. Only read docs for "explain why", "what does X mean", "how was X designed".
|
|
222
227
|
|
|
228
|
+
EXISTENCE CHECKS: If the prompt starts with "is there", "does this have", "do we have", "does X exist" — NEVER run/start/launch anything. Use ls, find, or test -d to CHECK existence. These are READ-ONLY questions.
|
|
229
|
+
|
|
223
230
|
MONOREPO: If the project context says "MONOREPO", search packages/ or apps/ NOT src/. Use: grep -rn "pattern" packages/ --include="*.ts". For specific packages, use packages/PKGNAME/src/.
|
|
224
231
|
cwd: ${process.cwd()}
|
|
225
232
|
shell: zsh / macOS${projectContext}${restrictionBlock}${contextBlock}`;
|
package/package.json
CHANGED
package/src/ai.ts
CHANGED
|
@@ -53,6 +53,8 @@ const IRREVERSIBLE_PATTERNS = [
|
|
|
53
53
|
/\bcodemod\b/, /\bsed\s+-i\b/, /\bawk\s.*>\s*\S+\.\w+/, /\bperl\s+-[pi]\b/,
|
|
54
54
|
// File creation/modification (READ-ONLY terminal)
|
|
55
55
|
/\btouch\b/, /\bmkdir\b/, /\becho\s.*>/, /\btee\b/, /\bcp\b/, /\bmv\b/,
|
|
56
|
+
// Starting servers/processes (dangerous from NL)
|
|
57
|
+
/\b(bun|npm|pnpm|yarn)\s+run\s+dev\b/, /\b(bun|npm)\s+start\b/,
|
|
56
58
|
];
|
|
57
59
|
|
|
58
60
|
// Commands that are ALWAYS safe (read-only git, etc.)
|
|
@@ -116,11 +118,13 @@ function detectProjectContext(): string {
|
|
|
116
118
|
if (existsSync(pkgPath)) {
|
|
117
119
|
try {
|
|
118
120
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
119
|
-
parts.push(`Project: Node.js/TypeScript
|
|
121
|
+
parts.push(`Project: ${pkg.name}@${pkg.version} (Node.js/TypeScript)`);
|
|
122
|
+
parts.push(`npm package: ${pkg.name} (use this name for npm view, npm info, etc.)`);
|
|
120
123
|
if (pkg.scripts) {
|
|
121
124
|
const scripts = Object.entries(pkg.scripts).map(([k, v]) => `${k}: ${v}`).slice(0, 8);
|
|
122
125
|
parts.push(`Available scripts: ${scripts.join(", ")}`);
|
|
123
126
|
}
|
|
127
|
+
if (pkg.dependencies) parts.push(`Dependencies: ${Object.keys(pkg.dependencies).join(", ")}`);
|
|
124
128
|
parts.push(`Use npm/bun/pnpm commands, NOT maven/gradle/cargo.`);
|
|
125
129
|
} catch {}
|
|
126
130
|
}
|
|
@@ -259,6 +263,8 @@ SEMANTIC MAPPING: When the user references a concept, search the file tree for R
|
|
|
259
263
|
|
|
260
264
|
ACTION vs CONCEPTUAL: If the prompt starts with "run", "execute", "check", "test", "build", "show output of" — ALWAYS generate an executable command. NEVER read README for action requests. Only read docs for "explain why", "what does X mean", "how was X designed".
|
|
261
265
|
|
|
266
|
+
EXISTENCE CHECKS: If the prompt starts with "is there", "does this have", "do we have", "does X exist" — NEVER run/start/launch anything. Use ls, find, or test -d to CHECK existence. These are READ-ONLY questions.
|
|
267
|
+
|
|
262
268
|
MONOREPO: If the project context says "MONOREPO", search packages/ or apps/ NOT src/. Use: grep -rn "pattern" packages/ --include="*.ts". For specific packages, use packages/PKGNAME/src/.
|
|
263
269
|
cwd: ${process.cwd()}
|
|
264
270
|
shell: zsh / macOS${projectContext}${restrictionBlock}${contextBlock}`;
|