gaunt-sloth-assistant 0.1.5 → 0.3.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/{.gsloth.preamble.review.md → .gsloth.guidelines.md} +0 -8
- package/.gsloth.review.md +7 -0
- package/.prettierrc.json +9 -0
- package/README.md +177 -158
- package/ROADMAP.md +1 -1
- package/dist/commands/askCommand.d.ts +6 -0
- package/dist/commands/askCommand.js +27 -0
- package/dist/commands/askCommand.js.map +1 -0
- package/dist/commands/initCommand.d.ts +6 -0
- package/dist/commands/initCommand.js +16 -0
- package/dist/commands/initCommand.js.map +1 -0
- package/dist/commands/reviewCommand.d.ts +3 -0
- package/dist/commands/reviewCommand.js +142 -0
- package/dist/commands/reviewCommand.js.map +1 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +180 -0
- package/dist/config.js.map +1 -0
- package/dist/configs/anthropic.d.ts +4 -0
- package/{src → dist}/configs/anthropic.js +45 -48
- package/dist/configs/anthropic.js.map +1 -0
- package/dist/configs/fake.d.ts +3 -0
- package/{src → dist}/configs/fake.js +11 -14
- package/dist/configs/fake.js.map +1 -0
- package/dist/configs/groq.d.ts +4 -0
- package/{src → dist}/configs/groq.js +10 -13
- package/dist/configs/groq.js.map +1 -0
- package/dist/configs/types.d.ts +14 -0
- package/dist/configs/types.js +2 -0
- package/dist/configs/types.js.map +1 -0
- package/dist/configs/vertexai.d.ts +4 -0
- package/{src → dist}/configs/vertexai.js +44 -47
- package/dist/configs/vertexai.js.map +1 -0
- package/dist/consoleUtils.d.ts +6 -0
- package/{src → dist}/consoleUtils.js +10 -15
- package/dist/consoleUtils.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/llmUtils.d.ts +4 -0
- package/dist/llmUtils.js +39 -0
- package/dist/llmUtils.js.map +1 -0
- package/dist/modules/questionAnsweringModule.d.ts +7 -0
- package/dist/modules/questionAnsweringModule.js +33 -0
- package/dist/modules/questionAnsweringModule.js.map +1 -0
- package/dist/modules/reviewModule.d.ts +1 -0
- package/dist/modules/reviewModule.js +29 -0
- package/dist/modules/reviewModule.js.map +1 -0
- package/dist/modules/types.d.ts +18 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/prompt.d.ts +8 -0
- package/dist/prompt.js +45 -0
- package/dist/prompt.js.map +1 -0
- package/dist/providers/file.d.ts +8 -0
- package/dist/providers/file.js +20 -0
- package/dist/providers/file.js.map +1 -0
- package/dist/providers/ghPrDiffProvider.d.ts +8 -0
- package/dist/providers/ghPrDiffProvider.js +16 -0
- package/dist/providers/ghPrDiffProvider.js.map +1 -0
- package/dist/providers/jiraIssueLegacyAccessTokenProvider.d.ts +8 -0
- package/dist/providers/jiraIssueLegacyAccessTokenProvider.js +62 -0
- package/dist/providers/jiraIssueLegacyAccessTokenProvider.js.map +1 -0
- package/dist/providers/jiraIssueLegacyProvider.d.ts +8 -0
- package/dist/providers/jiraIssueLegacyProvider.js +74 -0
- package/dist/providers/jiraIssueLegacyProvider.js.map +1 -0
- package/dist/providers/jiraIssueProvider.d.ts +11 -0
- package/dist/providers/jiraIssueProvider.js +96 -0
- package/dist/providers/jiraIssueProvider.js.map +1 -0
- package/dist/providers/text.d.ts +8 -0
- package/dist/providers/text.js +10 -0
- package/dist/providers/text.js.map +1 -0
- package/dist/providers/types.d.ts +21 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/systemUtils.d.ts +32 -0
- package/dist/systemUtils.js +70 -0
- package/dist/systemUtils.js.map +1 -0
- package/dist/utils.d.ts +49 -0
- package/dist/utils.js +192 -0
- package/dist/utils.js.map +1 -0
- package/docs/CONFIGURATION.md +99 -10
- package/docs/RELEASE-HOWTO.md +7 -1
- package/eslint.config.js +99 -21
- package/gth-ASK-2025-05-16T14-11-39.md +3 -0
- package/gth-ASK-2025-05-16T14-18-27.md +3 -0
- package/gth-ASK-2025-05-16T14-18-56.md +1 -0
- package/gth-ASK-2025-05-16T14-41-20.md +3 -0
- package/gth-ASK-2025-05-16T14-43-31.md +51 -0
- package/gth-ASK-2025-05-16T16-05-52.md +62 -0
- package/gth-DIFF-review-2025-05-16T16-07-53.md +56 -0
- package/gth-DIFF-review-2025-05-16T16-18-55.md +292 -0
- package/index.js +10 -27
- package/package.json +26 -15
- package/src/commands/askCommand.ts +35 -0
- package/src/commands/initCommand.ts +19 -0
- package/src/commands/reviewCommand.ts +223 -0
- package/src/config.ts +269 -0
- package/src/configs/anthropic.ts +57 -0
- package/src/configs/fake.ts +15 -0
- package/src/configs/groq.ts +54 -0
- package/src/configs/vertexai.ts +53 -0
- package/src/consoleUtils.ts +33 -0
- package/src/index.ts +30 -0
- package/src/llmUtils.ts +54 -0
- package/src/modules/questionAnsweringModule.ts +44 -0
- package/src/modules/reviewModule.ts +31 -0
- package/src/modules/types.ts +23 -0
- package/src/prompt.ts +54 -0
- package/src/providers/file.ts +24 -0
- package/src/providers/ghPrDiffProvider.ts +20 -0
- package/src/providers/jiraIssueLegacyProvider.ts +103 -0
- package/src/providers/jiraIssueProvider.ts +133 -0
- package/src/providers/text.ts +14 -0
- package/src/providers/types.ts +24 -0
- package/src/systemUtils.ts +90 -0
- package/src/utils.ts +232 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +13 -0
- package/.eslint.config.mjs +0 -72
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/ci.yml +0 -33
- package/spec/.gsloth.config.js +0 -22
- package/spec/.gsloth.config.json +0 -25
- package/spec/askCommand.spec.js +0 -92
- package/spec/config.spec.js +0 -421
- package/spec/initCommand.spec.js +0 -55
- package/spec/predefinedConfigs.spec.js +0 -100
- package/spec/questionAnsweringModule.spec.js +0 -137
- package/spec/reviewCommand.spec.js +0 -222
- package/spec/reviewModule.spec.js +0 -28
- package/spec/support/jasmine.mjs +0 -14
- package/src/commands/askCommand.js +0 -27
- package/src/commands/initCommand.js +0 -17
- package/src/commands/reviewCommand.js +0 -154
- package/src/config.js +0 -177
- package/src/modules/questionAnsweringModule.js +0 -82
- package/src/modules/reviewModule.js +0 -70
- package/src/prompt.js +0 -34
- package/src/providers/file.js +0 -19
- package/src/providers/ghPrDiffProvider.js +0 -11
- package/src/providers/jiraIssueLegacyAccessTokenProvider.js +0 -84
- package/src/providers/text.js +0 -6
- package/src/systemUtils.js +0 -32
- package/src/utils.js +0 -173
- /package/{.gsloth.preamble.internal.md → .gsloth.backstory.md} +0 -0
package/src/utils.js
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
import {display, displayError, displaySuccess, displayWarning} from "./consoleUtils.js";
|
2
|
-
import {existsSync, readFileSync, writeFileSync} from "node:fs";
|
3
|
-
import {slothContext} from "./config.js";
|
4
|
-
import {resolve} from "node:path";
|
5
|
-
import {spawn} from "node:child_process";
|
6
|
-
import {exit, stdin, stdout, argv} from "./systemUtils.js";
|
7
|
-
import url from "node:url";
|
8
|
-
|
9
|
-
export function toFileSafeString(string) {
|
10
|
-
return string.replace(/[^A-Za-z0-9]/g, '-');
|
11
|
-
}
|
12
|
-
|
13
|
-
export function fileSafeLocalDate() {
|
14
|
-
const date = new Date();
|
15
|
-
const offsetMs = date.getTimezoneOffset() * 60 * 1000;
|
16
|
-
const msLocal = date.getTime() - offsetMs;
|
17
|
-
const dateLocal = new Date(msLocal);
|
18
|
-
const iso = dateLocal.toISOString();
|
19
|
-
const isoLocal = iso.slice(0, 19);
|
20
|
-
return toFileSafeString(isoLocal);
|
21
|
-
}
|
22
|
-
|
23
|
-
export function readFileFromCurrentDir(fileName) {
|
24
|
-
const filePath = resolve(slothContext.currentDir, fileName);
|
25
|
-
display(`Reading file ${fileName}...`);
|
26
|
-
return readFileSyncWithMessages(filePath);
|
27
|
-
}
|
28
|
-
|
29
|
-
export function writeFileIfNotExistsWithMessages(filePath, content) {
|
30
|
-
display(`checking ${filePath} existence`);
|
31
|
-
if (!existsSync(filePath)) {
|
32
|
-
writeFileSync(filePath, content);
|
33
|
-
displaySuccess(`Created ${filePath}`);
|
34
|
-
} else {
|
35
|
-
displayWarning(`${filePath} already exists`);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
export function readFileSyncWithMessages(filePath, errorMessageIn, noFileMessage) {
|
40
|
-
const errorMessage = errorMessageIn ?? 'Error reading file at: ';
|
41
|
-
try {
|
42
|
-
return readFileSync(filePath, { encoding: 'utf8' });
|
43
|
-
} catch (error) {
|
44
|
-
displayError(errorMessage + filePath);
|
45
|
-
if (error.code === 'ENOENT') {
|
46
|
-
displayWarning(noFileMessage ?? 'Please ensure the file exists.');
|
47
|
-
} else {
|
48
|
-
displayError(error.message);
|
49
|
-
}
|
50
|
-
exit(1); // Exit gracefully after error
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
export function readStdin(program) {
|
55
|
-
return new Promise((resolve) => {
|
56
|
-
// TODO use progress indicator here
|
57
|
-
if(stdin.isTTY) {
|
58
|
-
program.parseAsync().then(resolve);
|
59
|
-
} else {
|
60
|
-
// Support piping diff into gsloth
|
61
|
-
stdout.write('reading STDIN.');
|
62
|
-
stdin.on('readable', function() {
|
63
|
-
const chunk = this.read();
|
64
|
-
stdout.write('.');
|
65
|
-
if (chunk !== null) {
|
66
|
-
slothContext.stdin += chunk;
|
67
|
-
}
|
68
|
-
});
|
69
|
-
stdin.on('end', function() {
|
70
|
-
stdout.write('.\n');
|
71
|
-
program.parseAsync(argv).then(resolve);
|
72
|
-
});
|
73
|
-
}
|
74
|
-
});
|
75
|
-
}
|
76
|
-
|
77
|
-
export async function spawnCommand(command, args, progressMessage, successMessage) {
|
78
|
-
return new Promise((resolve, reject) => {
|
79
|
-
// TODO use progress indicator
|
80
|
-
const out = {stdout: '', stderr: ''};
|
81
|
-
const spawned = spawn(command, args);
|
82
|
-
spawned.stdout.on('data', async (stdoutChunk) => {
|
83
|
-
display(progressMessage);
|
84
|
-
out.stdout += stdoutChunk.toString();
|
85
|
-
});
|
86
|
-
spawned.stderr.on('data', (err) => {
|
87
|
-
display(progressMessage);
|
88
|
-
out.stderr += err.toString();
|
89
|
-
});
|
90
|
-
spawned.on('error', (err) => {
|
91
|
-
reject(err.toString());
|
92
|
-
});
|
93
|
-
spawned.on('close', (code) => {
|
94
|
-
if (code === 0) {
|
95
|
-
display(successMessage);
|
96
|
-
resolve(out.stdout);
|
97
|
-
} else {
|
98
|
-
displayError(`Failed to spawn command with code ${code}`);
|
99
|
-
reject(out.stdout + ' ' + out.stderr);
|
100
|
-
}
|
101
|
-
});
|
102
|
-
});
|
103
|
-
}
|
104
|
-
|
105
|
-
export function getSlothVersion() {
|
106
|
-
const jsonPath = resolve(slothContext.installDir, 'package.json');
|
107
|
-
const projectJson = readFileSync(jsonPath, { encoding: 'utf8' });
|
108
|
-
return JSON.parse(projectJson).version;
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
export class ProgressIndicator {
|
113
|
-
|
114
|
-
constructor(initialMessage) {
|
115
|
-
this.hasBeenCalled = false;
|
116
|
-
this.initialMessage = initialMessage;
|
117
|
-
}
|
118
|
-
|
119
|
-
indicate() {
|
120
|
-
if (this.hasBeenCalled) {
|
121
|
-
stdout.write('.');
|
122
|
-
} else {
|
123
|
-
this.hasBeenCalled = true;
|
124
|
-
stdout.write(this.initialMessage);
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
}
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Extracts the content of the last message from an LLM response
|
132
|
-
* @param {Object} output - The output from the LLM containing messages
|
133
|
-
* @returns {string} The content of the last message
|
134
|
-
*/
|
135
|
-
export function extractLastMessageContent(output) {
|
136
|
-
if (!output || !output.messages || !output.messages.length) {
|
137
|
-
return '';
|
138
|
-
}
|
139
|
-
return output.messages[output.messages.length - 1].content;
|
140
|
-
}
|
141
|
-
|
142
|
-
/**
|
143
|
-
* Dynamically imports a module from a file path from the outside of the installation dir
|
144
|
-
* @param {string} filePath - The path to the file to import
|
145
|
-
* @returns {Promise} A promise that resolves to the imported module
|
146
|
-
*/
|
147
|
-
export function importExternalFile(filePath) {
|
148
|
-
const configFileUrl = url.pathToFileURL(filePath);
|
149
|
-
return import(configFileUrl);
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* Alias for importExternalFile for backward compatibility with tests
|
154
|
-
* @param {string} filePath - The path to the file to import
|
155
|
-
* @returns {Promise} A promise that resolves to the imported module
|
156
|
-
*/
|
157
|
-
export const importFromFilePath = importExternalFile;
|
158
|
-
|
159
|
-
/**
|
160
|
-
* Reads multiple files from the current directory and returns their contents
|
161
|
-
* @param {string[]} fileNames - Array of file names to read
|
162
|
-
* @returns {string} Combined content of all files with proper formatting
|
163
|
-
*/
|
164
|
-
export function readMultipleFilesFromCurrentDir(fileNames) {
|
165
|
-
if (!Array.isArray(fileNames)) {
|
166
|
-
return readFileFromCurrentDir(fileNames);
|
167
|
-
}
|
168
|
-
|
169
|
-
return fileNames.map(fileName => {
|
170
|
-
const content = readFileFromCurrentDir(fileName);
|
171
|
-
return `${fileName}:\n\`\`\`\n${content}\n\`\`\``;
|
172
|
-
}).join('\n\n');
|
173
|
-
}
|
File without changes
|