polydev-ai 1.9.21 → 1.9.22
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/lib/cliManager.js +17 -4
- package/package.json +1 -1
package/lib/cliManager.js
CHANGED
|
@@ -1180,10 +1180,14 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
1180
1180
|
const parseCodexOutput = (output) => {
|
|
1181
1181
|
if (!output || !output.trim()) return null;
|
|
1182
1182
|
|
|
1183
|
+
// Strip ANSI escape codes first — Codex CLI wraps markers like 'codex' and
|
|
1184
|
+
// 'tokens used' in bold/color codes which break regex matching
|
|
1185
|
+
const cleanOutput = output.replace(/\x1b\[[0-9;]*m/g, '');
|
|
1186
|
+
|
|
1183
1187
|
// First, try to extract the response between "codex" marker and "tokens used"
|
|
1184
1188
|
// IMPORTANT: Use (?:^|\n) to match "codex" only at the start of a line
|
|
1185
1189
|
// This prevents matching "codex" in model names like "gpt-5.2-codex"
|
|
1186
|
-
const codexMarkerMatch =
|
|
1190
|
+
const codexMarkerMatch = cleanOutput.match(/(?:^|\n)codex\s*\n([\s\S]*?)(?:\n\s*tokens used|\n\s*$)/i);
|
|
1187
1191
|
if (codexMarkerMatch && codexMarkerMatch[1]) {
|
|
1188
1192
|
const extracted = codexMarkerMatch[1].trim();
|
|
1189
1193
|
if (extracted.length > 0 && !extracted.startsWith('ERROR')) {
|
|
@@ -1192,7 +1196,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
1192
1196
|
}
|
|
1193
1197
|
|
|
1194
1198
|
// Fallback: Try to find bullet point responses
|
|
1195
|
-
const bulletMatches =
|
|
1199
|
+
const bulletMatches = cleanOutput.match(/•\s*(.+)/g);
|
|
1196
1200
|
if (bulletMatches && bulletMatches.length > 0) {
|
|
1197
1201
|
const bulletContent = bulletMatches
|
|
1198
1202
|
.map(m => m.replace(/^•\s*/, '').trim())
|
|
@@ -1204,8 +1208,9 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
1204
1208
|
}
|
|
1205
1209
|
|
|
1206
1210
|
// Last resort: Filter out known noise patterns line by line
|
|
1207
|
-
const lines =
|
|
1211
|
+
const lines = cleanOutput.split('\n');
|
|
1208
1212
|
const contentLines = [];
|
|
1213
|
+
let seenTokensUsed = false;
|
|
1209
1214
|
|
|
1210
1215
|
// Patterns to skip (Codex-specific noise)
|
|
1211
1216
|
const noisePatterns = [
|
|
@@ -1225,7 +1230,6 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
1225
1230
|
/^thinking$/i, // "thinking" marker
|
|
1226
1231
|
/^codex$/i, // "codex" marker
|
|
1227
1232
|
/^tokens used$/i, // Token count header
|
|
1228
|
-
/^[\d,]+$/, // Just numbers (token counts)
|
|
1229
1233
|
/^ERROR:\s*MCP/i, // MCP errors
|
|
1230
1234
|
/MCP client for .* failed/i, // MCP client failures
|
|
1231
1235
|
/handshake.*failed/i, // Handshake errors
|
|
@@ -1240,6 +1244,15 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
|
|
|
1240
1244
|
for (const line of lines) {
|
|
1241
1245
|
const trimmedLine = line.trim();
|
|
1242
1246
|
|
|
1247
|
+
// Track when we've passed the "tokens used" footer
|
|
1248
|
+
if (/^tokens used$/i.test(trimmedLine)) {
|
|
1249
|
+
seenTokensUsed = true;
|
|
1250
|
+
continue;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// After "tokens used", skip pure numbers (token counts like "22")
|
|
1254
|
+
if (seenTokensUsed && /^[\d,]+$/.test(trimmedLine)) continue;
|
|
1255
|
+
|
|
1243
1256
|
// Check if line matches any noise pattern
|
|
1244
1257
|
const isNoise = noisePatterns.some(pattern => pattern.test(trimmedLine));
|
|
1245
1258
|
if (isNoise) continue;
|