gaunt-sloth-assistant 0.0.8 → 0.1.0
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/.eslint.config.mjs +0 -0
- package/.github/dependabot.yml +0 -0
- package/.gsloth.preamble.internal.md +0 -0
- package/.gsloth.preamble.review.md +0 -0
- package/DEVELOPMENT.md +9 -0
- package/LICENSE +0 -0
- package/README.md +57 -14
- package/RELEASE-HOWTO.md +8 -0
- package/ROADMAP.md +2 -2
- package/UX-RESEARCH.md +78 -0
- package/index.js +12 -74
- package/package.json +9 -8
- package/spec/.gsloth.config.js +22 -0
- package/spec/askCommand.spec.js +58 -0
- package/spec/initCommand.spec.js +54 -0
- package/spec/questionAnsweringModule.spec.js +137 -0
- package/spec/reviewCommand.spec.js +144 -0
- package/spec/{codeReview.spec.js → reviewModule.spec.js} +2 -2
- package/spec/support/jasmine.mjs +0 -0
- package/src/commands/askCommand.js +26 -0
- package/src/commands/initCommand.js +16 -0
- package/src/commands/reviewCommand.js +147 -0
- package/src/config.js +1 -1
- package/src/configs/anthropic.js +0 -0
- package/src/configs/groq.js +0 -0
- package/src/configs/vertexai.js +0 -0
- package/src/consoleUtils.js +2 -0
- package/src/{questionAnswering.js → modules/questionAnsweringModule.js} +87 -68
- package/src/{codeReview.js → modules/reviewModule.js} +4 -6
- package/src/prompt.js +0 -0
- package/src/providers/ghPrDiffProvider.js +11 -0
- package/src/providers/jiraIssueLegacyAccessTokenProvider.js +81 -0
- package/src/providers/text.js +6 -0
- package/src/utils.js +35 -20
- package/testMessage.txt +0 -0
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
process.
|
67
|
-
|
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
|
-
|
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
|