gaunt-sloth-assistant 0.0.8 → 0.1.1

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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Simple provider returning text as it is.
3
+ */
4
+ export async function get(_, text) {
5
+ return text;
6
+ }
package/src/utils.js CHANGED
@@ -50,27 +50,30 @@ export function readFileSyncWithMessages(filePath, errorMessageIn, noFileMessage
50
50
  }
51
51
 
52
52
  export function readStdin(program) {
53
- if(process.stdin.isTTY) {
54
- program.parse();
55
- } else {
56
- // Support piping diff into gsloth
57
- process.stdout.write('reading STDIN.');
58
- process.stdin.on('readable', function() {
59
- const chunk = this.read();
60
- process.stdout.write('.');
61
- if (chunk !== null) {
62
- slothContext.stdin += chunk;
63
- }
64
- });
65
- process.stdin.on('end', function() {
66
- process.stdout.write('.\n');
67
- program.parse(process.argv);
68
- });
69
- }
53
+ return new Promise((resolve) => {
54
+ if(process.stdin.isTTY) {
55
+ program.parseAsync().then(resolve);
56
+ } else {
57
+ // Support piping diff into gsloth
58
+ process.stdout.write('reading STDIN.');
59
+ process.stdin.on('readable', function() {
60
+ const chunk = this.read();
61
+ process.stdout.write('.');
62
+ if (chunk !== null) {
63
+ slothContext.stdin += chunk;
64
+ }
65
+ });
66
+ process.stdin.on('end', function() {
67
+ process.stdout.write('.\n');
68
+ program.parseAsync(process.argv).then(resolve);
69
+ });
70
+ }
71
+ });
70
72
  }
71
73
 
72
74
  export async function spawnCommand(command, args, progressMessage, successMessage) {
73
75
  return new Promise((resolve, reject) => {
76
+ // TODO use progress indicator
74
77
  const out = {stdout: '', stderr: ''};
75
78
  const spawned = spawn(command, args);
76
79
  spawned.stdout.on('data', async (stdoutChunk, dd) => {
@@ -78,7 +81,7 @@ export async function spawnCommand(command, args, progressMessage, successMessag
78
81
  out.stdout += stdoutChunk.toString();
79
82
  });
80
83
  spawned.stderr.on('data', (err) => {
81
- displayError(progressMessage);
84
+ display(progressMessage);
82
85
  out.stderr += err.toString();
83
86
  })
84
87
  spawned.on('error', (err) => {
@@ -109,7 +112,7 @@ export class ProgressIndicator {
109
112
  this.hasBeenCalled = false;
110
113
  this.initialMessage = initialMessage;
111
114
  }
112
-
115
+
113
116
  indicate() {
114
117
  if (this.hasBeenCalled) {
115
118
  process.stdout.write('.');
@@ -119,4 +122,16 @@ export class ProgressIndicator {
119
122
  }
120
123
  }
121
124
 
122
- }
125
+ }
126
+
127
+ /**
128
+ * Extracts the content of the last message from an LLM response
129
+ * @param {Object} output - The output from the LLM containing messages
130
+ * @returns {string} The content of the last message
131
+ */
132
+ export function extractLastMessageContent(output) {
133
+ if (!output || !output.messages || !output.messages.length) {
134
+ return '';
135
+ }
136
+ return output.messages[output.messages.length - 1].content;
137
+ }
package/testMessage.txt CHANGED
File without changes