gaunt-sloth-assistant 0.0.3 → 0.0.7
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/README.md +65 -13
- package/RELEASE-HOWTO.md +12 -0
- package/ROADMAP.md +2 -0
- package/package.json +7 -2
- package/src/codeReview.js +3 -1
- package/src/utils.js +2 -2
package/README.md
CHANGED
@@ -2,42 +2,92 @@
|
|
2
2
|
Simplistic assistant helping to do code reviews from command line based on [Langchain.js](https://github.com/langchain-ai/langchainjs)
|
3
3
|
|
4
4
|
## Review PR
|
5
|
-
|
5
|
+
Review PR by PR number:
|
6
|
+
```shell
|
7
|
+
gsloth pr 42
|
8
|
+
```
|
6
9
|
Official [GitHub cli (gh)](https://cli.github.com/) should be installed
|
7
10
|
and authenticated to have access to your project.
|
8
11
|
|
9
|
-
|
12
|
+
Review providing markdown file with requirements and notes.
|
13
|
+
```shell
|
14
|
+
gsloth pr 42 -f PROJ-1234.md
|
15
|
+
```
|
10
16
|
Jira integration is in [ROADMAP](ROADMAP.md).
|
11
17
|
Currently, the easiest ***meaningful*** way to add jira description is to
|
12
18
|
open Jira XML with "Export XML" in jira and to copy `<description></description>` block.
|
13
19
|
This block contains HTML and AI understands it easily
|
14
20
|
(most importantly it understand nested lists like ul>li).
|
15
21
|
|
16
|
-
## Review Diff
|
17
|
-
|
18
|
-
|
22
|
+
## Review any Diff
|
23
|
+
```shell
|
24
|
+
git --no-pager diff origin/master...yourgitcommithash | gsloth review
|
25
|
+
```
|
26
|
+
(helpful to review a subset of PR)
|
27
|
+
|
28
|
+
Review current local changes:
|
29
|
+
```shell
|
30
|
+
git --no-pager diff | gsloth review
|
31
|
+
```
|
19
32
|
|
20
33
|
## Question Answering
|
21
|
-
|
34
|
+
```shell
|
35
|
+
gsloth ask "which types of primitives are available in JavaScript?"
|
36
|
+
```
|
22
37
|
|
23
|
-
|
38
|
+
```shell
|
39
|
+
gsloth ask "Please have a look at this file" -f index.js
|
40
|
+
```
|
24
41
|
|
25
42
|
## Installation
|
26
|
-
|
43
|
+
|
44
|
+
Tested with Node 22 LTS.
|
45
|
+
|
46
|
+
## NPM
|
47
|
+
```shell
|
48
|
+
npm install gaunt-sloth-assistant -g
|
27
49
|
```
|
50
|
+
|
51
|
+
## GitHub (master)
|
52
|
+
|
53
|
+
```shell
|
28
54
|
git clone https://github.com/andruhon/gaunt-sloth.git
|
29
55
|
npm install
|
30
56
|
npm install -g ./
|
31
57
|
```
|
32
58
|
|
33
59
|
## Configuration
|
34
|
-
|
60
|
+
Go to your project directory and init sloth with vendor of your choice.
|
35
61
|
|
36
|
-
|
37
|
-
|
62
|
+
### Google Vertex AI
|
63
|
+
```shell
|
64
|
+
cd ./your-project
|
65
|
+
gsloth init vertexai
|
66
|
+
gcloud auth login
|
67
|
+
gcloud auth application-default login
|
68
|
+
```
|
69
|
+
|
70
|
+
### Anthropic
|
71
|
+
```shell
|
72
|
+
cd ./your-project
|
73
|
+
gsloth init anthropic
|
74
|
+
```
|
75
|
+
Make sure you edit `.gsloth.config.js` and set up your key.
|
76
|
+
|
77
|
+
### Further configuration
|
78
|
+
|
79
|
+
Currently only vertexai and anthropic can be configured with `gsloth init`.
|
80
|
+
|
81
|
+
Populate `.gsloth.preamble.review.md` with your project details and quality requirements.
|
82
|
+
Proper preamble is a paramount for good inference.
|
38
83
|
Check [.gsloth.preamble.review.md](.gsloth.preamble.review.md) for example.
|
39
84
|
|
40
|
-
|
85
|
+
### Manual configuration.
|
86
|
+
Your project should have the following files in order for gsloth to function:
|
87
|
+
- `.gsloth.config.js`
|
88
|
+
- `.gsloth.preamble.review.md`
|
89
|
+
|
90
|
+
Global configuration to invoke gsloth anywhere is in [ROADMAP](ROADMAP.md).
|
41
91
|
|
42
92
|
**Example of .gsloth.config.js for Anthropic**
|
43
93
|
```javascript
|
@@ -53,7 +103,6 @@ export async function configure(importFunction, global) {
|
|
53
103
|
})
|
54
104
|
};
|
55
105
|
}
|
56
|
-
|
57
106
|
```
|
58
107
|
|
59
108
|
**Example of .gsloth.config.js for VertexAI**
|
@@ -78,6 +127,9 @@ export async function configure(importFunction, global) {
|
|
78
127
|
}
|
79
128
|
```
|
80
129
|
|
130
|
+
The configure function should simply return instance of langchain [chat model](https://v03.api.js.langchain.com/classes/_langchain_core.language_models_chat_models.BaseChatModel.html).
|
131
|
+
See [Langchain documentation](https://js.langchain.com/docs/tutorials/llm_chain/) for more details.
|
132
|
+
|
81
133
|
## License
|
82
134
|
License is [MIT](https://opensource.org/license/mit). See [LICENSE](LICENSE)
|
83
135
|
|
package/RELEASE-HOWTO.md
ADDED
package/ROADMAP.md
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
Doing the following below and making it work stably should be sufficient to call it version 1.
|
6
6
|
|
7
7
|
### Add tests and gain reasonable coverage
|
8
|
+
### Configure eslint for code quality checks
|
9
|
+
### Automate release process
|
8
10
|
### Add project init command
|
9
11
|
Add a command to init certain model in certain project, for example `gsloth init gemini`
|
10
12
|
or `gsloth init` and select one of the provided options.
|
package/package.json
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"name": "gaunt-sloth-assistant",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
4
4
|
"description": "",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Andrew Kondratev",
|
7
7
|
"type": "module",
|
8
8
|
"main": "index.js",
|
9
|
+
"repository": "github:andruhon/gaunt-sloth-assistant",
|
10
|
+
"engines": {
|
11
|
+
"node": ">=22.0.0",
|
12
|
+
"npm": ">=10.9.0"
|
13
|
+
},
|
9
14
|
"scripts": {
|
10
15
|
"test": "echo \"Error: no test specified\" && exit 1",
|
11
16
|
"test-run": "node --trace-deprecation index.js ask \"status check\""
|
@@ -18,7 +23,7 @@
|
|
18
23
|
"@langchain/anthropic": "^0.3.17",
|
19
24
|
"@langchain/core": "^0.3.43",
|
20
25
|
"@langchain/google-vertexai": "^0.2.3",
|
21
|
-
"@langchain/langgraph": "^0.2.
|
26
|
+
"@langchain/langgraph": "^0.2.64",
|
22
27
|
"@types/node": "^22.14.1",
|
23
28
|
"chalk": "^5.4.1",
|
24
29
|
"commander": "^13.1.0",
|
package/src/codeReview.js
CHANGED
@@ -49,14 +49,16 @@ export async function review(source, preamble, diff) {
|
|
49
49
|
];
|
50
50
|
|
51
51
|
process.stdout.write("Reviewing.");
|
52
|
+
// TODO create proper progress indicator for async tasks.
|
52
53
|
const progress = setInterval(() => process.stdout.write('.'), 1000);
|
53
54
|
const output = await app.invoke({messages}, slothContext.session);
|
54
55
|
const filePath = path.resolve(process.cwd(), toFileSafeString(source)+'-'+fileSafeLocalDate()+".md");
|
56
|
+
process.stdout.write("\n");
|
55
57
|
display(`writing ${filePath}`);
|
56
58
|
// FIXME this looks ugly, there should be other way
|
57
59
|
const outputContent = output.messages[output.messages.length - 1].content;
|
58
60
|
clearInterval(progress);
|
59
|
-
|
61
|
+
process.stdout.write("\n");
|
60
62
|
// TODO highlight LLM output with something like Prism.JS (maybe system emoj are enough ✅⚠️❌)
|
61
63
|
display(outputContent);
|
62
64
|
try {
|
package/src/utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import {display, displayError, displaySuccess, displayWarning} from "./consoleUtils.js";
|
2
2
|
import {existsSync, readFileSync, writeFileSync} from "node:fs";
|
3
|
-
import {slothContext
|
3
|
+
import {slothContext} from "./config.js";
|
4
4
|
import {resolve} from "node:path";
|
5
5
|
import {spawn} from "node:child_process";
|
6
6
|
|
@@ -63,7 +63,7 @@ export function readStdin(program) {
|
|
63
63
|
}
|
64
64
|
});
|
65
65
|
process.stdin.on('end', function() {
|
66
|
-
|
66
|
+
process.stdout.write('.\n');
|
67
67
|
program.parse(process.argv);
|
68
68
|
});
|
69
69
|
}
|