vigthoria-cli 1.6.40 → 1.6.41
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 +10 -2
- package/dist/commands/chat.js +100 -4
- package/package.json +1 -1
package/dist/commands/chat.d.ts
CHANGED
|
@@ -55,8 +55,9 @@ export declare class ChatCommand {
|
|
|
55
55
|
private isBrowserTaskPrompt;
|
|
56
56
|
/**
|
|
57
57
|
* Returns true when a prompt can be answered directly without the full
|
|
58
|
-
* BMAD operator workflow. Matches analysis/lookup questions
|
|
59
|
-
*
|
|
58
|
+
* BMAD operator workflow. Matches analysis/lookup questions as well as
|
|
59
|
+
* short echo/smoke-test prompts that don't require code generation,
|
|
60
|
+
* file scanning, or infrastructure changes.
|
|
60
61
|
*/
|
|
61
62
|
private isOperatorDirectAnswerable;
|
|
62
63
|
private inferAgentTaskType;
|
|
@@ -92,6 +93,13 @@ export declare class ChatCommand {
|
|
|
92
93
|
private formatWorkflowTargetResult;
|
|
93
94
|
private runWorkflowTargetPrompt;
|
|
94
95
|
private runOperatorTurn;
|
|
96
|
+
/**
|
|
97
|
+
* Fast-path for operator prompts that don't need the full BMAD workflow.
|
|
98
|
+
* Uses the regular chat API with a strong operator system message so
|
|
99
|
+
* the user gets an instant, grounded answer instead of waiting for the
|
|
100
|
+
* BMAD orchestrator to scan the workspace.
|
|
101
|
+
*/
|
|
102
|
+
private runOperatorDirectAnswer;
|
|
95
103
|
private runSimplePrompt;
|
|
96
104
|
private runAgentTurn;
|
|
97
105
|
private runLocalAgentLoop;
|
package/dist/commands/chat.js
CHANGED
|
@@ -210,11 +210,17 @@ class ChatCommand {
|
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
212
|
* Returns true when a prompt can be answered directly without the full
|
|
213
|
-
* BMAD operator workflow. Matches analysis/lookup questions
|
|
214
|
-
*
|
|
213
|
+
* BMAD operator workflow. Matches analysis/lookup questions as well as
|
|
214
|
+
* short echo/smoke-test prompts that don't require code generation,
|
|
215
|
+
* file scanning, or infrastructure changes.
|
|
215
216
|
*/
|
|
216
217
|
isOperatorDirectAnswerable(prompt) {
|
|
217
|
-
|
|
218
|
+
const trimmed = prompt.trim();
|
|
219
|
+
// Short prompts (under 200 chars) that do not contain action verbs
|
|
220
|
+
// targeting infrastructure are almost always direct-answerable.
|
|
221
|
+
const isShortNonAction = trimmed.length < 200
|
|
222
|
+
&& !/\b(deploy|provision|scale|migrate|rollback|restart|install|configure|create|build|scaffold|generate|set up|tear down|spin up|initialize|bootstrap)\b/i.test(trimmed);
|
|
223
|
+
return this.isAnalysisLookupPrompt(trimmed) || isShortNonAction;
|
|
218
224
|
}
|
|
219
225
|
inferAgentTaskType(prompt) {
|
|
220
226
|
if (this.isDiagnosticPrompt(prompt))
|
|
@@ -230,7 +236,7 @@ class ChatCommand {
|
|
|
230
236
|
instructions.push('Platform: Windows. Use list_dir, glob, read_file, and the grep tool for searching.', 'The grep tool handles Windows automatically — do not use bash to call grep, findstr, or Select-String manually.', 'Do not use bash for Unix commands (cat, head, tail, awk, sed, wc).', 'Use read_file to inspect file contents instead of shell commands.', 'All file paths use forward slashes internally.');
|
|
231
237
|
}
|
|
232
238
|
if (this.isDiagnosticPrompt(prompt)) {
|
|
233
|
-
instructions.push('Diagnostic mode is active.', 'Treat this as a debugging task, not a generic code review or feature request.', 'Start with concrete evidence: logs, runtime errors, config, launch files, and exact symbol references.', 'If log files exist, inspect them before proposing fixes.', 'Do not claim a file, definition, asset, or symbol is missing until you verify that with tools.', 'If a prior diagnosis mentioned a missing symbol or YAML entry, re-check the actual files before repeating it.', 'Prefer grep plus read_file around the exact references involved in the failure.', 'Separate your reasoning into: Evidence, Confirmed Cause, and Remaining Hypotheses.', 'Do not suggest speculative fixes when the current evidence contradicts them.');
|
|
239
|
+
instructions.push('Diagnostic mode is active.', 'Treat this as a debugging task, not a generic code review or feature request.', 'Start with concrete evidence: logs, runtime errors, config, launch files, and exact symbol references.', 'If log files exist, inspect them before proposing fixes.', 'Do not claim a file, definition, asset, or symbol is missing until you verify that with tools.', 'If a prior diagnosis mentioned a missing symbol or YAML entry, re-check the actual files before repeating it.', 'Prefer grep plus read_file around the exact references involved in the failure.', 'Separate your reasoning into: Evidence, Confirmed Cause, and Remaining Hypotheses.', 'Do not suggest speculative fixes when the current evidence contradicts them.', 'CRITICAL GROUNDING RULE: Every key name, variable name, symbol, or identifier you mention in your final answer MUST appear verbatim in the tool output you received. If a key/symbol does NOT appear in tool output, you MUST NOT mention it as involved in any conflict or issue.', 'CROSS-FILE ATTRIBUTION: When reporting conflicts between two files, a key/symbol is conflicting ONLY if it appears in BOTH files. Read each file carefully and list only the exact keys that appear in the relevant handler/function of EACH file. Do not assume that because one file handles a key, the other file does too.', 'When reporting conflicts between files, cite the exact file name, line number, and the exact string/key from the tool output. Do not paraphrase or substitute key names.', 'Before concluding, re-check: (1) does every key/symbol in my answer actually appear in the evidence I gathered? (2) for each claimed conflict, did I verify the key appears in BOTH files? If not, correct your answer.');
|
|
234
240
|
}
|
|
235
241
|
if (this.isBrowserTaskPrompt(prompt)) {
|
|
236
242
|
instructions.push('Browser-debug mode is active.', 'Prefer concrete browser evidence such as console errors, network failures, DOM state, and websocket behavior.', 'If a DevTools Bridge is available, use it as the primary browser observability path.');
|
|
@@ -783,6 +789,15 @@ class ChatCommand {
|
|
|
783
789
|
this.logger.error(this.operatorAccessMessage());
|
|
784
790
|
return;
|
|
785
791
|
}
|
|
792
|
+
// ── Fast-path: direct-answerable prompts skip the full BMAD workflow ──
|
|
793
|
+
// The BMAD orchestrator scans the entire workspace (can be 1000+ files)
|
|
794
|
+
// even for trivial prompts like "Reply with exactly: OK". Route these
|
|
795
|
+
// through the regular chat API with a strong operator system message
|
|
796
|
+
// so the user gets an instant, grounded answer.
|
|
797
|
+
if (this.isOperatorDirectAnswerable(prompt)) {
|
|
798
|
+
await this.runOperatorDirectAnswer(prompt);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
786
801
|
(0, bridge_client_js_1.getBridgeClient)()?.emitPrompt({ prompt, mode: 'operator', model: this.currentModel });
|
|
787
802
|
const runtimeContext = await this.getPromptRuntimeContext(prompt);
|
|
788
803
|
const spinner = this.jsonOutput ? null : (0, logger_js_1.createSpinner)({ text: 'Thinking like an operator...', spinner: 'clock' }).start();
|
|
@@ -858,6 +873,83 @@ class ChatCommand {
|
|
|
858
873
|
}
|
|
859
874
|
}
|
|
860
875
|
}
|
|
876
|
+
/**
|
|
877
|
+
* Fast-path for operator prompts that don't need the full BMAD workflow.
|
|
878
|
+
* Uses the regular chat API with a strong operator system message so
|
|
879
|
+
* the user gets an instant, grounded answer instead of waiting for the
|
|
880
|
+
* BMAD orchestrator to scan the workspace.
|
|
881
|
+
*/
|
|
882
|
+
async runOperatorDirectAnswer(prompt) {
|
|
883
|
+
(0, bridge_client_js_1.getBridgeClient)()?.emitPrompt({ prompt, mode: 'operator-direct', model: this.currentModel });
|
|
884
|
+
const spinner = this.jsonOutput ? null : (0, logger_js_1.createSpinner)({ text: 'Operator (direct)...', spinner: 'clock' }).start();
|
|
885
|
+
try {
|
|
886
|
+
let operatorGrounding = [
|
|
887
|
+
'You are Vigthoria Operator, a DevOps and infrastructure analysis assistant.',
|
|
888
|
+
`Workspace: ${this.currentProjectPath}`,
|
|
889
|
+
'Answer the user\'s question directly with a concrete, actionable answer.',
|
|
890
|
+
'Do NOT acknowledge instructions. Do NOT say "provide your next instruction".',
|
|
891
|
+
'If asked to produce exact output, produce exactly that output with no preamble.',
|
|
892
|
+
].join('\n');
|
|
893
|
+
try {
|
|
894
|
+
const snapshot = this.api.getAgentWorkspaceSnapshot(this.currentProjectPath);
|
|
895
|
+
if (snapshot && snapshot.paths.length > 0) {
|
|
896
|
+
const listing = snapshot.paths.slice(0, 80).join('\n');
|
|
897
|
+
operatorGrounding += `\n\nProject file listing (${snapshot.fileCount} files):\n${listing}`;
|
|
898
|
+
if (snapshot.fileCount > 80) {
|
|
899
|
+
operatorGrounding += `\n... and ${snapshot.fileCount - 80} more files.`;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
catch { /* ignore */ }
|
|
904
|
+
const chatMessages = [
|
|
905
|
+
{ role: 'system', content: operatorGrounding },
|
|
906
|
+
...this.getMessagesForModel().filter(m => m.role !== 'system'),
|
|
907
|
+
{ role: 'user', content: prompt },
|
|
908
|
+
];
|
|
909
|
+
const response = await this.api.chat(chatMessages, this.currentModel);
|
|
910
|
+
if (spinner)
|
|
911
|
+
spinner.stop();
|
|
912
|
+
const content = (response.message || '').trim();
|
|
913
|
+
const isPolicyAck = /^(i will follow|i understand|i('ll| will) adhere|understood[.,!]|sure[.,!]|provide your|waiting for|i('ll| will) proceed)/i.test(content)
|
|
914
|
+
|| (content.length < 200 && /follow the instructions|next instruction|ready to assist/i.test(content));
|
|
915
|
+
if (isPolicyAck || !content) {
|
|
916
|
+
throw new api_js_1.CLIError('Operator returned a non-actionable acknowledgement instead of a grounded result.', 'model_backend');
|
|
917
|
+
}
|
|
918
|
+
if (this.jsonOutput) {
|
|
919
|
+
console.log(JSON.stringify({
|
|
920
|
+
success: true,
|
|
921
|
+
mode: 'operator',
|
|
922
|
+
content,
|
|
923
|
+
metadata: { source: 'operator-direct', mode: 'operator' },
|
|
924
|
+
}, null, 2));
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
console.log(content);
|
|
928
|
+
}
|
|
929
|
+
this.messages.push({ role: 'assistant', content });
|
|
930
|
+
this.saveSession();
|
|
931
|
+
}
|
|
932
|
+
catch (error) {
|
|
933
|
+
if (spinner)
|
|
934
|
+
spinner.stop();
|
|
935
|
+
const cliErr = error instanceof api_js_1.CLIError ? error : (0, api_js_1.classifyError)(error);
|
|
936
|
+
const errorMsg = (0, api_js_1.formatCLIError)(cliErr);
|
|
937
|
+
if (this.jsonOutput) {
|
|
938
|
+
process.exitCode = 1;
|
|
939
|
+
console.log(JSON.stringify({
|
|
940
|
+
success: false,
|
|
941
|
+
mode: 'operator',
|
|
942
|
+
content: '',
|
|
943
|
+
error: errorMsg,
|
|
944
|
+
errorCategory: cliErr.category,
|
|
945
|
+
}, null, 2));
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
this.logger.error('Operator direct answer failed');
|
|
949
|
+
this.logger.error(errorMsg);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
861
953
|
async runSimplePrompt(prompt) {
|
|
862
954
|
this.lastActionableUserInput = prompt;
|
|
863
955
|
// For direct --prompt mode with simple prompts, use a minimal system
|
|
@@ -1628,6 +1720,8 @@ class ChatCommand {
|
|
|
1628
1720
|
'When diagnosing failures, prefer evidence-backed conclusions over broad repo scans.',
|
|
1629
1721
|
'If the user corrects you, treat that as evidence that your previous assumption was wrong and re-check with tools.',
|
|
1630
1722
|
'Do not stop after a partial answer when more direct inspection is possible.',
|
|
1723
|
+
'EVIDENCE-GROUNDING RULE: Every identifier, key name, variable, or symbol you cite in your final answer MUST appear verbatim in tool output you received during this session. Never invent or guess identifiers. If you read a file and saw "KeyA" and "KeyS" on specific lines, cite those exact strings — do not substitute "KeyR" or any other key that was not in the output.',
|
|
1724
|
+
'CROSS-FILE RULE: When comparing two or more files, only claim a key/symbol is conflicting or shared if it literally appears in the relevant function/handler of EACH file you read. Finding a key in File A does not mean it also exists in File B — verify each file independently. Use grep to confirm a key exists in a file before claiming that file handles it.',
|
|
1631
1725
|
'When you need a tool, emit only one or more tool wrappers in this exact format:',
|
|
1632
1726
|
'<tool_call>',
|
|
1633
1727
|
'{"tool":"read_file","args":{"path":"relative/path.ext"}}',
|
|
@@ -1811,6 +1905,8 @@ class ChatCommand {
|
|
|
1811
1905
|
'Do not declare success until the exact user question has been answered with tool-backed evidence.',
|
|
1812
1906
|
'If a user is asking which file is correct or most recent, keep inspecting until you can justify the answer from actual results.',
|
|
1813
1907
|
diagnosticMode ? 'Because this is a debugging task, prefer logs, runtime evidence, and exact symbol references over generic fixes.' : 'Keep working from concrete tool results.',
|
|
1908
|
+
'GROUNDING CHECK: Before writing your final answer, verify that every identifier, key name, or symbol you mention actually appeared in tool output above. Do not invent identifiers that were not in the evidence. If you saw "KeyA" and "KeyS" in the file contents, use those exact names — never substitute a different key. For cross-file comparisons, confirm each claimed conflict key appears in the handler/function of BOTH files — not just one.',
|
|
1909
|
+
'VERIFICATION PROTOCOL for cross-file comparisons: If your answer claims a key/identifier appears in multiple files, you MUST first use grep to search for that exact identifier in each file BEFORE including it in your answer. Only include keys/identifiers that grep confirms exist in each file. Example: to verify "KeyW" is in InputManager.js, use grep for "KeyW" in that file. If grep finds no match, do NOT claim that file handles "KeyW".',
|
|
1814
1910
|
'If the request is already satisfied, return a concise completion summary and no tool calls.',
|
|
1815
1911
|
'If more work is required, continue with only the next minimal tool calls needed to finish it.',
|
|
1816
1912
|
'Do not ask follow-up questions or drift into unrelated tasks.',
|