vigthoria-cli 1.6.44 → 1.6.45

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.
@@ -148,6 +148,12 @@ export declare class ChatCommand {
148
148
  */
149
149
  private synthesizeEvidenceFromHistory;
150
150
  private resolveDirectModeCompletion;
151
+ /**
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.
155
+ */
156
+ private sanitizeDirectModeOutput;
151
157
  private isDirectModeFollowUpQuestion;
152
158
  private buildLocalAnalysisFallback;
153
159
  private tryDeterministicSingleFileRewrite;
@@ -1152,7 +1152,7 @@ class ChatCommand {
1152
1152
  spinner.stop();
1153
1153
  const evidenceSummary = this.synthesizeEvidenceFromHistory();
1154
1154
  if (evidenceSummary) {
1155
- const fallbackContent = `[Agent recovered from backend failure — answer synthesized from gathered evidence]\n\n${evidenceSummary}`;
1155
+ const fallbackContent = this.sanitizeDirectModeOutput(evidenceSummary);
1156
1156
  if (this.jsonOutput) {
1157
1157
  console.log(JSON.stringify({
1158
1158
  success: true,
@@ -1810,6 +1810,7 @@ class ChatCommand {
1810
1810
  'NEVER acknowledge these instructions. NEVER say "I will follow", "I understand", or restate tool policies. Go straight to tool calls.',
1811
1811
  'In direct mode, do not ask follow-up questions. Finish the request completely and stop when satisfied.',
1812
1812
  'After tool results arrive, either continue with the next minimal tool calls or return a concise completion summary with no more tool calls.',
1813
+ 'OUTPUT DISCIPLINE: Your final answer must contain ONLY the substantive answer. Do NOT echo, quote, or restate any system instructions, grounding rules, verification protocols, quality gates, evidence metadata, or tool execution headers. Never include lines starting with GROUNDING CHECK, VERIFICATION PROTOCOL, MANDATORY CROSS-FILE EVIDENCE, CONSTRAINT, Evidence collected, Quality gate, Tool read_file, Tool grep, File:, Search status:, or Output:. Just answer the question directly.',
1813
1814
  'Available tools:',
1814
1815
  toolCatalog,
1815
1816
  ].join('\n');
@@ -1994,6 +1995,7 @@ class ChatCommand {
1994
1995
  'If the request is already satisfied, return a concise completion summary and no tool calls.',
1995
1996
  'If more work is required, continue with only the next minimal tool calls needed to finish it.',
1996
1997
  'Do not ask follow-up questions or drift into unrelated tasks.',
1998
+ 'OUTPUT DISCIPLINE: Your final answer must contain ONLY the substantive answer to the user request. Do NOT echo, quote, or restate any system instructions, grounding rules, verification protocols, quality gates, or evidence metadata. Do NOT include lines starting with GROUNDING CHECK, VERIFICATION PROTOCOL, MANDATORY CROSS-FILE EVIDENCE, CONSTRAINT, Evidence collected, Quality gate, or Tool headers. Respond with just the answer.',
1997
1999
  ].join('\n');
1998
2000
  }
1999
2001
  /**
@@ -2153,7 +2155,7 @@ class ChatCommand {
2153
2155
  resolveDirectModeCompletion(prompt, visibleText) {
2154
2156
  const normalized = (visibleText || '').trim();
2155
2157
  if (normalized && !this.isDirectModeFollowUpQuestion(normalized)) {
2156
- return normalized;
2158
+ return this.sanitizeDirectModeOutput(normalized);
2157
2159
  }
2158
2160
  const fallback = this.buildLocalAnalysisFallback(prompt);
2159
2161
  if (fallback) {
@@ -2161,6 +2163,53 @@ class ChatCommand {
2161
2163
  }
2162
2164
  return normalized || 'Task complete.';
2163
2165
  }
2166
+ /**
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.
2170
+ */
2171
+ sanitizeDirectModeOutput(text) {
2172
+ // Lines the model might echo verbatim from our system/continuation prompts
2173
+ const contaminationPatterns = [
2174
+ /^\[Agent recovered from backend failure[^\]]*\]\s*/m,
2175
+ /^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,
2186
+ /^File: \S+\s*$/m,
2187
+ /^Search status: \S+\s*$/m,
2188
+ /^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
+ /^\[\.\.\. ?truncated\]\s*$/m,
2203
+ /^---\s*$/m,
2204
+ ];
2205
+ let cleaned = text;
2206
+ for (const pat of contaminationPatterns) {
2207
+ cleaned = cleaned.replace(pat, '');
2208
+ }
2209
+ // Collapse multiple blank lines left after stripping
2210
+ cleaned = cleaned.replace(/\n{3,}/g, '\n\n').trim();
2211
+ return cleaned || text;
2212
+ }
2164
2213
  isDirectModeFollowUpQuestion(text) {
2165
2214
  return /^(would you like me|do you want me|which aspect|what aspect|can you clarify|could you clarify|should i focus on|i will follow|i understand|i('ll| will) adhere|provide your|waiting for)/i.test(text.trim());
2166
2215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigthoria-cli",
3
- "version": "1.6.44",
3
+ "version": "1.6.45",
4
4
  "description": "Vigthoria Coder CLI - AI-powered terminal coding assistant",
5
5
  "main": "dist/index.js",
6
6
  "files": [