vigthoria-cli 1.6.45 → 1.6.46

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.
@@ -150,8 +150,9 @@ export declare class ChatCommand {
150
150
  private resolveDirectModeCompletion;
151
151
  /**
152
152
  * Strip system-prompt echoes, tool execution headers, grounding-rule
153
- * parroting, and recovery banners from the model's final answer so that
154
- * --json output contains only the substantive answer.
153
+ * parroting, recovery banners, and multi-line tool output blocks from
154
+ * the model's final answer so that --json output contains only the
155
+ * substantive answer.
155
156
  */
156
157
  private sanitizeDirectModeOutput;
157
158
  private isDirectModeFollowUpQuestion;
@@ -2165,48 +2165,78 @@ class ChatCommand {
2165
2165
  }
2166
2166
  /**
2167
2167
  * Strip system-prompt echoes, tool execution headers, grounding-rule
2168
- * parroting, and recovery banners from the model's final answer so that
2169
- * --json output contains only the substantive answer.
2168
+ * parroting, recovery banners, and multi-line tool output blocks from
2169
+ * the model's final answer so that --json output contains only the
2170
+ * substantive answer.
2170
2171
  */
2171
2172
  sanitizeDirectModeOutput(text) {
2172
- // Lines the model might echo verbatim from our system/continuation prompts
2173
+ let cleaned = text;
2174
+ // ── Phase 1: Strip entire multi-line tool-output blocks ──
2175
+ // Pattern: "Tool <name> succeeded/FAILED." followed by optional
2176
+ // metadata lines (File:, Search status:, Output:) and then a
2177
+ // content block until the next double-newline or end-of-string.
2178
+ cleaned = cleaned.replace(/Tool (?:read_file|grep|list_dir|glob|bash|write_file) (?:succeeded|FAILED)\.[\s\S]*?(?=\n\n[A-Z_]+:|$)/g, '');
2179
+ // Fallback: simpler block pattern for any remaining tool headers
2180
+ cleaned = cleaned.replace(/Tool (?:read_file|grep|list_dir|glob|bash|write_file) (?:succeeded|FAILED)\.[\s\S]*?(?:\n\n|\s*$)/g, '');
2181
+ // ── Phase 2: Strip echoed system-prompt / grounding lines ──
2173
2182
  const contaminationPatterns = [
2174
2183
  /^\[Agent recovered from backend failure[^\]]*\]\s*/m,
2175
2184
  /^Evidence gathered before backend failure:?\s*/m,
2176
- /^MANDATORY CROSS-FILE EVIDENCE \(computed from actual tool output[^)]*\):?\s*/m,
2177
- /^CONFIRMED CONFLICTING keys \(found in MULTIPLE files\):.*$/m,
2178
- /^Keys found ONLY in .+\(NOT in other files\):.*$/m,
2179
- /^CONSTRAINT: Your answer MUST list ONLY the keys from.*$/m,
2180
- /^GROUNDING CHECK:.*$/m,
2181
- /^VERIFICATION PROTOCOL for cross-file comparisons:.*$/m,
2182
- /^Quality gate: only \d+ discovery tool\(s\).*$/m,
2183
- /^Evidence collected: \d+ discovery.*$/m,
2184
- /^Warning: \d+ search tool call\(s\) failed\..*$/m,
2185
- /^Tool (?:read_file|grep|list_dir|glob|bash|write_file) (?:succeeded|FAILED)\.\s*/m,
2185
+ /^MANDATORY CROSS-FILE EVIDENCE[^\n]*\n?/m,
2186
+ /^CONFIRMED CONFLICTING keys[^\n]*/m,
2187
+ /^Keys found ONLY in [^\n]*/m,
2188
+ /^CONSTRAINT: Your answer MUST[^\n]*/m,
2189
+ /^GROUNDING CHECK:[^\n]*/m,
2190
+ /^VERIFICATION PROTOCOL[^\n]*/m,
2191
+ /^Quality gate:[^\n]*/m,
2192
+ /^Evidence collected:[^\n]*/m,
2193
+ /^Warning: \d+ search tool[^\n]*/m,
2194
+ /^Tool results received for direct mode[^\n]*/m,
2195
+ /^Original user request:[^\n]*/m,
2196
+ /^Project root boundary:[^\n]*/m,
2197
+ /^Do not declare success[^\n]*/m,
2198
+ /^Keep working from concrete[^\n]*/m,
2199
+ /^Because this is a debugging[^\n]*/m,
2200
+ /^If the request is already[^\n]*/m,
2201
+ /^If more work is required[^\n]*/m,
2202
+ /^Do not ask follow-up[^\n]*/m,
2203
+ /^CRITICAL GROUNDING RULE:[^\n]*/m,
2204
+ /^CROSS-FILE ATTRIBUTION:[^\n]*/m,
2205
+ /^EVIDENCE-GROUNDING RULE:[^\n]*/m,
2206
+ /^CROSS-FILE RULE:[^\n]*/m,
2207
+ /^OUTPUT DISCIPLINE:[^\n]*/m,
2186
2208
  /^File: \S+\s*$/m,
2187
2209
  /^Search status: \S+\s*$/m,
2188
2210
  /^Output:\s*$/m,
2189
- /^Tool results received for direct mode step \d+\.\s*$/m,
2190
- /^Original user request:.*$/m,
2191
- /^Project root boundary:.*$/m,
2192
- /^Do not declare success until.*$/m,
2193
- /^Keep working from concrete tool results\.\s*$/m,
2194
- /^Because this is a debugging task.*$/m,
2195
- /^If the request is already satisfied.*$/m,
2196
- /^If more work is required.*$/m,
2197
- /^Do not ask follow-up questions.*$/m,
2198
- /^CRITICAL GROUNDING RULE:.*$/m,
2199
- /^CROSS-FILE ATTRIBUTION:.*$/m,
2200
- /^EVIDENCE-GROUNDING RULE:.*$/m,
2201
- /^CROSS-FILE RULE:.*$/m,
2202
2211
  /^\[\.\.\. ?truncated\]\s*$/m,
2203
2212
  /^---\s*$/m,
2204
2213
  ];
2205
- let cleaned = text;
2206
2214
  for (const pat of contaminationPatterns) {
2207
2215
  cleaned = cleaned.replace(pat, '');
2208
2216
  }
2209
- // Collapse multiple blank lines left after stripping
2217
+ // ── Phase 3: Paragraph-level filter ──
2218
+ // Split into paragraph blocks and discard any that are pure tool
2219
+ // output, file content dumps, or system-instruction echoes.
2220
+ const paragraphs = cleaned.split(/\n\n+/);
2221
+ const kept = paragraphs.filter(p => {
2222
+ const t = p.trim();
2223
+ if (!t)
2224
+ return false;
2225
+ // Discard lingering tool headers
2226
+ if (/^Tool (?:read_file|grep|list_dir|glob|bash|write_file) /i.test(t))
2227
+ return false;
2228
+ // Discard paragraphs that are mostly file-content dumps (many
2229
+ // lines of code with typical code tokens like { } ; = function class)
2230
+ const lines = t.split('\n');
2231
+ if (lines.length > 6) {
2232
+ const codeLines = lines.filter(l => /[{};=]|function |class |const |let |var |import |export |switch |case /.test(l));
2233
+ if (codeLines.length / lines.length > 0.4)
2234
+ return false;
2235
+ }
2236
+ return true;
2237
+ });
2238
+ cleaned = kept.join('\n\n');
2239
+ // Collapse multiple blank lines
2210
2240
  cleaned = cleaned.replace(/\n{3,}/g, '\n\n').trim();
2211
2241
  return cleaned || text;
2212
2242
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigthoria-cli",
3
- "version": "1.6.45",
3
+ "version": "1.6.46",
4
4
  "description": "Vigthoria Coder CLI - AI-powered terminal coding assistant",
5
5
  "main": "dist/index.js",
6
6
  "files": [