@hasna/terminal 2.0.3 → 2.0.5
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/cli.js +1 -1
- package/dist/output-processor.js +15 -5
- package/package.json +1 -1
- package/src/cli.tsx +1 -1
- package/src/output-processor.ts +15 -5
package/dist/cli.js
CHANGED
|
@@ -550,7 +550,7 @@ else if (args.length > 0) {
|
|
|
550
550
|
// Step 3: Execute
|
|
551
551
|
try {
|
|
552
552
|
const start = Date.now();
|
|
553
|
-
const raw = execSync(actualCmd, { encoding: "utf8", maxBuffer: 10 * 1024 * 1024, cwd: process.cwd() });
|
|
553
|
+
const raw = execSync(actualCmd + " 2>&1", { encoding: "utf8", maxBuffer: 10 * 1024 * 1024, cwd: process.cwd() });
|
|
554
554
|
const duration = Date.now() - start;
|
|
555
555
|
const clean = stripNoise(stripAnsi(raw)).cleaned;
|
|
556
556
|
const rawTokens = estimateTokens(raw);
|
package/dist/output-processor.js
CHANGED
|
@@ -47,15 +47,25 @@ export async function processOutput(command, output, originalPrompt) {
|
|
|
47
47
|
output.slice(-tailChars);
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
// Pre-parse:
|
|
51
|
-
|
|
50
|
+
// Pre-parse: if output contains clear pass/fail counts, extract and return directly
|
|
51
|
+
// No hardcoded test runner list — works for ANY tool that outputs "X pass, Y fail"
|
|
52
52
|
const passMatch = output.match(/(\d+)\s+pass/i);
|
|
53
53
|
const failMatch = output.match(/(\d+)\s+fail/i);
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Pre-parse fires when output has BOTH pass+fail counts AND the user asked about tests
|
|
55
|
+
if (passMatch && failMatch && originalPrompt && /test|pass|fail/i.test(originalPrompt)) {
|
|
56
|
+
const passed = parseInt(passMatch[1]);
|
|
57
|
+
const failed = parseInt(failMatch[1]);
|
|
58
|
+
const answer = failed === 0
|
|
59
|
+
? `✓ Yes, all ${passed} tests pass.`
|
|
60
|
+
: `✗ ${failed} of ${passed + failed} tests failed.`;
|
|
61
|
+
const savedTokens = estimateTokens(output) - estimateTokens(answer);
|
|
62
|
+
return {
|
|
63
|
+
summary: answer, full: output, tokensSaved: Math.max(0, savedTokens),
|
|
64
|
+
aiTokensUsed: 0, aiProcessed: true, aiCostUsd: 0, savingsValueUsd: 0, netSavingsUsd: 0,
|
|
65
|
+
};
|
|
56
66
|
}
|
|
57
67
|
const provider = getProvider();
|
|
58
|
-
const summary = await provider.complete(`${originalPrompt ? `User asked: ${originalPrompt}\n` : ""}Command: ${command}
|
|
68
|
+
const summary = await provider.complete(`${originalPrompt ? `User asked: ${originalPrompt}\n` : ""}Command: ${command}\nOutput (${lines.length} lines):\n${toSummarize}`, {
|
|
59
69
|
system: SUMMARIZE_PROMPT,
|
|
60
70
|
maxTokens: 300,
|
|
61
71
|
});
|
package/package.json
CHANGED
package/src/cli.tsx
CHANGED
|
@@ -535,7 +535,7 @@ else if (args.length > 0) {
|
|
|
535
535
|
// Step 3: Execute
|
|
536
536
|
try {
|
|
537
537
|
const start = Date.now();
|
|
538
|
-
const raw = execSync(actualCmd, { encoding: "utf8", maxBuffer: 10 * 1024 * 1024, cwd: process.cwd() });
|
|
538
|
+
const raw = execSync(actualCmd + " 2>&1", { encoding: "utf8", maxBuffer: 10 * 1024 * 1024, cwd: process.cwd() });
|
|
539
539
|
const duration = Date.now() - start;
|
|
540
540
|
const clean = stripNoise(stripAnsi(raw)).cleaned;
|
|
541
541
|
const rawTokens = estimateTokens(raw);
|
package/src/output-processor.ts
CHANGED
|
@@ -79,17 +79,27 @@ export async function processOutput(
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
try {
|
|
82
|
-
// Pre-parse:
|
|
83
|
-
|
|
82
|
+
// Pre-parse: if output contains clear pass/fail counts, extract and return directly
|
|
83
|
+
// No hardcoded test runner list — works for ANY tool that outputs "X pass, Y fail"
|
|
84
84
|
const passMatch = output.match(/(\d+)\s+pass/i);
|
|
85
85
|
const failMatch = output.match(/(\d+)\s+fail/i);
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
// Pre-parse fires when output has BOTH pass+fail counts AND the user asked about tests
|
|
87
|
+
if (passMatch && failMatch && originalPrompt && /test|pass|fail/i.test(originalPrompt)) {
|
|
88
|
+
const passed = parseInt(passMatch[1]);
|
|
89
|
+
const failed = parseInt(failMatch[1]);
|
|
90
|
+
const answer = failed === 0
|
|
91
|
+
? `✓ Yes, all ${passed} tests pass.`
|
|
92
|
+
: `✗ ${failed} of ${passed + failed} tests failed.`;
|
|
93
|
+
const savedTokens = estimateTokens(output) - estimateTokens(answer);
|
|
94
|
+
return {
|
|
95
|
+
summary: answer, full: output, tokensSaved: Math.max(0, savedTokens),
|
|
96
|
+
aiTokensUsed: 0, aiProcessed: true, aiCostUsd: 0, savingsValueUsd: 0, netSavingsUsd: 0,
|
|
97
|
+
};
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
const provider = getProvider();
|
|
91
101
|
const summary = await provider.complete(
|
|
92
|
-
`${originalPrompt ? `User asked: ${originalPrompt}\n` : ""}Command: ${command}
|
|
102
|
+
`${originalPrompt ? `User asked: ${originalPrompt}\n` : ""}Command: ${command}\nOutput (${lines.length} lines):\n${toSummarize}`,
|
|
93
103
|
{
|
|
94
104
|
system: SUMMARIZE_PROMPT,
|
|
95
105
|
maxTokens: 300,
|