vigthoria-cli 1.6.43 → 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.
@@ -138,6 +138,7 @@ class AuthCommand {
138
138
  this.logger.warn('Not logged in');
139
139
  console.log();
140
140
  console.log(chalk_1.default.gray('Run `vigthoria login` to authenticate'));
141
+ this.api.destroy();
141
142
  return;
142
143
  }
143
144
  const email = this.config.get('email');
@@ -174,6 +175,7 @@ class AuthCommand {
174
175
  console.log();
175
176
  // Run ALL three probes in parallel — they are independent.
176
177
  const spinner = (0, logger_js_1.createSpinner)('Checking API, capabilities and auth...').start();
178
+ let capabilityTimeout = null;
177
179
  const [apiStatus, capabilityStatus, tokenValidation] = await Promise.all([
178
180
  this.api.getHealthStatus(),
179
181
  Promise.race([
@@ -182,16 +184,20 @@ class AuthCommand {
182
184
  projectPath: process.cwd(),
183
185
  targetPath: process.cwd(),
184
186
  }),
185
- new Promise(resolve => setTimeout(() => resolve({
186
- overallOk: false,
187
- v3Agent: { name: 'V3 Agent', endpoint: '', ok: false, error: 'Timed out (8s)' },
188
- hyperLoop: { name: 'Hyper Loop', endpoint: '', ok: false, error: 'Timed out (8s)' },
189
- repoMemory: { name: 'Repo Memory', endpoint: '', ok: false, error: 'Timed out (8s)' },
190
- devtoolsBridge: { name: 'DevTools Bridge', endpoint: '', ok: false, error: 'Timed out (8s)' },
191
- }), 8000)),
187
+ new Promise(resolve => {
188
+ capabilityTimeout = setTimeout(() => resolve({
189
+ overallOk: false,
190
+ v3Agent: { name: 'V3 Agent', endpoint: '', ok: false, error: 'Timed out (8s)' },
191
+ hyperLoop: { name: 'Hyper Loop', endpoint: '', ok: false, error: 'Timed out (8s)' },
192
+ repoMemory: { name: 'Repo Memory', endpoint: '', ok: false, error: 'Timed out (8s)' },
193
+ devtoolsBridge: { name: 'DevTools Bridge', endpoint: '', ok: false, error: 'Timed out (8s)' },
194
+ }), 8000);
195
+ }),
192
196
  ]),
193
197
  this.api.validateToken(),
194
198
  ]);
199
+ if (capabilityTimeout)
200
+ clearTimeout(capabilityTimeout);
195
201
  spinner.stop();
196
202
  // --- Display API Status ---
197
203
  console.log(chalk_1.default.white('API Status:'));
@@ -249,13 +255,11 @@ class AuthCommand {
249
255
  console.log(chalk_1.default.gray(' Bridge Auth: ') + (capabilityStatus.devtoolsBridge.ok ? chalk_1.default.green('Connected') : chalk_1.default.gray('N/A — bridge not running')) + chalk_1.default.gray(' (used by --bridge flag only)'));
250
256
  console.log();
251
257
  // Graceful exit — destroy keep-alive agents so the event loop drains
252
- // naturally instead of calling process.exit(0), which on
253
- // Windows / Node 25 triggers a libuv UV_HANDLE_CLOSING assertion
254
- // when async handles are still being cleaned up.
258
+ // naturally. Setting exitCode (not calling process.exit()) avoids the
259
+ // libuv UV_HANDLE_CLOSING assertion on Windows that occurs when
260
+ // process.exit() is invoked while socket handles are mid-close.
255
261
  this.api.destroy();
256
- // Fallback: if straggler handles still keep the loop alive after
257
- // 150 ms, force exit (unref'd so it won't block a clean drain).
258
- setTimeout(() => process.exit(0), 150).unref();
262
+ process.exitCode = 0;
259
263
  }
260
264
  printLoginSuccess() {
261
265
  const email = this.config.get('email');
@@ -32,6 +32,8 @@ class BridgeCommand {
32
32
  ? chalk_1.default.green('Local browser observability is available for debugging flows.')
33
33
  : chalk_1.default.gray('Start the DevTools Bridge to enable local browser observability.')));
34
34
  console.log();
35
+ this.api.destroy();
36
+ process.exitCode = 0;
35
37
  }
36
38
  }
37
39
  exports.BridgeCommand = BridgeCommand;
@@ -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/dist/index.js CHANGED
@@ -752,5 +752,5 @@ async function main() {
752
752
  }
753
753
  main().catch((err) => {
754
754
  console.error(chalk_1.default.red('Error:'), err.message);
755
- process.exit(1);
755
+ process.exitCode = 1;
756
756
  });
package/dist/utils/api.js CHANGED
@@ -148,6 +148,7 @@ class APIClient {
148
148
  this.selfHostedModelRouterClient = selfHostedModelsApiUrl ? axios_1.default.create({
149
149
  baseURL: selfHostedModelsApiUrl,
150
150
  timeout: 240000,
151
+ httpsAgent,
151
152
  headers: {
152
153
  'Content-Type': 'application/json',
153
154
  'User-Agent': `Vigthoria-CLI/${process.env.npm_package_version || '1.6.9'}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigthoria-cli",
3
- "version": "1.6.43",
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": [
@@ -86,4 +86,4 @@
86
86
  "engines": {
87
87
  "node": ">=18.0.0"
88
88
  }
89
- }
89
+ }