vigthoria-cli 1.6.44 → 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.
- package/dist/commands/chat.d.ts +7 -0
- package/dist/commands/chat.js +81 -2
- package/package.json +1 -1
package/dist/commands/chat.d.ts
CHANGED
|
@@ -148,6 +148,13 @@ 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, 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.
|
|
156
|
+
*/
|
|
157
|
+
private sanitizeDirectModeOutput;
|
|
151
158
|
private isDirectModeFollowUpQuestion;
|
|
152
159
|
private buildLocalAnalysisFallback;
|
|
153
160
|
private tryDeterministicSingleFileRewrite;
|
package/dist/commands/chat.js
CHANGED
|
@@ -1152,7 +1152,7 @@ class ChatCommand {
|
|
|
1152
1152
|
spinner.stop();
|
|
1153
1153
|
const evidenceSummary = this.synthesizeEvidenceFromHistory();
|
|
1154
1154
|
if (evidenceSummary) {
|
|
1155
|
-
const fallbackContent =
|
|
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,83 @@ 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, 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.
|
|
2171
|
+
*/
|
|
2172
|
+
sanitizeDirectModeOutput(text) {
|
|
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 ──
|
|
2182
|
+
const contaminationPatterns = [
|
|
2183
|
+
/^\[Agent recovered from backend failure[^\]]*\]\s*/m,
|
|
2184
|
+
/^Evidence gathered before backend failure:?\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,
|
|
2208
|
+
/^File: \S+\s*$/m,
|
|
2209
|
+
/^Search status: \S+\s*$/m,
|
|
2210
|
+
/^Output:\s*$/m,
|
|
2211
|
+
/^\[\.\.\. ?truncated\]\s*$/m,
|
|
2212
|
+
/^---\s*$/m,
|
|
2213
|
+
];
|
|
2214
|
+
for (const pat of contaminationPatterns) {
|
|
2215
|
+
cleaned = cleaned.replace(pat, '');
|
|
2216
|
+
}
|
|
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
|
|
2240
|
+
cleaned = cleaned.replace(/\n{3,}/g, '\n\n').trim();
|
|
2241
|
+
return cleaned || text;
|
|
2242
|
+
}
|
|
2164
2243
|
isDirectModeFollowUpQuestion(text) {
|
|
2165
2244
|
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
2245
|
}
|