sam-coder-cli 1.0.60 → 1.0.62
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/bin/agi-cli.js +6 -11
- package/bin/ui.js +21 -1
- package/package.json +1 -1
package/bin/agi-cli.js
CHANGED
|
@@ -557,7 +557,6 @@ const agentUtils = {
|
|
|
557
557
|
// Extract JSON from markdown code blocks
|
|
558
558
|
function extractJsonFromMarkdown(text) {
|
|
559
559
|
if (!text || typeof text !== 'string') {
|
|
560
|
-
console.error('Invalid input to extractJsonFromMarkdown:', typeof text);
|
|
561
560
|
return null;
|
|
562
561
|
}
|
|
563
562
|
|
|
@@ -569,13 +568,11 @@ function extractJsonFromMarkdown(text) {
|
|
|
569
568
|
try {
|
|
570
569
|
const jsonStr = match[1].trim();
|
|
571
570
|
if (!jsonStr) {
|
|
572
|
-
console.error('Empty JSON content in markdown block');
|
|
573
571
|
return null;
|
|
574
572
|
}
|
|
575
573
|
return JSON.parse(jsonStr);
|
|
576
574
|
} catch (error) {
|
|
577
|
-
|
|
578
|
-
console.error('JSON content was:', match[1]);
|
|
575
|
+
// ignore
|
|
579
576
|
}
|
|
580
577
|
}
|
|
581
578
|
|
|
@@ -615,8 +612,6 @@ function extractJsonFromMarkdown(text) {
|
|
|
615
612
|
// Last resort failed
|
|
616
613
|
}
|
|
617
614
|
|
|
618
|
-
console.error('Failed to extract valid JSON from response');
|
|
619
|
-
console.error('Response text was:', text);
|
|
620
615
|
return null;
|
|
621
616
|
}
|
|
622
617
|
|
|
@@ -817,7 +812,7 @@ async function processQueryWithTools(query, conversation = [], currentModel) {
|
|
|
817
812
|
if (assistantMessage && typeof assistantMessage.content === 'string') {
|
|
818
813
|
const { thought, content } = splitThinking(assistantMessage.content);
|
|
819
814
|
if (thought && SHOW_THOUGHTS) {
|
|
820
|
-
ui.
|
|
815
|
+
ui.showThought(thought);
|
|
821
816
|
}
|
|
822
817
|
assistantMessage.content = content;
|
|
823
818
|
}
|
|
@@ -841,7 +836,7 @@ async function processQueryWithTools(query, conversation = [], currentModel) {
|
|
|
841
836
|
if (finalAssistantMessage && typeof finalAssistantMessage.content === 'string') {
|
|
842
837
|
const { thought, content } = splitThinking(finalAssistantMessage.content);
|
|
843
838
|
if (thought && SHOW_THOUGHTS) {
|
|
844
|
-
ui.
|
|
839
|
+
ui.showThought(thought);
|
|
845
840
|
}
|
|
846
841
|
finalAssistantMessage.content = content;
|
|
847
842
|
}
|
|
@@ -866,7 +861,7 @@ async function processQueryWithTools(query, conversation = [], currentModel) {
|
|
|
866
861
|
if (finalAssistantMessage && typeof finalAssistantMessage.content === 'string') {
|
|
867
862
|
const { thought, content } = splitThinking(finalAssistantMessage.content);
|
|
868
863
|
if (thought && SHOW_THOUGHTS) {
|
|
869
|
-
ui.
|
|
864
|
+
ui.showThought(thought);
|
|
870
865
|
}
|
|
871
866
|
finalAssistantMessage.content = content;
|
|
872
867
|
}
|
|
@@ -1008,7 +1003,7 @@ async function processQuery(query, conversation = [], currentModel) {
|
|
|
1008
1003
|
if (assistantMessage && typeof assistantMessage.content === 'string') {
|
|
1009
1004
|
const { thought, content } = splitThinking(assistantMessage.content);
|
|
1010
1005
|
if (thought && SHOW_THOUGHTS) {
|
|
1011
|
-
ui.
|
|
1006
|
+
ui.showThought(thought);
|
|
1012
1007
|
}
|
|
1013
1008
|
assistantMessage.content = content;
|
|
1014
1009
|
}
|
|
@@ -1068,7 +1063,7 @@ async function processQuery(query, conversation = [], currentModel) {
|
|
|
1068
1063
|
if (finalAssistantMessage && typeof finalAssistantMessage.content === 'string') {
|
|
1069
1064
|
const { thought, content } = splitThinking(finalAssistantMessage.content);
|
|
1070
1065
|
if (thought && SHOW_THOUGHTS) {
|
|
1071
|
-
ui.
|
|
1066
|
+
ui.showThought(thought);
|
|
1072
1067
|
}
|
|
1073
1068
|
finalResponse = content;
|
|
1074
1069
|
} else {
|
package/bin/ui.js
CHANGED
|
@@ -72,6 +72,25 @@ function showAGIStatus(status) {
|
|
|
72
72
|
console.log(chalk.cyanBright(statusBox));
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
function showThought(thought) {
|
|
76
|
+
if (!thought) return;
|
|
77
|
+
const top = chalk.gray('┌' + '─'.repeat(30) + '┐');
|
|
78
|
+
const title = chalk.magenta.bold('│ ✧ Thinking');
|
|
79
|
+
const pad = ' '.repeat(Math.max(0, 30 - ' ✧ Thinking'.length));
|
|
80
|
+
const titleLine = title + pad + chalk.gray(' │');
|
|
81
|
+
const separator = chalk.gray('├' + '─'.repeat(30) + '┤');
|
|
82
|
+
const bottom = chalk.gray('└' + '─'.repeat(30) + '┘');
|
|
83
|
+
console.log(top);
|
|
84
|
+
console.log(titleLine);
|
|
85
|
+
console.log(separator);
|
|
86
|
+
// Print each line of thought dimmed
|
|
87
|
+
String(thought).split('\n').forEach(line => {
|
|
88
|
+
const truncated = line; // keep full line; rely on terminal wrap
|
|
89
|
+
console.log(chalk.gray('│ ') + chalk.dim(truncated) + chalk.gray(' │'));
|
|
90
|
+
});
|
|
91
|
+
console.log(bottom);
|
|
92
|
+
}
|
|
93
|
+
|
|
75
94
|
module.exports = {
|
|
76
95
|
showHeader,
|
|
77
96
|
showLegacyHeader,
|
|
@@ -84,5 +103,6 @@ module.exports = {
|
|
|
84
103
|
showWarning,
|
|
85
104
|
showSuccess,
|
|
86
105
|
showInfo,
|
|
87
|
-
showAGIStatus
|
|
106
|
+
showAGIStatus,
|
|
107
|
+
showThought
|
|
88
108
|
};
|