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.
Files changed (145) hide show
  1. package/{.gsloth.preamble.review.md → .gsloth.guidelines.md} +0 -8
  2. package/.gsloth.review.md +7 -0
  3. package/.prettierrc.json +9 -0
  4. package/README.md +177 -158
  5. package/ROADMAP.md +1 -1
  6. package/dist/commands/askCommand.d.ts +6 -0
  7. package/dist/commands/askCommand.js +27 -0
  8. package/dist/commands/askCommand.js.map +1 -0
  9. package/dist/commands/initCommand.d.ts +6 -0
  10. package/dist/commands/initCommand.js +16 -0
  11. package/dist/commands/initCommand.js.map +1 -0
  12. package/dist/commands/reviewCommand.d.ts +3 -0
  13. package/dist/commands/reviewCommand.js +142 -0
  14. package/dist/commands/reviewCommand.js.map +1 -0
  15. package/dist/config.d.ts +84 -0
  16. package/dist/config.js +180 -0
  17. package/dist/config.js.map +1 -0
  18. package/dist/configs/anthropic.d.ts +4 -0
  19. package/{src → dist}/configs/anthropic.js +45 -48
  20. package/dist/configs/anthropic.js.map +1 -0
  21. package/dist/configs/fake.d.ts +3 -0
  22. package/{src → dist}/configs/fake.js +11 -14
  23. package/dist/configs/fake.js.map +1 -0
  24. package/dist/configs/groq.d.ts +4 -0
  25. package/{src → dist}/configs/groq.js +10 -13
  26. package/dist/configs/groq.js.map +1 -0
  27. package/dist/configs/types.d.ts +14 -0
  28. package/dist/configs/types.js +2 -0
  29. package/dist/configs/types.js.map +1 -0
  30. package/dist/configs/vertexai.d.ts +4 -0
  31. package/{src → dist}/configs/vertexai.js +44 -47
  32. package/dist/configs/vertexai.js.map +1 -0
  33. package/dist/consoleUtils.d.ts +6 -0
  34. package/{src → dist}/consoleUtils.js +10 -15
  35. package/dist/consoleUtils.js.map +1 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +26 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/llmUtils.d.ts +4 -0
  40. package/dist/llmUtils.js +39 -0
  41. package/dist/llmUtils.js.map +1 -0
  42. package/dist/modules/questionAnsweringModule.d.ts +7 -0
  43. package/dist/modules/questionAnsweringModule.js +33 -0
  44. package/dist/modules/questionAnsweringModule.js.map +1 -0
  45. package/dist/modules/reviewModule.d.ts +1 -0
  46. package/dist/modules/reviewModule.js +29 -0
  47. package/dist/modules/reviewModule.js.map +1 -0
  48. package/dist/modules/types.d.ts +18 -0
  49. package/dist/modules/types.js +2 -0
  50. package/dist/modules/types.js.map +1 -0
  51. package/dist/prompt.d.ts +8 -0
  52. package/dist/prompt.js +45 -0
  53. package/dist/prompt.js.map +1 -0
  54. package/dist/providers/file.d.ts +8 -0
  55. package/dist/providers/file.js +20 -0
  56. package/dist/providers/file.js.map +1 -0
  57. package/dist/providers/ghPrDiffProvider.d.ts +8 -0
  58. package/dist/providers/ghPrDiffProvider.js +16 -0
  59. package/dist/providers/ghPrDiffProvider.js.map +1 -0
  60. package/dist/providers/jiraIssueLegacyAccessTokenProvider.d.ts +8 -0
  61. package/dist/providers/jiraIssueLegacyAccessTokenProvider.js +62 -0
  62. package/dist/providers/jiraIssueLegacyAccessTokenProvider.js.map +1 -0
  63. package/dist/providers/jiraIssueLegacyProvider.d.ts +8 -0
  64. package/dist/providers/jiraIssueLegacyProvider.js +74 -0
  65. package/dist/providers/jiraIssueLegacyProvider.js.map +1 -0
  66. package/dist/providers/jiraIssueProvider.d.ts +11 -0
  67. package/dist/providers/jiraIssueProvider.js +96 -0
  68. package/dist/providers/jiraIssueProvider.js.map +1 -0
  69. package/dist/providers/text.d.ts +8 -0
  70. package/dist/providers/text.js +10 -0
  71. package/dist/providers/text.js.map +1 -0
  72. package/dist/providers/types.d.ts +21 -0
  73. package/dist/providers/types.js +2 -0
  74. package/dist/providers/types.js.map +1 -0
  75. package/dist/systemUtils.d.ts +32 -0
  76. package/dist/systemUtils.js +70 -0
  77. package/dist/systemUtils.js.map +1 -0
  78. package/dist/utils.d.ts +49 -0
  79. package/dist/utils.js +192 -0
  80. package/dist/utils.js.map +1 -0
  81. package/docs/CONFIGURATION.md +99 -10
  82. package/docs/RELEASE-HOWTO.md +7 -1
  83. package/eslint.config.js +99 -21
  84. package/gth-ASK-2025-05-16T14-11-39.md +3 -0
  85. package/gth-ASK-2025-05-16T14-18-27.md +3 -0
  86. package/gth-ASK-2025-05-16T14-18-56.md +1 -0
  87. package/gth-ASK-2025-05-16T14-41-20.md +3 -0
  88. package/gth-ASK-2025-05-16T14-43-31.md +51 -0
  89. package/gth-ASK-2025-05-16T16-05-52.md +62 -0
  90. package/gth-DIFF-review-2025-05-16T16-07-53.md +56 -0
  91. package/gth-DIFF-review-2025-05-16T16-18-55.md +292 -0
  92. package/index.js +10 -27
  93. package/package.json +26 -15
  94. package/src/commands/askCommand.ts +35 -0
  95. package/src/commands/initCommand.ts +19 -0
  96. package/src/commands/reviewCommand.ts +223 -0
  97. package/src/config.ts +269 -0
  98. package/src/configs/anthropic.ts +57 -0
  99. package/src/configs/fake.ts +15 -0
  100. package/src/configs/groq.ts +54 -0
  101. package/src/configs/vertexai.ts +53 -0
  102. package/src/consoleUtils.ts +33 -0
  103. package/src/index.ts +30 -0
  104. package/src/llmUtils.ts +54 -0
  105. package/src/modules/questionAnsweringModule.ts +44 -0
  106. package/src/modules/reviewModule.ts +31 -0
  107. package/src/modules/types.ts +23 -0
  108. package/src/prompt.ts +54 -0
  109. package/src/providers/file.ts +24 -0
  110. package/src/providers/ghPrDiffProvider.ts +20 -0
  111. package/src/providers/jiraIssueLegacyProvider.ts +103 -0
  112. package/src/providers/jiraIssueProvider.ts +133 -0
  113. package/src/providers/text.ts +14 -0
  114. package/src/providers/types.ts +24 -0
  115. package/src/systemUtils.ts +90 -0
  116. package/src/utils.ts +232 -0
  117. package/tsconfig.json +24 -0
  118. package/vitest.config.ts +13 -0
  119. package/.eslint.config.mjs +0 -72
  120. package/.github/dependabot.yml +0 -11
  121. package/.github/workflows/ci.yml +0 -33
  122. package/spec/.gsloth.config.js +0 -22
  123. package/spec/.gsloth.config.json +0 -25
  124. package/spec/askCommand.spec.js +0 -92
  125. package/spec/config.spec.js +0 -421
  126. package/spec/initCommand.spec.js +0 -55
  127. package/spec/predefinedConfigs.spec.js +0 -100
  128. package/spec/questionAnsweringModule.spec.js +0 -137
  129. package/spec/reviewCommand.spec.js +0 -222
  130. package/spec/reviewModule.spec.js +0 -28
  131. package/spec/support/jasmine.mjs +0 -14
  132. package/src/commands/askCommand.js +0 -27
  133. package/src/commands/initCommand.js +0 -17
  134. package/src/commands/reviewCommand.js +0 -154
  135. package/src/config.js +0 -177
  136. package/src/modules/questionAnsweringModule.js +0 -82
  137. package/src/modules/reviewModule.js +0 -70
  138. package/src/prompt.js +0 -34
  139. package/src/providers/file.js +0 -19
  140. package/src/providers/ghPrDiffProvider.js +0 -11
  141. package/src/providers/jiraIssueLegacyAccessTokenProvider.js +0 -84
  142. package/src/providers/text.js +0 -6
  143. package/src/systemUtils.js +0 -32
  144. package/src/utils.js +0 -173
  145. /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
- }