@hasna/terminal 2.0.3 → 2.0.4
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/output-processor.js +15 -5
- package/package.json +1 -1
- package/src/output-processor.ts +15 -5
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/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,
|