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/docs/CONFIGURATION.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# Configuration
|
2
2
|
|
3
|
-
Populate `.gsloth.
|
3
|
+
Populate `.gsloth.guidelines.md` with your project details and quality requirements.
|
4
4
|
Proper preamble is a paramount for good inference.
|
5
|
-
Check [.gsloth.
|
5
|
+
Check [.gsloth.guidelines.md](../.gsloth.guidelines.md) for example.
|
6
6
|
|
7
7
|
Your project should have the following files in order for gsloth to function:
|
8
8
|
- Configuration file (one of):
|
9
9
|
- `.gsloth.config.js` (JavaScript module)
|
10
10
|
- `.gsloth.config.json` (JSON file)
|
11
11
|
- `.gsloth.config.mjs` (JavaScript module with explicit module extension)
|
12
|
-
- `.gsloth.
|
12
|
+
- `.gsloth.guidelines.md`
|
13
13
|
|
14
|
-
> Gaunt Sloth currently only functions from the directory which has one of the configuration files and `.gsloth.
|
14
|
+
> Gaunt Sloth currently only functions from the directory which has one of the configuration files and `.gsloth.guidelines.md`.
|
15
15
|
> Global configuration to invoke gsloth anywhere is in [ROADMAP](../ROADMAP.md).
|
16
16
|
|
17
17
|
## Config initialization
|
@@ -62,7 +62,7 @@ JSON configuration is simpler but less flexible than JavaScript configuration. I
|
|
62
62
|
{
|
63
63
|
"llm": {
|
64
64
|
"type": "vertexai",
|
65
|
-
"model": "gemini-2.5-pro-
|
65
|
+
"model": "gemini-2.5-pro-preview-05-06",
|
66
66
|
"temperature": 0
|
67
67
|
}
|
68
68
|
}
|
@@ -109,7 +109,7 @@ export async function configure(importFunction, global) {
|
|
109
109
|
const vertexAi = await importFunction('@langchain/google-vertexai');
|
110
110
|
return {
|
111
111
|
llm: new vertexAi.ChatVertexAI({
|
112
|
-
model: "gemini-2.5-pro-
|
112
|
+
model: "gemini-2.5-pro-preview-05-06", // Consider checking for latest recommended model versions
|
113
113
|
// API Key from AI Studio should also work
|
114
114
|
temperature: 0,
|
115
115
|
//// Other parameters might be relevant depending on Vertex AI API updates.
|
@@ -146,16 +146,106 @@ See [Langchain documentation](https://js.langchain.com/docs/tutorials/llm_chain/
|
|
146
146
|
|
147
147
|
### JIRA
|
148
148
|
|
149
|
+
Gaunt Sloth supports two methods to integrate with JIRA:
|
150
|
+
|
151
|
+
#### 1. Modern Jira REST API (Scoped Token)
|
152
|
+
|
153
|
+
This method uses the Atlassian REST API v3 with a Personal Access Token (PAT). It requires your Atlassian Cloud ID.
|
154
|
+
|
155
|
+
**Prerequisites:**
|
156
|
+
|
157
|
+
1. **Cloud ID**: You can find your Cloud ID by visiting `https://yourcompany.atlassian.net/_edge/tenant_info` while authenticated.
|
158
|
+
|
159
|
+
2. **Personal Access Token (PAT)**: Create a PAT with the appropriate permissions from `Atlassian Account Settings -> Security -> Create and manage API tokens -> [Create API token with scopes]`.
|
160
|
+
- For issue access, the recommended permission is `read:jira-work` (classic)
|
161
|
+
- Alternatively granular access would require: `read:issue-meta:jira`, `read:issue-security-level:jira`, `read:issue.vote:jira`, `read:issue.changelog:jira`, `read:avatar:jira`, `read:issue:jira`, `read:status:jira`, `read:user:jira`, `read:field-configuration:jira`
|
162
|
+
|
163
|
+
Refer to JIRA API documentation for more details [https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-get](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-get)
|
164
|
+
|
165
|
+
**Environment Variables Support:**
|
166
|
+
|
167
|
+
For better security, you can set the JIRA username, token, and cloud ID using environment variables instead of placing them in the configuration file:
|
168
|
+
|
169
|
+
- `JIRA_USERNAME`: Your JIRA username (e.g., `user@yourcompany.com`).
|
170
|
+
- `JIRA_API_PAT_TOKEN`: Your JIRA Personal Access Token with scopes.
|
171
|
+
- `JIRA_CLOUD_ID`: Your Atlassian Cloud ID.
|
172
|
+
|
173
|
+
If these environment variables are set, they will take precedence over the values in the configuration file.
|
174
|
+
|
175
|
+
JSON:
|
176
|
+
|
177
|
+
```json
|
178
|
+
{
|
179
|
+
"llm": {"type": "vertexai", "model": "gemini-2.5-pro-preview-05-06"},
|
180
|
+
"requirementsProvider": "jira",
|
181
|
+
"requirementsProviderConfig": {
|
182
|
+
"jira": {
|
183
|
+
"username": "username@yourcompany.com",
|
184
|
+
"token": "YOUR_JIRA_PAT_TOKEN",
|
185
|
+
"cloudId": "YOUR_ATLASSIAN_CLOUD_ID"
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
```
|
190
|
+
|
191
|
+
Optionally displayUrl can be defined to have a clickable link in the output:
|
192
|
+
|
193
|
+
```json
|
194
|
+
{
|
195
|
+
"llm": {"type": "vertexai", "model": "gemini-2.5-pro-preview-05-06"},
|
196
|
+
"requirementsProvider": "jira",
|
197
|
+
"requirementsProviderConfig": {
|
198
|
+
"jira": {
|
199
|
+
"displayUrl": "https://yourcompany.atlassian.net/browse/"
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
```
|
204
|
+
|
205
|
+
JavaScript:
|
206
|
+
|
207
|
+
```javascript
|
208
|
+
export async function configure(importFunction, global) {
|
209
|
+
const vertexAi = await importFunction('@langchain/google-vertexai');
|
210
|
+
return {
|
211
|
+
llm: new vertexAi.ChatVertexAI({
|
212
|
+
model: "gemini-2.5-pro-preview-05-06"
|
213
|
+
}),
|
214
|
+
requirementsProvider: 'jira',
|
215
|
+
requirementsProviderConfig: {
|
216
|
+
'jira': {
|
217
|
+
username: 'username@yourcompany.com', // Your Jira username/email
|
218
|
+
token: 'YOUR_JIRA_PAT_TOKEN', // Your Personal Access Token
|
219
|
+
cloudId: 'YOUR_ATLASSIAN_CLOUD_ID' // Your Atlassian Cloud ID
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
```
|
225
|
+
|
226
|
+
#### 2. Legacy Jira REST API (Unscoped Token)
|
227
|
+
|
228
|
+
This uses the Unscoped API token (Aka Legacy API token) method with REST API v2.
|
229
|
+
|
230
|
+
A legacy token can be acquired from `Atlassian Account Settings -> Security -> Create and manage API tokens -> [Create API token without scopes]`.
|
231
|
+
|
149
232
|
Example configuration setting up JIRA integration using a legacy API token for both `review` and `pr` commands.
|
150
233
|
Make sure you use your actual company domain in `baseUrl` and your personal legacy `token`.
|
151
234
|
|
152
|
-
|
235
|
+
**Environment Variables Support:**
|
236
|
+
|
237
|
+
For better security, you can set the JIRA username and token using environment variables instead of placing them in the configuration file:
|
238
|
+
|
239
|
+
- `JIRA_USERNAME`: Your JIRA username (e.g., `user@yourcompany.com`).
|
240
|
+
- `JIRA_LEGACY_API_TOKEN`: Your JIRA legacy API token.
|
241
|
+
|
242
|
+
If these environment variables are set, they will take precedence over the values in the configuration file.
|
153
243
|
|
154
244
|
JSON:
|
155
245
|
|
156
246
|
```json
|
157
247
|
{
|
158
|
-
"llm": {"type": "vertexai", "model": "gemini-2.5-pro-
|
248
|
+
"llm": {"type": "vertexai", "model": "gemini-2.5-pro-preview-05-06"},
|
159
249
|
"requirementsProvider": "jira-legacy",
|
160
250
|
"requirementsProviderConfig": {
|
161
251
|
"jira-legacy": {
|
@@ -174,7 +264,7 @@ export async function configure(importFunction, global) {
|
|
174
264
|
const vertexAi = await importFunction('@langchain/google-vertexai');
|
175
265
|
return {
|
176
266
|
llm: new vertexAi.ChatVertexAI({
|
177
|
-
model: "gemini-2.5-pro-
|
267
|
+
model: "gemini-2.5-pro-preview-05-06"
|
178
268
|
}),
|
179
269
|
requirementsProvider: 'jira-legacy',
|
180
270
|
requirementsProviderConfig: {
|
@@ -187,4 +277,3 @@ export async function configure(importFunction, global) {
|
|
187
277
|
}
|
188
278
|
}
|
189
279
|
```
|
190
|
-
|
package/docs/RELEASE-HOWTO.md
CHANGED
@@ -16,11 +16,17 @@ git push --tags
|
|
16
16
|
|
17
17
|
Note the release version and do
|
18
18
|
```shell
|
19
|
-
gh release create --
|
19
|
+
gh release create --notes "notes"
|
20
20
|
```
|
21
21
|
|
22
22
|
Publish to NPM
|
23
23
|
```shell
|
24
24
|
npm login
|
25
25
|
npm publish
|
26
|
+
```
|
27
|
+
|
28
|
+
Delete incidental remote and local tag
|
29
|
+
```shell
|
30
|
+
git push --delete v0.3.0
|
31
|
+
git push --delete origin v0.3.0
|
26
32
|
```
|
package/eslint.config.js
CHANGED
@@ -1,38 +1,116 @@
|
|
1
|
-
import
|
2
|
-
import { defineConfig } from
|
3
|
-
import
|
4
|
-
import
|
1
|
+
import jsConfig from '@eslint/js';
|
2
|
+
import { defineConfig } from 'eslint/config';
|
3
|
+
import globals from 'globals';
|
4
|
+
import tseslint from '@typescript-eslint/eslint-plugin';
|
5
|
+
import tsParser from '@typescript-eslint/parser';
|
6
|
+
import prettierConfig from 'eslint-config-prettier';
|
7
|
+
import prettierPlugin from 'eslint-plugin-prettier';
|
8
|
+
import path from 'path';
|
9
|
+
import { fileURLToPath } from 'url';
|
5
10
|
|
6
|
-
|
11
|
+
// Get the directory path of the current module
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
13
|
+
const __dirname = path.dirname(__filename);
|
14
|
+
|
15
|
+
// Global ignores applied to all configurations
|
16
|
+
const globalIgnores = ['**/node_modules/**', '**/dist/**', 'coverage/**', '.git/**'];
|
7
17
|
|
8
18
|
export default defineConfig([
|
19
|
+
// Ignore files config - applies first
|
20
|
+
{
|
21
|
+
ignores: globalIgnores,
|
22
|
+
},
|
23
|
+
// Base configuration for all JavaScript files
|
9
24
|
{
|
10
|
-
files: [
|
25
|
+
files: ['**/*.js'],
|
26
|
+
languageOptions: {
|
27
|
+
ecmaVersion: 2022,
|
28
|
+
sourceType: 'module',
|
29
|
+
globals: {
|
30
|
+
...globals.node,
|
31
|
+
},
|
32
|
+
},
|
11
33
|
plugins: {
|
12
|
-
|
34
|
+
prettier: prettierPlugin,
|
13
35
|
},
|
14
|
-
extends: ["js/recommended"],
|
15
36
|
rules: {
|
16
|
-
|
17
|
-
|
37
|
+
...jsConfig.configs.recommended.rules,
|
38
|
+
...prettierConfig.rules,
|
39
|
+
semi: 'error',
|
40
|
+
'eol-last': 'error',
|
41
|
+
'prettier/prettier': 'error',
|
42
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
18
43
|
},
|
44
|
+
},
|
45
|
+
// Source TypeScript files
|
46
|
+
{
|
47
|
+
files: ['src/**/*.ts'],
|
19
48
|
languageOptions: {
|
49
|
+
parser: tsParser,
|
50
|
+
parserOptions: {
|
51
|
+
ecmaVersion: 2022,
|
52
|
+
sourceType: 'module',
|
53
|
+
project: path.resolve(__dirname, 'tsconfig.json'),
|
54
|
+
},
|
20
55
|
globals: {
|
21
|
-
|
22
|
-
setInterval,
|
23
|
-
clearInterval,
|
24
|
-
Buffer,
|
25
|
-
fetch
|
56
|
+
...globals.node,
|
26
57
|
},
|
27
58
|
},
|
59
|
+
plugins: {
|
60
|
+
'@typescript-eslint': tseslint,
|
61
|
+
prettier: prettierPlugin,
|
62
|
+
},
|
63
|
+
rules: {
|
64
|
+
...tseslint.configs.recommended.rules,
|
65
|
+
...prettierConfig.rules,
|
66
|
+
semi: 'error',
|
67
|
+
'eol-last': 'error',
|
68
|
+
'prettier/prettier': 'error',
|
69
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
70
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
71
|
+
'@typescript-eslint/no-unused-vars': [
|
72
|
+
'error',
|
73
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
|
74
|
+
],
|
75
|
+
},
|
28
76
|
},
|
77
|
+
// Test TypeScript files with separate project reference
|
29
78
|
{
|
30
|
-
files: [
|
31
|
-
|
32
|
-
|
79
|
+
files: ['spec/**/*.ts', 'vitest.config.ts'],
|
80
|
+
languageOptions: {
|
81
|
+
parser: tsParser,
|
82
|
+
parserOptions: {
|
83
|
+
ecmaVersion: 2022,
|
84
|
+
sourceType: 'module',
|
85
|
+
// No project needed for tests to avoid parser errors
|
86
|
+
},
|
87
|
+
globals: {
|
88
|
+
...globals.node,
|
89
|
+
describe: 'readonly',
|
90
|
+
it: 'readonly',
|
91
|
+
expect: 'readonly',
|
92
|
+
beforeEach: 'readonly',
|
93
|
+
afterEach: 'readonly',
|
94
|
+
vi: 'readonly',
|
95
|
+
},
|
96
|
+
},
|
97
|
+
plugins: {
|
98
|
+
'@typescript-eslint': tseslint,
|
99
|
+
prettier: prettierPlugin,
|
100
|
+
},
|
33
101
|
rules: {
|
34
|
-
|
35
|
-
|
36
|
-
|
102
|
+
...tseslint.configs.recommended.rules,
|
103
|
+
...prettierConfig.rules,
|
104
|
+
semi: 'error',
|
105
|
+
'eol-last': 'error',
|
106
|
+
'prettier/prettier': 'error',
|
107
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
108
|
+
'@typescript-eslint/no-explicit-any': 'off', // Allow any in test files
|
109
|
+
'@typescript-eslint/no-unused-vars': [
|
110
|
+
'error',
|
111
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
112
|
+
], // Error for unused vars in tests
|
113
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], // For .js test files
|
114
|
+
},
|
37
115
|
},
|
38
116
|
]);
|
@@ -0,0 +1 @@
|
|
1
|
+
✅ Understood. I am ready for your programming-related inquiries. Please state your requirements.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
This `package.json` file is reasonably well-structured. I have a few observations:
|
2
|
+
|
3
|
+
* ✅ **`name`, `version`, `license`, `author`, `type`, `main`, `repository`**: These fields are correctly defined. Using `"type": "module"` is a modern choice.
|
4
|
+
* ✅ **`engines`**: Clearly specifies Node.js `>=22.0.0` and npm `>=10.9.0`. These are very recent versions, which is a deliberate choice that limits broader compatibility but ensures usage of newer features.
|
5
|
+
* ✅ **`scripts`**:
|
6
|
+
* `build`, `lint`, `format`: Standard and appropriate.
|
7
|
+
* `test`: `"npm run build && vitest run"` is good practice, ensuring tests run against the compiled output.
|
8
|
+
* `prepare`: `"npm run build"` is also standard, ensuring the package is built after installation and before publishing.
|
9
|
+
* ✅ **`dependencies`** and **`devDependencies`**: The listed packages are appropriate for the described functionality (Langchain, CLI tools) and development (TypeScript, ESLint, Prettier, Vitest). Versions are up-to-date.
|
10
|
+
* ✅ **`imports`**: The subpath import `"#src/*.js": "./dist/*.js"` is a modern way to define internal package aliases.
|
11
|
+
* ⚠️ For a smoother development experience with TypeScript, ensure your `tsconfig.json` has a corresponding `paths` alias, for example:
|
12
|
+
```json
|
13
|
+
{
|
14
|
+
"compilerOptions": {
|
15
|
+
"baseUrl": ".", // Or "./src"
|
16
|
+
"paths": {
|
17
|
+
"#src/*": ["src/*"] // Or just "*" if baseUrl is "./src"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
```
|
22
|
+
This allows TypeScript to resolve `#src/...` imports to your source files during development and type-checking.
|
23
|
+
|
24
|
+
Now, for more critical points:
|
25
|
+
|
26
|
+
* ❌ **`bin` configuration**:
|
27
|
+
```json
|
28
|
+
"bin": {
|
29
|
+
"gsloth": "index.js",
|
30
|
+
"gth": "index.js"
|
31
|
+
}
|
32
|
+
```
|
33
|
+
Your `main` field is `"dist/index.js"`, indicating that your compiled, runnable JavaScript code resides in the `dist` directory. However, your `bin` entries point to `index.js` in the project root.
|
34
|
+
If `index.js` in the root is your TypeScript source file (or does not exist), this will not work when the package is installed globally or used via `npx`. The `bin` entries should point to the executable JavaScript files generated by your build process.
|
35
|
+
Typically, this would be something like:
|
36
|
+
```json
|
37
|
+
"bin": {
|
38
|
+
"gsloth": "dist/index.js", // Or a specific CLI entry point like "dist/cli.js"
|
39
|
+
"gth": "dist/index.js" // Same here
|
40
|
+
}
|
41
|
+
```
|
42
|
+
The target file (e.g., `dist/index.js` or `dist/cli.js`) must be executable and should start with a shebang line (e.g., `#!/usr/bin/env node`). If your main TypeScript entry point (e.g., `src/index.ts` or `src/cli.ts`) includes this shebang, `tsc` usually preserves it in the output JavaScript file.
|
43
|
+
|
44
|
+
* ⚠️ **`description`**: The `description` field is empty.
|
45
|
+
```json
|
46
|
+
"description": "",
|
47
|
+
```
|
48
|
+
Providing a concise description is highly recommended. It improves the package's discoverability on npm and helps users understand its purpose quickly.
|
49
|
+
|
50
|
+
In summary:
|
51
|
+
The most critical issue is the `bin` configuration, which likely needs to be updated to point to files within your `dist` directory. The empty `description` is a minor omission. The `imports` setup is good, but ensure your TypeScript configuration complements it for development.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Okay, I've reviewed your `package.json` file. Here's my assessment:
|
2
|
+
|
3
|
+
## `package.json` Review
|
4
|
+
|
5
|
+
Overall, this `package.json` is well-structured and sets up a modern Node.js TypeScript project with appropriate tooling for LangChain/LangGraph development. However, there are a few points to address.
|
6
|
+
|
7
|
+
### ✅ Positive Aspects
|
8
|
+
|
9
|
+
* **Modern Node.js Setup**:
|
10
|
+
* `"type": "module"`: Correctly enables ES module syntax.
|
11
|
+
* `"engines"`: Specifying Node.js (`>=22.0.0`) and npm (`>=10.9.0`) versions is good practice for ensuring environment compatibility.
|
12
|
+
* **Build and Development Scripts**:
|
13
|
+
* `"build": "tsc"`: Standard TypeScript compilation.
|
14
|
+
* `"test": "npm run build && vitest run"`: Ensures code is built before tests run. `vitest` is a good choice for a modern testing framework.
|
15
|
+
* `"lint": "eslint . --ext .js,.ts"`: Proper linting setup.
|
16
|
+
* `"format": "prettier --write 'src/**/*.{js,ts}'"`: Standard code formatting.
|
17
|
+
* `"prepare": "npm run build"`: Excellent practice to ensure the project is built after installation, making it ready for use, especially if it's a library or a CLI tool.
|
18
|
+
* **Dependencies**:
|
19
|
+
* The LangChain/LangGraph dependencies (`@langchain/anthropic`, `@langchain/core`, `@langchain/google-vertexai`, `@langchain/groq`, `@langchain/langgraph`) are correctly listed. Using `^` for versioning allows for non-breaking updates.
|
20
|
+
* Utility dependencies like `chalk`, `commander`, and `uuid` are appropriate for a CLI/assistant type of project.
|
21
|
+
* **Dev Dependencies**:
|
22
|
+
* A comprehensive set of development tools is included: TypeScript, ESLint (with TypeScript and Prettier plugins), Prettier, and type definitions (`@types/node`, `@types/uuid`).
|
23
|
+
* **Subpath Imports**:
|
24
|
+
* `"imports": { "#src/*.js": "./dist/*.js" }`: This is a good use of Node.js subpath imports, allowing for cleaner import statements within your compiled code (e.g., `import ... from '#src/module.js'`).
|
25
|
+
|
26
|
+
### ⚠️ Areas for Improvement / Potential Issues
|
27
|
+
|
28
|
+
* **Missing Description**:
|
29
|
+
* The `"description"` field is empty. It's good practice to provide a brief description of your package. This is helpful for `npm search` and general understanding.
|
30
|
+
* **Recommendation**: Add a concise description.
|
31
|
+
* **`globals` Dependency**:
|
32
|
+
* The `globals` package is listed in `devDependencies`. While it can be used to define global variables for ESLint, modern ESLint configurations (especially with `@eslint/js` and `@typescript-eslint/parser`) often handle this directly within the ESLint configuration file (e.g., `env` or `globals` sections in `.eslintrc.js`).
|
33
|
+
* **Recommendation**: Verify if this dependency is actively used and necessary. If your ESLint configuration handles globals sufficiently, this might be redundant.
|
34
|
+
|
35
|
+
### ❌ Critical Issues
|
36
|
+
|
37
|
+
* **Incorrect `bin` Path(s)**:
|
38
|
+
* The `"bin"` field defines CLI commands:
|
39
|
+
```json
|
40
|
+
"bin": {
|
41
|
+
"gsloth": "index.js",
|
42
|
+
"gth": "index.js"
|
43
|
+
}
|
44
|
+
```
|
45
|
+
* However, your `"main"` field is `"dist/index.js"`, and your build script (`tsc`) compiles TypeScript from `src` to `dist`. This strongly suggests that the executable entry point for your CLI should be within the `dist` directory (likely `dist/index.js` or a specific CLI entry file in `dist`).
|
46
|
+
* Pointing `bin` to `index.js` in the project root will either:
|
47
|
+
1. Fail if `index.js` doesn't exist or isn't executable.
|
48
|
+
2. Run the wrong (uncompiled or placeholder) code if an `index.js` exists in the root but isn't the intended compiled entry point.
|
49
|
+
* **Recommendation**: Change the `bin` paths to point to the compiled JavaScript entry file. For example:
|
50
|
+
```json
|
51
|
+
"bin": {
|
52
|
+
"gsloth": "dist/index.js",
|
53
|
+
"gth": "dist/index.js"
|
54
|
+
}
|
55
|
+
```
|
56
|
+
Or, if you have a dedicated CLI entry point, adjust accordingly (e.g., `dist/cli.js`). Ensure the target file has a shebang (e.g., `#!/usr/bin/env node`) if it's meant to be directly executable.
|
57
|
+
|
58
|
+
### Summary
|
59
|
+
|
60
|
+
The `package.json` is largely well-configured for a TypeScript-based LangChain/LangGraph project. The most critical issue to address is the `bin` path configuration to ensure your CLI commands work correctly after installation. The other points are minor improvements.
|
61
|
+
|
62
|
+
Please provide the actual code files (TypeScript/JavaScript) when you're ready for a review of the LangChain/LangGraph logic itself.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Greetings. I have reviewed the submitted diff. The changes introduce significant architectural improvements, enhance configuration flexibility, and refine the user experience.
|
2
|
+
|
3
|
+
Here is my assessment:
|
4
|
+
|
5
|
+
**Architectural and Flow Improvements:**
|
6
|
+
* ✅ The introduction of `src/llmUtils.ts` is a commendable refactoring. Centralizing the LangChain/LangGraph LLM invocation logic into a reusable `invoke` function simplifies the `questionAnsweringModule` and `reviewModule` considerably. This promotes the DRY principle and makes the core LLM interaction logic easier to manage and test.
|
7
|
+
* ✅ The use of `StateGraph`, `MessagesAnnotation`, and `MemorySaver` from `@langchain/langgraph` within `llmUtils.ts` is appropriate for managing the LLM interaction state.
|
8
|
+
* ✅ The separation of prompt concerns into distinct files (`.gsloth.backstory.md`, `.gsloth.guidelines.md`, `.gsloth.review.md`) and corresponding loader functions (`readBackstory`, `readGuidelines`, `readReviewInstructions`) in `src/prompt.ts` provides better organization and clarity for prompt engineering.
|
9
|
+
* ✅ Handling of standard input (`stdin`) has been cleanly moved to `src/systemUtils.ts` and cached, which is a more logical placement.
|
10
|
+
|
11
|
+
**Configuration Enhancements:**
|
12
|
+
* ✅ The `SlothConfig` interface and default configurations in `src/config.ts` have been updated to include `projectGuidelines` and `projectReviewInstructions`. This allows for more tailored prompting.
|
13
|
+
* ✅ The type hint for the LLM instance in `SlothConfig` has been refined from `LanguageModelLike` to the more specific `BaseChatModel`.
|
14
|
+
* ✅ Documentation (`README.md`, `docs/CONFIGURATION.md`) and initialization logic (`initCommand`) have been updated to reflect the new configuration file names (e.g., `.gsloth.guidelines.md`).
|
15
|
+
|
16
|
+
**Code Quality and Testing:**
|
17
|
+
* ✅ Test suites (`*.spec.ts`) have been diligently updated to reflect the refactoring. Mocks are handled more cleanly (e.g., top-level `vi.mock`), and tests cover the new `llmUtils.ts` and changes in existing modules.
|
18
|
+
* ✅ The new output file prefix `gth-` (e.g., `gth-ASK`, `gth-DIFF-review`) is consistently applied across the codebase and tests, and is now included in `.gitignore`.
|
19
|
+
* ✅ TypeScript types are used effectively, and improvements have been made (e.g., `BaseChatModel`).
|
20
|
+
* ✅ The new global `--verbose` option in `src/index.ts` for enabling detailed LLM prompt logging is a useful debugging feature.
|
21
|
+
|
22
|
+
**User Experience:**
|
23
|
+
* ✅ The `ProgressIndicator` in `src/utils.ts` has been significantly improved. It now provides continuous feedback for long-running operations by default and includes a `stop()` method for clean termination. It also supports a manual indication mode.
|
24
|
+
|
25
|
+
**Specific Feedback & Suggestions:**
|
26
|
+
|
27
|
+
* ⚠️ **Security Suggestion (Important):** In `src/commands/reviewCommand.ts`, there's a `TODO` comment regarding `prId` sanitization:
|
28
|
+
```typescript
|
29
|
+
// src/commands/reviewCommand.ts
|
30
|
+
// ...
|
31
|
+
// TODO sanitize prId
|
32
|
+
await review(`gth-PR-${prId}-review`, systemMessage.join('\n'), content.join('\n'));
|
33
|
+
```
|
34
|
+
If `prId` can be influenced by user input (e.g., from a command-line argument that might not be strictly numeric or could contain path characters), it's crucial to sanitize it before using it in a filename. This prevents potential path traversal or other file system vulnerabilities. Please ensure `prId` is appropriately validated or sanitized.
|
35
|
+
|
36
|
+
* ✅ **Refactoring of `reviewInner` and `askQuestionInner`:** The logic previously in these internal functions has been effectively moved to the generic `llmUtils.invoke` function. This is a good simplification.
|
37
|
+
|
38
|
+
* ✅ **File Reading Utilities:** The new `readFileFromCurrentOrInstallDir` utility in `src/utils.ts` is a good addition for robustly loading configuration/prompt files.
|
39
|
+
|
40
|
+
* ⚠️ **Nitpick (Minor):** In `src/modules/questionAnsweringModule.ts`, the comment:
|
41
|
+
```typescript
|
42
|
+
// TODO highlight LLM output with something like Prism.JS (maybe system emoj are enough ????????????)
|
43
|
+
```
|
44
|
+
The series of question marks makes it appear less formal than typical `TODO` comments. This is a minor point of style.
|
45
|
+
|
46
|
+
**Overall:**
|
47
|
+
|
48
|
+
The submitted changes are of high quality and represent a significant improvement in the codebase's structure, maintainability, and user experience. The refactoring to centralize LLM interaction is particularly noteworthy.
|
49
|
+
|
50
|
+
---
|
51
|
+
|
52
|
+
**Recommendation:**
|
53
|
+
|
54
|
+
✅ **I recommend approving this PR.**
|
55
|
+
|
56
|
+
The changes are largely excellent. The primary point to consider before merging is the `prId` sanitization mentioned above to ensure robustness against potentially malformed inputs. The other points are minor.
|