gaunt-sloth-assistant 0.5.0 → 0.5.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.
- package/.claude/settings.local.json +15 -0
- package/.gsloth.backstory.md +0 -0
- package/.gsloth.guidelines.md +0 -0
- package/.gsloth.review.md +0 -0
- package/.gsloth.system.md +10 -0
- package/.prettierrc.json +0 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +0 -0
- package/README.md +9 -0
- package/ROADMAP.md +0 -0
- package/assets/gaunt-sloth-logo.png +0 -0
- package/assets/release-notes/v0_4_0.md +0 -0
- package/assets/release-notes/v0_5_0.md +0 -0
- package/assets/release-notes/v0_5_1.md +47 -0
- package/dist/commands/askCommand.d.ts +0 -0
- package/dist/commands/askCommand.js +9 -5
- package/dist/commands/askCommand.js.map +1 -1
- package/dist/commands/commandUtils.d.ts +25 -0
- package/dist/commands/commandUtils.js +48 -0
- package/dist/commands/commandUtils.js.map +1 -0
- package/dist/commands/initCommand.d.ts +0 -0
- package/dist/commands/initCommand.js +0 -0
- package/dist/commands/initCommand.js.map +0 -0
- package/dist/commands/prCommand.d.ts +2 -0
- package/dist/commands/prCommand.js +52 -0
- package/dist/commands/prCommand.js.map +1 -0
- package/dist/commands/reviewCommand.d.ts +1 -2
- package/dist/commands/reviewCommand.js +17 -98
- package/dist/commands/reviewCommand.js.map +1 -1
- package/dist/config.d.ts +18 -36
- package/dist/config.js +104 -84
- package/dist/config.js.map +1 -1
- package/dist/configs/anthropic.d.ts +0 -0
- package/dist/configs/anthropic.js +0 -0
- package/dist/configs/anthropic.js.map +0 -0
- package/dist/configs/fake.d.ts +0 -0
- package/dist/configs/fake.js +0 -0
- package/dist/configs/fake.js.map +0 -0
- package/dist/configs/groq.d.ts +0 -0
- package/dist/configs/groq.js +0 -0
- package/dist/configs/groq.js.map +0 -0
- package/dist/configs/vertexai.d.ts +0 -0
- package/dist/configs/vertexai.js +0 -0
- package/dist/configs/vertexai.js.map +0 -0
- package/dist/consoleUtils.d.ts +0 -0
- package/dist/consoleUtils.js +0 -0
- package/dist/consoleUtils.js.map +0 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/filePathUtils.d.ts +0 -0
- package/dist/filePathUtils.js +0 -0
- package/dist/filePathUtils.js.map +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/llmUtils.d.ts +1 -1
- package/dist/llmUtils.js +85 -22
- package/dist/llmUtils.js.map +1 -1
- package/dist/modules/questionAnsweringModule.d.ts +2 -1
- package/dist/modules/questionAnsweringModule.js +4 -7
- package/dist/modules/questionAnsweringModule.js.map +1 -1
- package/dist/modules/reviewModule.d.ts +2 -1
- package/dist/modules/reviewModule.js +4 -7
- package/dist/modules/reviewModule.js.map +1 -1
- package/dist/modules/types.d.ts +0 -0
- package/dist/modules/types.js +0 -0
- package/dist/modules/types.js.map +0 -0
- package/dist/prompt.d.ts +1 -0
- package/dist/prompt.js +4 -1
- package/dist/prompt.js.map +1 -1
- package/dist/providers/file.d.ts +0 -0
- package/dist/providers/file.js +0 -0
- package/dist/providers/file.js.map +0 -0
- package/dist/providers/ghIssueProvider.d.ts +0 -0
- package/dist/providers/ghIssueProvider.js +3 -1
- package/dist/providers/ghIssueProvider.js.map +1 -1
- package/dist/providers/ghPrDiffProvider.d.ts +0 -0
- package/dist/providers/ghPrDiffProvider.js +3 -1
- package/dist/providers/ghPrDiffProvider.js.map +1 -1
- package/dist/providers/jiraIssueLegacyProvider.d.ts +0 -0
- package/dist/providers/jiraIssueLegacyProvider.js +0 -0
- package/dist/providers/jiraIssueLegacyProvider.js.map +0 -0
- package/dist/providers/jiraIssueProvider.d.ts +0 -0
- package/dist/providers/jiraIssueProvider.js +0 -0
- package/dist/providers/jiraIssueProvider.js.map +0 -0
- package/dist/providers/text.d.ts +0 -0
- package/dist/providers/text.js +0 -0
- package/dist/providers/text.js.map +0 -0
- package/dist/providers/types.d.ts +0 -0
- package/dist/providers/types.js +0 -0
- package/dist/providers/types.js.map +0 -0
- package/dist/systemUtils.d.ts +0 -0
- package/dist/systemUtils.js +0 -0
- package/dist/systemUtils.js.map +0 -0
- package/dist/utils.d.ts +0 -0
- package/dist/utils.js +0 -0
- package/dist/utils.js.map +0 -0
- package/docs/CONFIGURATION.md +0 -0
- package/docs/DEVELOPMENT.md +0 -0
- package/docs/RELEASE-HOWTO.md +0 -0
- package/eslint.config.js +0 -0
- package/maintenance/doc-maintenance.md +0 -0
- package/package.json +10 -8
- package/src/commands/askCommand.ts +9 -5
- package/src/commands/commandUtils.ts +77 -0
- package/src/commands/initCommand.ts +0 -0
- package/src/commands/prCommand.ts +93 -0
- package/src/commands/reviewCommand.ts +33 -155
- package/src/config.ts +121 -119
- package/src/configs/anthropic.ts +0 -0
- package/src/configs/fake.ts +0 -0
- package/src/configs/groq.ts +0 -0
- package/src/configs/vertexai.ts +0 -0
- package/src/consoleUtils.ts +0 -0
- package/src/constants.ts +7 -0
- package/src/filePathUtils.ts +0 -0
- package/src/index.ts +4 -2
- package/src/llmUtils.ts +100 -23
- package/src/modules/questionAnsweringModule.ts +6 -12
- package/src/modules/reviewModule.ts +11 -7
- package/src/modules/types.ts +0 -0
- package/src/prompt.ts +5 -1
- package/src/providers/file.ts +0 -0
- package/src/providers/ghIssueProvider.ts +3 -1
- package/src/providers/ghPrDiffProvider.ts +3 -1
- package/src/providers/jiraIssueLegacyProvider.ts +0 -0
- package/src/providers/jiraIssueProvider.ts +0 -0
- package/src/providers/text.ts +0 -0
- package/src/providers/types.ts +0 -0
- package/src/systemUtils.ts +0 -0
- package/src/utils.ts +0 -0
- package/tsconfig.json +0 -0
- package/vitest-it.config.ts +0 -0
- package/vitest.config.ts +0 -0
package/dist/config.js
CHANGED
@@ -3,12 +3,7 @@ import { importExternalFile, writeFileIfNotExistsWithMessages } from '#src/utils
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
4
4
|
import { error, exit } from '#src/systemUtils.js';
|
5
5
|
import { getGslothConfigReadPath, getGslothConfigWritePath } from '#src/filePathUtils.js';
|
6
|
-
|
7
|
-
export const USER_PROJECT_CONFIG_JSON = '.gsloth.config.json';
|
8
|
-
export const USER_PROJECT_CONFIG_MJS = '.gsloth.config.mjs';
|
9
|
-
export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
|
10
|
-
export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
|
11
|
-
export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
|
6
|
+
import { USER_PROJECT_CONFIG_JS, USER_PROJECT_CONFIG_JSON, USER_PROJECT_CONFIG_MJS, PROJECT_GUIDELINES, PROJECT_REVIEW_INSTRUCTIONS, } from '#src/constants.js';
|
12
7
|
export const availableDefaultConfigs = ['vertexai', 'anthropic', 'groq'];
|
13
8
|
export const DEFAULT_CONFIG = {
|
14
9
|
llm: undefined,
|
@@ -17,6 +12,15 @@ export const DEFAULT_CONFIG = {
|
|
17
12
|
projectGuidelines: PROJECT_GUIDELINES,
|
18
13
|
projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
|
19
14
|
streamOutput: true,
|
15
|
+
filesystem: [
|
16
|
+
'read_file',
|
17
|
+
'read_multiple_files',
|
18
|
+
'list_directory',
|
19
|
+
'directory_tree',
|
20
|
+
'search_files',
|
21
|
+
'get_file_info',
|
22
|
+
'list_allowed_directories',
|
23
|
+
],
|
20
24
|
commands: {
|
21
25
|
pr: {
|
22
26
|
contentProvider: 'github', // gh pr diff NN
|
@@ -25,29 +29,26 @@ export const DEFAULT_CONFIG = {
|
|
25
29
|
},
|
26
30
|
};
|
27
31
|
/**
|
28
|
-
*
|
29
|
-
*
|
30
|
-
* TODO this should be reworked to something more robust
|
32
|
+
* Initialize configuration by loading from available config files
|
33
|
+
* @returns The loaded SlothConfig
|
31
34
|
*/
|
32
|
-
export const slothContext = {
|
33
|
-
config: DEFAULT_CONFIG,
|
34
|
-
};
|
35
35
|
export async function initConfig() {
|
36
36
|
const jsonConfigPath = getGslothConfigReadPath(USER_PROJECT_CONFIG_JSON);
|
37
|
-
|
38
|
-
const mjsConfigPath = getGslothConfigReadPath(USER_PROJECT_CONFIG_MJS);
|
39
|
-
// Try loading JSON config file first
|
37
|
+
// Try loading the JSON config file first
|
40
38
|
if (existsSync(jsonConfigPath)) {
|
41
39
|
try {
|
42
40
|
// TODO makes sense to employ ZOD to validate config
|
43
41
|
const jsonConfig = JSON.parse(readFileSync(jsonConfigPath, 'utf8'));
|
44
42
|
// If the config has an LLM with a type, create the appropriate LLM instance
|
45
43
|
if (jsonConfig.llm && typeof jsonConfig.llm === 'object' && 'type' in jsonConfig.llm) {
|
46
|
-
await tryJsonConfig(jsonConfig);
|
44
|
+
return await tryJsonConfig(jsonConfig);
|
47
45
|
}
|
48
46
|
else {
|
49
47
|
error(`${jsonConfigPath} is not in valid format. Should at least define llm.type`);
|
50
48
|
exit(1);
|
49
|
+
// noinspection ExceptionCaughtLocallyJS
|
50
|
+
// This throw is unreachable due to exit(1) above, but satisfies TS type analysis and prevents tests from exiting
|
51
|
+
throw new Error('Unexpected error occurred.');
|
51
52
|
}
|
52
53
|
}
|
53
54
|
catch (e) {
|
@@ -61,98 +62,110 @@ export async function initConfig() {
|
|
61
62
|
// JSON config not found, try JS
|
62
63
|
return tryJsConfig();
|
63
64
|
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
displayDebug(e instanceof Error ? e : String(e));
|
74
|
-
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JS}, will try other formats.`);
|
75
|
-
// Continue to try other formats
|
76
|
-
return tryMjsConfig();
|
77
|
-
});
|
65
|
+
}
|
66
|
+
// Helper function to try loading JS config
|
67
|
+
async function tryJsConfig() {
|
68
|
+
const jsConfigPath = getGslothConfigReadPath(USER_PROJECT_CONFIG_JS);
|
69
|
+
if (existsSync(jsConfigPath)) {
|
70
|
+
try {
|
71
|
+
const i = await importExternalFile(jsConfigPath);
|
72
|
+
const customConfig = await i.configure(jsConfigPath);
|
73
|
+
return mergeConfig(customConfig);
|
78
74
|
}
|
79
|
-
|
80
|
-
|
75
|
+
catch (e) {
|
76
|
+
displayDebug(e instanceof Error ? e : String(e));
|
77
|
+
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_JS}, will try other formats.`);
|
78
|
+
// Continue to try other formats
|
81
79
|
return tryMjsConfig();
|
82
80
|
}
|
83
81
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
});
|
82
|
+
else {
|
83
|
+
// JS config not found, try MJS
|
84
|
+
return tryMjsConfig();
|
85
|
+
}
|
86
|
+
}
|
87
|
+
// Helper function to try loading MJS config
|
88
|
+
async function tryMjsConfig() {
|
89
|
+
const mjsConfigPath = getGslothConfigReadPath(USER_PROJECT_CONFIG_MJS);
|
90
|
+
if (existsSync(mjsConfigPath)) {
|
91
|
+
try {
|
92
|
+
const i = await importExternalFile(mjsConfigPath);
|
93
|
+
const customConfig = await i.configure(mjsConfigPath);
|
94
|
+
return mergeConfig(customConfig);
|
98
95
|
}
|
99
|
-
|
100
|
-
|
101
|
-
displayError(
|
102
|
-
|
103
|
-
|
104
|
-
exit();
|
96
|
+
catch (e) {
|
97
|
+
displayDebug(e instanceof Error ? e : String(e));
|
98
|
+
displayError(`Failed to read config from ${USER_PROJECT_CONFIG_MJS}.`);
|
99
|
+
displayError(`No valid configuration found. Please create a valid configuration file.`);
|
100
|
+
exit(1);
|
105
101
|
}
|
106
102
|
}
|
107
|
-
|
108
|
-
//
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
// Check if the LLM type is in availableDefaultConfigs
|
113
|
-
if (!llmType || !availableDefaultConfigs.includes(llmType)) {
|
114
|
-
displayError(`Unsupported LLM type: ${llmType}. Available types are: ${availableDefaultConfigs.join(', ')}`);
|
103
|
+
else {
|
104
|
+
// No config files found
|
105
|
+
displayError('No configuration file found. Please create one of: ' +
|
106
|
+
`${USER_PROJECT_CONFIG_JSON}, ${USER_PROJECT_CONFIG_JS}, or ${USER_PROJECT_CONFIG_MJS} ` +
|
107
|
+
'in your project directory.');
|
115
108
|
exit(1);
|
116
|
-
return;
|
117
109
|
}
|
110
|
+
// This throw is unreachable due to exit(1) above, but satisfies TS type analysis and prevents tests from exiting
|
111
|
+
throw new Error('Unexpected error occurred.');
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* Process JSON LLM config by creating the appropriate LLM instance
|
115
|
+
* @param jsonConfig - The parsed JSON config
|
116
|
+
* @returns Promise<SlothConfig>
|
117
|
+
*/
|
118
|
+
export async function tryJsonConfig(jsonConfig) {
|
118
119
|
try {
|
119
|
-
|
120
|
-
|
120
|
+
if (jsonConfig.llm && typeof jsonConfig.llm === 'object') {
|
121
|
+
// Get the type of LLM (e.g., 'vertexai', 'anthropic') - this should exist
|
122
|
+
const llmType = jsonConfig.llm.type;
|
123
|
+
if (!llmType) {
|
124
|
+
displayError('LLM type not specified in config.');
|
125
|
+
exit(1);
|
126
|
+
}
|
127
|
+
// Get the configuration for the specific LLM type
|
128
|
+
const llmConfig = jsonConfig.llm;
|
129
|
+
// Import the appropriate config module
|
121
130
|
const configModule = await import(`./configs/${llmType}.js`);
|
122
131
|
if (configModule.processJsonConfig) {
|
123
132
|
const llm = (await configModule.processJsonConfig(llmConfig));
|
124
|
-
|
133
|
+
return mergeRawConfig(jsonConfig, llm);
|
125
134
|
}
|
126
135
|
else {
|
127
136
|
displayWarning(`Config module for ${llmType} does not have processJsonConfig function.`);
|
128
137
|
exit(1);
|
129
138
|
}
|
130
139
|
}
|
131
|
-
|
132
|
-
|
133
|
-
displayWarning(`Could not import config module for ${llmType}.`);
|
140
|
+
else {
|
141
|
+
displayError('No LLM configuration found in config.');
|
134
142
|
exit(1);
|
135
143
|
}
|
136
144
|
}
|
137
|
-
catch (
|
138
|
-
|
139
|
-
|
145
|
+
catch (e) {
|
146
|
+
if (e instanceof Error && e.message.includes('Cannot find module')) {
|
147
|
+
displayError(`LLM type '${jsonConfig.llm.type}' not supported.`);
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
displayError(`Error processing LLM config: ${e instanceof Error ? e.message : String(e)}`);
|
151
|
+
}
|
140
152
|
exit(1);
|
141
153
|
}
|
154
|
+
// This throw is unreachable due to exit(1) above, but satisfies TS type analysis and prevents tests from exiting
|
155
|
+
throw new Error('Unexpected error occurred.');
|
142
156
|
}
|
143
157
|
export async function createProjectConfig(configType) {
|
144
|
-
|
145
|
-
writeProjectReviewPreamble();
|
146
|
-
displayWarning(`Make sure you add as much detail as possible to your ${PROJECT_GUIDELINES}.\n`);
|
147
|
-
// Check if the config type is in availableDefaultConfigs
|
158
|
+
// Check if the config type is valid
|
148
159
|
if (!availableDefaultConfigs.includes(configType)) {
|
149
|
-
displayError(`
|
160
|
+
displayError(`Unknown config type: ${configType}. Available options: ${availableDefaultConfigs.join(', ')}`);
|
150
161
|
exit(1);
|
151
|
-
return;
|
152
162
|
}
|
163
|
+
displayInfo(`Setting up your project\n`);
|
164
|
+
writeProjectReviewPreamble();
|
165
|
+
displayWarning(`Make sure you add as much detail as possible to your ${PROJECT_GUIDELINES}.\n`);
|
153
166
|
displayInfo(`Creating project config for ${configType}`);
|
154
167
|
const vendorConfig = await import(`./configs/${configType}.js`);
|
155
|
-
vendorConfig.init(getGslothConfigWritePath(USER_PROJECT_CONFIG_JSON)
|
168
|
+
vendorConfig.init(getGslothConfigWritePath(USER_PROJECT_CONFIG_JSON));
|
156
169
|
}
|
157
170
|
export function writeProjectReviewPreamble() {
|
158
171
|
const guidelinesPath = getGslothConfigWritePath(PROJECT_GUIDELINES);
|
@@ -195,13 +208,20 @@ Important! You are likely to be dealing with git diff below, please don't confus
|
|
195
208
|
writeFileIfNotExistsWithMessages(reviewPath, reviewTemplate);
|
196
209
|
}
|
197
210
|
/**
|
198
|
-
*
|
199
|
-
|
211
|
+
* Merge config with default config
|
212
|
+
*/
|
213
|
+
function mergeConfig(partialConfig) {
|
214
|
+
const config = partialConfig;
|
215
|
+
return {
|
216
|
+
...DEFAULT_CONFIG,
|
217
|
+
...config,
|
218
|
+
commands: { ...DEFAULT_CONFIG.commands, ...(config?.commands ?? {}) },
|
219
|
+
};
|
220
|
+
}
|
221
|
+
/**
|
222
|
+
* Merge raw with default config
|
200
223
|
*/
|
201
|
-
|
202
|
-
|
203
|
-
delete slothContext[key];
|
204
|
-
});
|
205
|
-
slothContext.config = DEFAULT_CONFIG;
|
224
|
+
function mergeRawConfig(config, llm) {
|
225
|
+
return mergeConfig({ ...config, llm });
|
206
226
|
}
|
207
227
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,YAAY,EAA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AAE;KACtE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,MAAsB,EAAE,GAAkB;IAChE,OAAO,WAAW,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
File without changes
|
File without changes
|
File without changes
|
package/dist/configs/fake.d.ts
CHANGED
File without changes
|
package/dist/configs/fake.js
CHANGED
File without changes
|
package/dist/configs/fake.js.map
CHANGED
File without changes
|
package/dist/configs/groq.d.ts
CHANGED
File without changes
|
package/dist/configs/groq.js
CHANGED
File without changes
|
package/dist/configs/groq.js.map
CHANGED
File without changes
|
File without changes
|
package/dist/configs/vertexai.js
CHANGED
File without changes
|
File without changes
|
package/dist/consoleUtils.d.ts
CHANGED
File without changes
|
package/dist/consoleUtils.js
CHANGED
File without changes
|
package/dist/consoleUtils.js.map
CHANGED
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export declare const USER_PROJECT_CONFIG_JS = ".gsloth.config.js";
|
2
|
+
export declare const USER_PROJECT_CONFIG_JSON = ".gsloth.config.json";
|
3
|
+
export declare const USER_PROJECT_CONFIG_MJS = ".gsloth.config.mjs";
|
4
|
+
export declare const GSLOTH_BACKSTORY = ".gsloth.backstory.md";
|
5
|
+
export declare const PROJECT_GUIDELINES = ".gsloth.guidelines.md";
|
6
|
+
export declare const PROJECT_REVIEW_INSTRUCTIONS = ".gsloth.review.md";
|
7
|
+
export declare const GSLOTH_SYSTEM_PROMPT = ".gsloth.system.md";
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export const USER_PROJECT_CONFIG_JS = '.gsloth.config.js';
|
2
|
+
export const USER_PROJECT_CONFIG_JSON = '.gsloth.config.json';
|
3
|
+
export const USER_PROJECT_CONFIG_MJS = '.gsloth.config.mjs';
|
4
|
+
export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
|
5
|
+
export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
|
6
|
+
export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
|
7
|
+
export const GSLOTH_SYSTEM_PROMPT = '.gsloth.system.md';
|
8
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC"}
|
package/dist/filePathUtils.d.ts
CHANGED
File without changes
|
package/dist/filePathUtils.js
CHANGED
File without changes
|
File without changes
|
package/dist/index.d.ts
CHANGED
File without changes
|
package/dist/index.js
CHANGED
@@ -2,7 +2,7 @@ import { Command } from 'commander';
|
|
2
2
|
import { askCommand } from '#src/commands/askCommand.js';
|
3
3
|
import { initCommand } from '#src/commands/initCommand.js';
|
4
4
|
import { reviewCommand } from '#src/commands/reviewCommand.js';
|
5
|
-
import {
|
5
|
+
import { prCommand } from '#src/commands/prCommand.js';
|
6
6
|
import { getSlothVersion } from '#src/utils.js';
|
7
7
|
import { argv, readStdin } from '#src/systemUtils.js';
|
8
8
|
import { setVerbose } from '#src/llmUtils.js';
|
@@ -18,8 +18,10 @@ if (program.getOptionValue('verbose')) {
|
|
18
18
|
// Set global prompt debug
|
19
19
|
setVerbose(true);
|
20
20
|
}
|
21
|
+
// Initialize all commands - they will handle their own config loading
|
21
22
|
initCommand(program);
|
22
|
-
reviewCommand(program
|
23
|
+
reviewCommand(program);
|
24
|
+
prCommand(program);
|
23
25
|
askCommand(program);
|
24
26
|
// TODO add general interactive chat command
|
25
27
|
await readStdin(program);
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,eAAe,EAAE,CAAC;KAC1B,MAAM,CAAC,WAAW,EAAE,kCAAkC,CAAC,CAAC;AAE3D,mDAAmD;AACnD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,IAAI,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;IACtC,0BAA0B;IAC1B,UAAU,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC;AAED,sEAAsE;AACtE,WAAW,CAAC,OAAO,CAAC,CAAC;AACrB,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,SAAS,CAAC,OAAO,CAAC,CAAC;AACnB,UAAU,CAAC,OAAO,CAAC,CAAC;AACpB,4CAA4C;AAE5C,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/llmUtils.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
2
2
|
import { SlothConfig } from '#src/config.js';
|
3
|
-
export declare function invoke(llm: BaseChatModel, systemMessage: string, prompt: string, config: SlothConfig): Promise<string>;
|
3
|
+
export declare function invoke(llm: BaseChatModel, systemMessage: string, prompt: string, config: SlothConfig, command?: 'ask' | 'pr' | 'review'): Promise<string>;
|
4
4
|
export declare function setVerbose(debug: boolean): void;
|
package/dist/llmUtils.js
CHANGED
@@ -1,19 +1,36 @@
|
|
1
|
-
import { HumanMessage,
|
1
|
+
import { HumanMessage, isAIMessage, SystemMessage } from '@langchain/core/messages';
|
2
2
|
import { MultiServerMCPClient } from '@langchain/mcp-adapters';
|
3
|
-
import { display, displayError, displayInfo } from '#src/consoleUtils.js';
|
3
|
+
import { display, displayError, displayInfo, displayWarning } from '#src/consoleUtils.js';
|
4
4
|
import { createReactAgent } from '@langchain/langgraph/prebuilt';
|
5
|
-
import { stdout } from '#src/systemUtils.js';
|
5
|
+
import { getCurrentDir, stdout } from '#src/systemUtils.js';
|
6
|
+
import { ProgressIndicator } from '#src/utils.js';
|
6
7
|
const llmGlobalSettings = {
|
7
8
|
verbose: false,
|
8
9
|
};
|
9
|
-
export async function invoke(llm, systemMessage, prompt, config) {
|
10
|
+
export async function invoke(llm, systemMessage, prompt, config, command) {
|
11
|
+
try {
|
12
|
+
if (config.streamOutput && config.llm._llmType() === 'anthropic') {
|
13
|
+
displayWarning('To avoid known bug with Anthropic forcing streamOutput to false');
|
14
|
+
config.streamOutput = false;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
catch { }
|
10
18
|
if (llmGlobalSettings.verbose) {
|
11
19
|
llm.verbose = true;
|
12
20
|
}
|
13
|
-
|
14
|
-
|
15
|
-
if (
|
16
|
-
|
21
|
+
// Merge command-specific filesystem config if provided
|
22
|
+
let effectiveConfig = config;
|
23
|
+
if (command && config.commands?.[command]?.filesystem !== undefined) {
|
24
|
+
effectiveConfig = {
|
25
|
+
...config,
|
26
|
+
filesystem: config.commands[command].filesystem,
|
27
|
+
};
|
28
|
+
}
|
29
|
+
const client = getClient(effectiveConfig);
|
30
|
+
const allTools = (await client?.getTools()) ?? [];
|
31
|
+
const tools = filterTools(allTools, effectiveConfig.filesystem || 'none');
|
32
|
+
if (allTools.length > 0) {
|
33
|
+
displayInfo(`Loaded ${tools.length} tools.`);
|
17
34
|
}
|
18
35
|
// Create the React agent
|
19
36
|
const agent = createReactAgent({
|
@@ -24,19 +41,39 @@ export async function invoke(llm, systemMessage, prompt, config) {
|
|
24
41
|
try {
|
25
42
|
const messages = [new SystemMessage(systemMessage), new HumanMessage(prompt)];
|
26
43
|
display(`Connecting to LLM...`);
|
27
|
-
const stream = await agent.stream({ messages }, { streamMode: 'messages' });
|
28
44
|
const output = { aiMessage: '' };
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
45
|
+
if (!config.streamOutput) {
|
46
|
+
const progress = new ProgressIndicator('Thinking.');
|
47
|
+
try {
|
48
|
+
const response = await agent.invoke({ messages });
|
49
|
+
output.aiMessage = response.messages[response.messages.length - 1].content;
|
50
|
+
const toolNames = response.messages
|
51
|
+
.filter((msg) => msg.tool_calls && msg.tool_calls.length > 0)
|
52
|
+
.flatMap((msg) => msg.tool_calls.map((tc) => tc.name));
|
53
|
+
if (toolNames.length > 0) {
|
54
|
+
displayInfo(`\nUsed tools: ${toolNames.join(', ')}`);
|
33
55
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
56
|
+
}
|
57
|
+
catch (e) {
|
58
|
+
displayWarning(`Something went wrong ${e.message}`);
|
59
|
+
}
|
60
|
+
finally {
|
61
|
+
progress.stop();
|
62
|
+
}
|
63
|
+
display(output.aiMessage);
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
const stream = await agent.stream({ messages }, { streamMode: 'messages' });
|
67
|
+
for await (const [chunk, _metadata] of stream) {
|
68
|
+
if (isAIMessage(chunk)) {
|
69
|
+
stdout.write(chunk.content, 'utf-8');
|
70
|
+
output.aiMessage += chunk.content;
|
71
|
+
let toolCalls = chunk.tool_calls;
|
72
|
+
if (toolCalls && toolCalls.length > 0) {
|
73
|
+
const suffix = toolCalls.length > 1 ? 's' : '';
|
74
|
+
const toolCallsString = toolCalls.map((t) => t?.name).join(', ');
|
75
|
+
displayInfo(`Using tool${suffix} ${toolCallsString}`);
|
76
|
+
}
|
40
77
|
}
|
41
78
|
}
|
42
79
|
}
|
@@ -52,7 +89,6 @@ export async function invoke(llm, systemMessage, prompt, config) {
|
|
52
89
|
}
|
53
90
|
finally {
|
54
91
|
if (client) {
|
55
|
-
console.log('closing');
|
56
92
|
await client.close();
|
57
93
|
}
|
58
94
|
}
|
@@ -60,13 +96,40 @@ export async function invoke(llm, systemMessage, prompt, config) {
|
|
60
96
|
export function setVerbose(debug) {
|
61
97
|
llmGlobalSettings.verbose = debug;
|
62
98
|
}
|
99
|
+
function filterTools(tools, filesystemConfig) {
|
100
|
+
if (filesystemConfig === 'all' || !Array.isArray(filesystemConfig)) {
|
101
|
+
return tools;
|
102
|
+
}
|
103
|
+
// Create set of allowed tool names with mcp__filesystem__ prefix
|
104
|
+
const allowedToolNames = new Set(filesystemConfig.map((shortName) => `mcp__filesystem__${shortName}`));
|
105
|
+
return tools.filter((tool) => {
|
106
|
+
// Allow non-filesystem tools and only allowed filesystem tools
|
107
|
+
return !tool.name.startsWith('mcp__filesystem__') || allowedToolNames.has(tool.name);
|
108
|
+
});
|
109
|
+
}
|
63
110
|
function getClient(config) {
|
64
|
-
|
111
|
+
const defaultServers = {};
|
112
|
+
// Add filesystem server if configured
|
113
|
+
if (config.filesystem && config.filesystem !== 'none') {
|
114
|
+
const filesystemConfig = {
|
115
|
+
transport: 'stdio',
|
116
|
+
command: 'npx',
|
117
|
+
args: ['-y', '@modelcontextprotocol/server-filesystem', getCurrentDir()],
|
118
|
+
};
|
119
|
+
defaultServers.filesystem = filesystemConfig;
|
120
|
+
}
|
121
|
+
// Merge with user's mcpServers
|
122
|
+
const mcpServers = { ...defaultServers, ...(config.mcpServers || {}) };
|
123
|
+
// If user provided their own filesystem config, it overrides default
|
124
|
+
if (config.mcpServers?.filesystem) {
|
125
|
+
mcpServers.filesystem = config.mcpServers.filesystem;
|
126
|
+
}
|
127
|
+
if (Object.keys(mcpServers).length > 0) {
|
65
128
|
return new MultiServerMCPClient({
|
66
129
|
throwOnLoadError: true,
|
67
130
|
prefixToolNameWithServerName: true,
|
68
131
|
additionalToolNamePrefix: 'mcp',
|
69
|
-
mcpServers
|
132
|
+
mcpServers,
|
70
133
|
});
|
71
134
|
}
|
72
135
|
else {
|
package/dist/llmUtils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"llmUtils.js","sourceRoot":"","sources":["../src/llmUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,
|
1
|
+
{"version":3,"file":"llmUtils.js","sourceRoot":"","sources":["../src/llmUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAIpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE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gB,CAAC;IAC/C,CAAC;IAED,+BAA+B;IAC/B,MAAM,UAAU,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;IAEvE,qEAAqE;IACrE,IAAI,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;QAClC,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;IACvD,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,oBAAoB,CAAC;YAC9B,gBAAgB,EAAE,IAAI;YACtB,4BAA4B,EAAE,IAAI;YAClC,wBAAwB,EAAE,KAAK;YAC/B,UAAU;SACX,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
@@ -1,7 +1,8 @@
|
|
1
|
+
import type { SlothConfig } from '#src/config.js';
|
1
2
|
/**
|
2
3
|
* Ask a question and get an answer from the LLM
|
3
4
|
* @param source - The source of the question (used for file naming)
|
4
5
|
* @param preamble - The preamble to send to the LLM
|
5
6
|
* @param content - The content of the question
|
6
7
|
*/
|
7
|
-
export declare function askQuestion(source: string, preamble: string, content: string): Promise<void>;
|
8
|
+
export declare function askQuestion(source: string, preamble: string, content: string, config: SlothConfig): Promise<void>;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { slothContext } from '#src/config.js';
|
2
1
|
import { display, displayError, displaySuccess } from '#src/consoleUtils.js';
|
3
2
|
import { getGslothFilePath } from '#src/filePathUtils.js';
|
4
3
|
import { generateStandardFileName, ProgressIndicator } from '#src/utils.js';
|
@@ -10,15 +9,13 @@ import { invoke } from '#src/llmUtils.js';
|
|
10
9
|
* @param preamble - The preamble to send to the LLM
|
11
10
|
* @param content - The content of the question
|
12
11
|
*/
|
13
|
-
export async function askQuestion(source, preamble, content) {
|
14
|
-
const progressIndicator =
|
15
|
-
|
16
|
-
: new ProgressIndicator('Thinking.');
|
17
|
-
const outputContent = await invoke(slothContext.config.llm, preamble, content, slothContext.config);
|
12
|
+
export async function askQuestion(source, preamble, content, config) {
|
13
|
+
const progressIndicator = config.streamOutput ? undefined : new ProgressIndicator('Thinking.');
|
14
|
+
const outputContent = await invoke(config.llm, preamble, content, config, 'ask');
|
18
15
|
progressIndicator?.stop();
|
19
16
|
const filename = generateStandardFileName(source);
|
20
17
|
const filePath = getGslothFilePath(filename);
|
21
|
-
if (!
|
18
|
+
if (!config.streamOutput) {
|
22
19
|
display('\n' + outputContent);
|
23
20
|
}
|
24
21
|
try {
|