gaunt-sloth-assistant 0.5.3 → 0.6.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.chat.md +11 -0
- package/.gsloth.code.md +19 -0
- package/README.md +20 -52
- package/assets/release-notes/v0_6_0.md +44 -0
- package/dist/commands/chatCommand.js +12 -2
- package/dist/commands/chatCommand.js.map +1 -1
- package/dist/commands/codeCommand.d.ts +6 -0
- package/dist/commands/codeCommand.js +92 -0
- package/dist/commands/codeCommand.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/llmUtils.d.ts +1 -1
- package/dist/llmUtils.js.map +1 -1
- package/dist/prompt.d.ts +2 -0
- package/dist/prompt.js +7 -1
- package/dist/prompt.js.map +1 -1
- package/docs/COMMANDS.md +231 -0
- package/docs/CONFIGURATION.md +3 -0
- package/index.js +10 -1
- package/package.json +1 -1
- package/src/commands/chatCommand.ts +12 -2
- package/src/commands/codeCommand.ts +106 -0
- package/src/config.ts +6 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +2 -0
- package/src/llmUtils.ts +1 -1
- package/src/prompt.ts +14 -1
- package/vitest-it.config.ts +1 -1
package/.gsloth.chat.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Chat Mode Instructions
|
|
2
|
+
|
|
3
|
+
You are a helpful AI assistant engaged in a conversational chat session. Your role is to:
|
|
4
|
+
|
|
5
|
+
- Provide informative, accurate, and helpful responses to user queries
|
|
6
|
+
- Maintain context throughout the conversation
|
|
7
|
+
- Be conversational and friendly while remaining professional
|
|
8
|
+
- Ask clarifying questions when needed to better understand the user's intent
|
|
9
|
+
- Provide examples and explanations when appropriate
|
|
10
|
+
|
|
11
|
+
Remember that this is an interactive chat session, so keep your responses concise and engaging. Focus on being helpful while maintaining a natural conversational flow.
|
package/.gsloth.code.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Code Mode Instructions
|
|
2
|
+
|
|
3
|
+
You are an AI coding assistant with full file system access within the user's project. Your role is to:
|
|
4
|
+
|
|
5
|
+
- Help write, modify, and debug code
|
|
6
|
+
- Understand and work with the existing codebase
|
|
7
|
+
- Follow project conventions and best practices
|
|
8
|
+
- Create, read, update, and delete files as needed to complete coding tasks
|
|
9
|
+
- Run commands and scripts to test and validate changes
|
|
10
|
+
- Provide clear explanations of the changes you make
|
|
11
|
+
|
|
12
|
+
You have access to the entire project directory and can:
|
|
13
|
+
- Navigate the file system
|
|
14
|
+
- Read and analyze existing code
|
|
15
|
+
- Make modifications to implement features or fix bugs
|
|
16
|
+
- Create new files and directories as needed
|
|
17
|
+
- Execute commands to build, test, or run the project
|
|
18
|
+
|
|
19
|
+
Focus on writing clean, maintainable code that follows the project's established patterns and conventions. Always test your changes when possible and explain what you're doing and why.
|
package/README.md
CHANGED
|
@@ -41,79 +41,47 @@ Unlike proprietary solutions that restrict you to a single AI provider, Gaunt Sl
|
|
|
41
41
|
- Anthropic;
|
|
42
42
|
- Groq.
|
|
43
43
|
|
|
44
|
-
##
|
|
44
|
+
## Commands Overview
|
|
45
45
|
|
|
46
46
|
`gth` and `gsloth` commands are used interchangeably, both `gsloth pr 42` and `gth pr 42` do the same thing.
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
To review PR by PR number:
|
|
48
|
+
For detailed information about all commands, see [docs/COMMANDS.md](./docs/COMMANDS.md).
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
and authenticated to have access to your project.
|
|
50
|
+
### Available Commands:
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
- **`init`** - Initialize Gaunt Sloth in your project with a specific AI provider
|
|
53
|
+
- **`pr`** - ⚠️ This feature requires GitHub CLI to be installed. Review pull requests with optional requirement integration (GitHub issues or Jira).
|
|
54
|
+
- **`review`** - Review any diff or content from various sources
|
|
55
|
+
- **`ask`** - Ask questions about code or programming topics
|
|
56
|
+
- **`chat`** - Start an interactive chat session
|
|
57
|
+
- **`code`** - Write code interactively with full project context
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
### Quick Examples:
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
this means that the branch of reviewed PR should be checked out, otherwise Sloth might get confused.
|
|
60
|
-
If you are typically review PRs without checking them out and looking at diff only is enough,
|
|
61
|
-
consider setting pr.filesystem to 'none' in your config.
|
|
62
|
-
|
|
63
|
-
```shell
|
|
64
|
-
gsloth pr 42
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Review PR providing a markdown file with requirements and notes.
|
|
61
|
+
**Initialize project:**
|
|
68
62
|
```shell
|
|
69
|
-
gsloth
|
|
63
|
+
gsloth init anthropic
|
|
70
64
|
```
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
The command syntax is `gsloth pr <prId> [githubIssueId]`. For example, to review PR #42 and include GitHub issue #23 as requirements:
|
|
75
|
-
|
|
66
|
+
**Review PR with requirements:**
|
|
76
67
|
```shell
|
|
77
|
-
gsloth pr 42
|
|
68
|
+
gsloth pr 42 23 # Review PR #42 with GitHub issue #23
|
|
78
69
|
```
|
|
79
70
|
|
|
80
|
-
**
|
|
81
|
-
|
|
82
|
-
1. Make sure the official [GitHub CLI (gh)](https://cli.github.com/) is installed and authenticated
|
|
83
|
-
2. Ensure you have access to the repository's issues
|
|
84
|
-
|
|
85
|
-
No further configuration is needed! Gaunt Sloth will automatically fetch the GitHub issue content using the GitHub CLI.
|
|
86
|
-
|
|
87
|
-
The project review preamble can be modified to reject a pull request immediately if it appears to implement something different from what was requested in the requirements.
|
|
88
|
-
|
|
89
|
-
Gaunt Sloth also supports JIRA integration as an alternative requirements provider.
|
|
90
|
-
For more information on **JIRA** setup and other configuration options, see [CONFIGURATION.md#jira](./docs/CONFIGURATION.md#jira).
|
|
91
|
-
|
|
92
|
-
### Review any Diff
|
|
93
|
-
|
|
94
|
-
Review current local changes:
|
|
71
|
+
**Review local changes:**
|
|
95
72
|
```shell
|
|
96
73
|
git --no-pager diff | gsloth review
|
|
97
74
|
```
|
|
98
75
|
|
|
76
|
+
**Ask questions:**
|
|
99
77
|
```shell
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
(helpful to review a subset of PR)
|
|
103
|
-
|
|
104
|
-
### Question Answering
|
|
105
|
-
```shell
|
|
106
|
-
gsloth ask "which types of primitives are available in JavaScript?"
|
|
78
|
+
gsloth ask "What does this function do?" -f utils.js
|
|
107
79
|
```
|
|
108
80
|
|
|
81
|
+
**Interactive sessions:**
|
|
109
82
|
```shell
|
|
110
|
-
gsloth
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Multiple files may be provided as well
|
|
114
|
-
|
|
115
|
-
```shell
|
|
116
|
-
gsloth ask "Please have a look at these files" -f index.js test.js
|
|
83
|
+
gsloth chat # Start chat session
|
|
84
|
+
gsloth code # Start coding session
|
|
117
85
|
```
|
|
118
86
|
|
|
119
87
|
## Installation
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# v0.6.0 Interactive Code Command
|
|
2
|
+
|
|
3
|
+
## New Features
|
|
4
|
+
|
|
5
|
+
### Interactive Code Command
|
|
6
|
+
- Added new `code` command for interactive coding sessions with enhanced project awareness
|
|
7
|
+
- Features:
|
|
8
|
+
- Full file system read access within your project for better context
|
|
9
|
+
- Interactive coding sessions with conversation memory
|
|
10
|
+
- Code-specific prompts and guidelines for optimal code generation
|
|
11
|
+
- Session history saved to `.gsloth/gth_<timestamp>_CODE.md` files
|
|
12
|
+
- Clean exit with 'exit' command or Ctrl+C
|
|
13
|
+
- Automatic streaming disabled for better interactive experience
|
|
14
|
+
|
|
15
|
+
### Command Improvements
|
|
16
|
+
- Both `chat` and `code` commands now use system prompts for better responses
|
|
17
|
+
- Enhanced prompt loading with dedicated `readCodePrompt()` and `readChatPrompt()` functions
|
|
18
|
+
- Improved separation of concerns between chat (general assistance) and code (development tasks)
|
|
19
|
+
|
|
20
|
+
## Documentation
|
|
21
|
+
|
|
22
|
+
### New Documentation Structure
|
|
23
|
+
- Created comprehensive `docs/COMMANDS.md` with detailed information about all commands
|
|
24
|
+
- Restructured README.md to provide concise command overview with link to detailed documentation
|
|
25
|
+
- Updated `docs/CONFIGURATION.md` to include configuration options for new commands
|
|
26
|
+
|
|
27
|
+
### Documentation Updates
|
|
28
|
+
- Added clear descriptions for all six available commands: `init`, `pr`, `review`, `ask`, `chat`, and `code`
|
|
29
|
+
- Included examples and use cases for each command
|
|
30
|
+
- Documented command-specific configuration options
|
|
31
|
+
- Added information about output file locations and naming conventions
|
|
32
|
+
|
|
33
|
+
## Technical Improvements
|
|
34
|
+
- Consistent command structure across chat and code commands
|
|
35
|
+
- Better error handling in interactive sessions
|
|
36
|
+
- Improved module organization with dedicated prompt reading functions
|
|
37
|
+
|
|
38
|
+
## Breaking Changes
|
|
39
|
+
- None
|
|
40
|
+
|
|
41
|
+
## Upgrade Notes
|
|
42
|
+
- The new `code` command is available immediately after upgrade
|
|
43
|
+
- No configuration changes required for existing installations
|
|
44
|
+
- All existing commands continue to work as before
|
|
@@ -8,6 +8,7 @@ import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
|
8
8
|
import { createInterface, error, exit, stdin as input, stdout as output, } from '#src/systemUtils.js';
|
|
9
9
|
import { getGslothFilePath } from '#src/filePathUtils.js';
|
|
10
10
|
import { generateStandardFileName, appendToFile } from '#src/utils.js';
|
|
11
|
+
import { readBackstory, readGuidelines, readSystemPrompt, readChatPrompt } from '#src/prompt.js';
|
|
11
12
|
export function chatCommand(program) {
|
|
12
13
|
program
|
|
13
14
|
.command('chat')
|
|
@@ -27,7 +28,16 @@ export function chatCommand(program) {
|
|
|
27
28
|
const processMessage = async (userInput) => {
|
|
28
29
|
const messages = [];
|
|
29
30
|
if (isFirstMessage) {
|
|
30
|
-
|
|
31
|
+
const systemPromptParts = [readBackstory(), readGuidelines(config.projectGuidelines)];
|
|
32
|
+
const chatPrompt = readChatPrompt();
|
|
33
|
+
if (chatPrompt) {
|
|
34
|
+
systemPromptParts.push(chatPrompt);
|
|
35
|
+
}
|
|
36
|
+
const systemPrompt = readSystemPrompt();
|
|
37
|
+
if (systemPrompt) {
|
|
38
|
+
systemPromptParts.push(systemPrompt);
|
|
39
|
+
}
|
|
40
|
+
messages.push(new SystemMessage(systemPromptParts.join('\n')));
|
|
31
41
|
}
|
|
32
42
|
messages.push(new HumanMessage(userInput));
|
|
33
43
|
const runConfig = {
|
|
@@ -63,7 +73,7 @@ export function chatCommand(program) {
|
|
|
63
73
|
await processMessage(message);
|
|
64
74
|
}
|
|
65
75
|
else {
|
|
66
|
-
display(
|
|
76
|
+
display('\nGaunt Sloth is ready to chat. Type your prompt.');
|
|
67
77
|
display(chalk.gray("Type 'exit' or hit Ctrl+C to exit chat\n"));
|
|
68
78
|
}
|
|
69
79
|
if (!shouldExit)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatCommand.js","sourceRoot":"","sources":["../../src/commands/chatCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAoB,MAAM,0BAA0B,CAAC;AACzF,OAAO,EACL,eAAe,EACf,KAAK,EACL,IAAI,EACJ,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EA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AO,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;YACvC,IAAI,CAAC,CAAC,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { initConfig } from '#src/config.js';
|
|
2
|
+
import { display } from '#src/consoleUtils.js';
|
|
3
|
+
import { invoke } from '#src/llmUtils.js';
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { MemorySaver } from '@langchain/langgraph';
|
|
7
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
8
|
+
import { createInterface, error, exit, stdin as input, stdout as output, } from '#src/systemUtils.js';
|
|
9
|
+
import { getGslothFilePath } from '#src/filePathUtils.js';
|
|
10
|
+
import { generateStandardFileName, appendToFile } from '#src/utils.js';
|
|
11
|
+
import { readBackstory, readGuidelines, readSystemPrompt, readCodePrompt } from '#src/prompt.js';
|
|
12
|
+
/**
|
|
13
|
+
* Adds the code command to the program
|
|
14
|
+
* @param program - The commander program
|
|
15
|
+
*/
|
|
16
|
+
export function codeCommand(program) {
|
|
17
|
+
program
|
|
18
|
+
.command('code')
|
|
19
|
+
.description('Interactively write code with sloth (has full file system access within your project)')
|
|
20
|
+
.argument('[message]', 'Initial message to start the code session')
|
|
21
|
+
.action(async (message) => {
|
|
22
|
+
try {
|
|
23
|
+
// Force streaming Off for code, it does not play nicely with the input interface
|
|
24
|
+
const config = { ...(await initConfig()), streamOutput: false };
|
|
25
|
+
const checkpointSaver = new MemorySaver();
|
|
26
|
+
const rl = createInterface({ input, output });
|
|
27
|
+
let isFirstMessage = true;
|
|
28
|
+
let shouldExit = false;
|
|
29
|
+
const thread_id = uuidv4();
|
|
30
|
+
const codeLogFileName = getGslothFilePath(generateStandardFileName('CODE'));
|
|
31
|
+
display(chalk.gray(`Code session will be logged to ${codeLogFileName}\n`));
|
|
32
|
+
const processMessage = async (userInput) => {
|
|
33
|
+
const messages = [];
|
|
34
|
+
if (isFirstMessage) {
|
|
35
|
+
const systemPromptParts = [readBackstory(), readGuidelines(config.projectGuidelines)];
|
|
36
|
+
const codePrompt = readCodePrompt();
|
|
37
|
+
if (codePrompt) {
|
|
38
|
+
systemPromptParts.push(codePrompt);
|
|
39
|
+
}
|
|
40
|
+
const systemPrompt = readSystemPrompt();
|
|
41
|
+
if (systemPrompt) {
|
|
42
|
+
systemPromptParts.push(systemPrompt);
|
|
43
|
+
}
|
|
44
|
+
messages.push(new SystemMessage(systemPromptParts.join('\n')));
|
|
45
|
+
}
|
|
46
|
+
messages.push(new HumanMessage(userInput));
|
|
47
|
+
const runConfig = {
|
|
48
|
+
configurable: { thread_id },
|
|
49
|
+
};
|
|
50
|
+
const aiResponse = await invoke('code', messages, config, runConfig, checkpointSaver);
|
|
51
|
+
const logEntry = `## User\n\n${userInput}\n\n## Assistant\n\n${aiResponse}\n\n`;
|
|
52
|
+
appendToFile(codeLogFileName, logEntry);
|
|
53
|
+
isFirstMessage = false;
|
|
54
|
+
};
|
|
55
|
+
const askQuestion = () => {
|
|
56
|
+
rl.question(chalk.magenta(' > '), async (userInput) => {
|
|
57
|
+
if (userInput.toLowerCase() === 'exit') {
|
|
58
|
+
rl.close();
|
|
59
|
+
shouldExit = true;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (isFirstMessage && !userInput.trim()) {
|
|
63
|
+
rl.close();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!userInput.trim()) {
|
|
67
|
+
rl.close();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await processMessage(userInput);
|
|
71
|
+
display(chalk.gray("Type 'exit' or hit Ctrl+C to exit code session\n"));
|
|
72
|
+
if (!shouldExit)
|
|
73
|
+
askQuestion();
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
if (message) {
|
|
77
|
+
await processMessage(message);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
display('\nGaunt Sloth is ready to code. Type your prompt.');
|
|
81
|
+
display(chalk.gray("Type 'exit' or hit Ctrl+C to exit code session\n"));
|
|
82
|
+
}
|
|
83
|
+
if (!shouldExit)
|
|
84
|
+
askQuestion();
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
error(`Error in code command: ${err}`);
|
|
88
|
+
exit(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=codeCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeCommand.js","sourceRoot":"","sources":["../../src/commands/codeCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAoB,MAAM,0BAA0B,CAAC;AACzF,OAAO,EACL,eAAe,EACf,KAAK,EACL,IAAI,EACJ,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjG;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC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,CAAC;YAEF,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,mDAAmD,CAAC,CAAC;gBAC7D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC,CAAC;YAC1E,CAAC;YACD,IAAI,CAAC,UAAU;gBAAE,WAAW,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;YACvC,IAAI,CAAC,CAAC,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -43,6 +43,9 @@ interface BaseSlothConfig {
|
|
|
43
43
|
chat?: {
|
|
44
44
|
filesystem?: string[] | 'all' | 'none';
|
|
45
45
|
};
|
|
46
|
+
code?: {
|
|
47
|
+
filesystem?: string[] | 'all' | 'none';
|
|
48
|
+
};
|
|
46
49
|
};
|
|
47
50
|
requirementsProviderConfig?: Record<string, unknown>;
|
|
48
51
|
contentProviderConfig?: Record<string, unknown>;
|
package/dist/config.js
CHANGED
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;AAE1F,OAAO,EAC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IG;IACH,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;CAexB,CAAC;IAEA,gCAAgC,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IACrE,gCAAgC,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,aAAmC;IACtD,MAAM,MAAM,GAAG,aAA4B,CAAC;IAC5C,OAAO;QACL,GAAG,cAAc;QACjB,GAAG,MAAM;QACT,QAAQ,EAAE,EAAE,GAAG,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC,EAAE;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"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,3 +5,5 @@ export declare const GSLOTH_BACKSTORY = ".gsloth.backstory.md";
|
|
|
5
5
|
export declare const PROJECT_GUIDELINES = ".gsloth.guidelines.md";
|
|
6
6
|
export declare const PROJECT_REVIEW_INSTRUCTIONS = ".gsloth.review.md";
|
|
7
7
|
export declare const GSLOTH_SYSTEM_PROMPT = ".gsloth.system.md";
|
|
8
|
+
export declare const GSLOTH_CHAT_PROMPT = ".gsloth.chat.md";
|
|
9
|
+
export declare const GSLOTH_CODE_PROMPT = ".gsloth.code.md";
|
package/dist/constants.js
CHANGED
|
@@ -5,4 +5,6 @@ export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
|
|
|
5
5
|
export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
|
|
6
6
|
export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
|
|
7
7
|
export const GSLOTH_SYSTEM_PROMPT = '.gsloth.system.md';
|
|
8
|
+
export const GSLOTH_CHAT_PROMPT = '.gsloth.chat.md';
|
|
9
|
+
export const GSLOTH_CODE_PROMPT = '.gsloth.code.md';
|
|
8
10
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +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"}
|
|
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;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { initCommand } from '#src/commands/initCommand.js';
|
|
|
4
4
|
import { reviewCommand } from '#src/commands/reviewCommand.js';
|
|
5
5
|
import { prCommand } from '#src/commands/prCommand.js';
|
|
6
6
|
import { chatCommand } from '#src/commands/chatCommand.js';
|
|
7
|
+
import { codeCommand } from '#src/commands/codeCommand.js';
|
|
7
8
|
import { getSlothVersion } from '#src/utils.js';
|
|
8
9
|
import { argv, readStdin } from '#src/systemUtils.js';
|
|
9
10
|
import { setVerbose } from '#src/llmUtils.js';
|
|
@@ -25,5 +26,6 @@ reviewCommand(program);
|
|
|
25
26
|
prCommand(program);
|
|
26
27
|
askCommand(program);
|
|
27
28
|
chatCommand(program);
|
|
29
|
+
codeCommand(program);
|
|
28
30
|
await readStdin(program);
|
|
29
31
|
//# sourceMappingURL=index.js.map
|
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,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,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;AAE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AAmD;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,WAAW,CAAC,OAAO,CAAC,CAAC;AACrB,WAAW,CAAC,OAAO,CAAC,CAAC;AAErB,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/llmUtils.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { Message } from '#src/modules/types.js';
|
|
|
2
2
|
import { SlothConfig } from '#src/config.js';
|
|
3
3
|
import { type RunnableConfig } from '@langchain/core/runnables';
|
|
4
4
|
import { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
5
|
-
export declare function invoke(command: 'ask' | 'pr' | 'review' | 'chat' | undefined, messages: Message[], config: SlothConfig, runConfig?: RunnableConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<string>;
|
|
5
|
+
export declare function invoke(command: 'ask' | 'pr' | 'review' | 'chat' | 'code' | undefined, messages: Message[], config: SlothConfig, runConfig?: RunnableConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<string>;
|
|
6
6
|
export declare function setVerbose(debug: boolean): void;
|
package/dist/llmUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llmUtils.js","sourceRoot":"","sources":["../src/llmUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WA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ACH,CAAC"}
|
package/dist/prompt.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export declare function readBackstory(): string;
|
|
|
2
2
|
export declare function readGuidelines(guidelinesFilename: string): string;
|
|
3
3
|
export declare function readReviewInstructions(reviewInstructions: string): string;
|
|
4
4
|
export declare function readSystemPrompt(): string;
|
|
5
|
+
export declare function readChatPrompt(): string;
|
|
6
|
+
export declare function readCodePrompt(): string;
|
|
5
7
|
/**
|
|
6
8
|
* This function expects https://cli.github.com/ to be installed and authenticated.
|
|
7
9
|
* It does something like `gh pr diff 42`
|
package/dist/prompt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileFromCurrentDir, readFileFromCurrentOrInstallDir, spawnCommand, } from '#src/utils.js';
|
|
2
2
|
import { displayError } from '#src/consoleUtils.js';
|
|
3
3
|
import { exit } from '#src/systemUtils.js';
|
|
4
|
-
import { GSLOTH_BACKSTORY, GSLOTH_SYSTEM_PROMPT } from '#src/constants.js';
|
|
4
|
+
import { GSLOTH_BACKSTORY, GSLOTH_SYSTEM_PROMPT, GSLOTH_CHAT_PROMPT, GSLOTH_CODE_PROMPT, } from '#src/constants.js';
|
|
5
5
|
import { getGslothConfigReadPath } from '#src/filePathUtils.js';
|
|
6
6
|
export function readBackstory() {
|
|
7
7
|
return readFileFromCurrentOrInstallDir(GSLOTH_BACKSTORY, true);
|
|
@@ -22,6 +22,12 @@ export function readReviewInstructions(reviewInstructions) {
|
|
|
22
22
|
export function readSystemPrompt() {
|
|
23
23
|
return readFileFromCurrentOrInstallDir(GSLOTH_SYSTEM_PROMPT, true);
|
|
24
24
|
}
|
|
25
|
+
export function readChatPrompt() {
|
|
26
|
+
return readFileFromCurrentOrInstallDir(GSLOTH_CHAT_PROMPT, true);
|
|
27
|
+
}
|
|
28
|
+
export function readCodePrompt() {
|
|
29
|
+
return readFileFromCurrentOrInstallDir(GSLOTH_CODE_PROMPT, true);
|
|
30
|
+
}
|
|
25
31
|
function readConfigPromptFile(guidelinesFilename) {
|
|
26
32
|
try {
|
|
27
33
|
const filePath = getGslothConfigReadPath(guidelinesFilename);
|
package/dist/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,UAAU,aAAa;IAC3B,OAAO,+BAA+B,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,kBAA0B;IACvD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;QAC7D,OAAO,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,YAAY,CACV,mGAAmG,CACpG,CAAC;QACF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,kBAA0B;IAC/D,OAAO,oBAAoB,CAAC,k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ed information about all available commands in Gaunt Sloth Assistant.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Gaunt Sloth Assistant provides several commands to help with code review, analysis, and interaction. All commands can be executed using either `gsloth` or `gth`.
|
|
8
|
+
|
|
9
|
+
## init
|
|
10
|
+
|
|
11
|
+
Initialize Gaunt Sloth Assistant in your project.
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
gsloth init <type>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Arguments
|
|
18
|
+
- `<type>` - Configuration type. Available options: `vertexai`, `anthropic`, `groq`
|
|
19
|
+
|
|
20
|
+
### Description
|
|
21
|
+
Creates the necessary configuration files for your project:
|
|
22
|
+
- `.gsloth.config.js`, `.gsloth.config.json`, or `.gsloth.config.mjs` - Configuration file
|
|
23
|
+
- `.gsloth.guidelines.md` - Project guidelines file
|
|
24
|
+
|
|
25
|
+
### Examples
|
|
26
|
+
```shell
|
|
27
|
+
gsloth init vertexai
|
|
28
|
+
gsloth init anthropic
|
|
29
|
+
gsloth init groq
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## pr
|
|
33
|
+
|
|
34
|
+
Review a Pull Request in the current directory.
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
gsloth pr <prId> [requirementsId]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Arguments
|
|
41
|
+
- `<prId>` - Pull request ID to review (required)
|
|
42
|
+
- `[requirementsId]` - Optional requirements ID to retrieve requirements from provider
|
|
43
|
+
|
|
44
|
+
### Options
|
|
45
|
+
- `-p, --requirements-provider <provider>` - Requirements provider for this review
|
|
46
|
+
- `-f, --file [files...]` - Input files to add before the diff
|
|
47
|
+
|
|
48
|
+
### Prerequisites
|
|
49
|
+
- GitHub CLI (`gh`) must be installed and authenticated
|
|
50
|
+
- For optimal reviews, the PR branch should be checked out locally
|
|
51
|
+
|
|
52
|
+
### Description
|
|
53
|
+
Reviews a pull request using GitHub as the default content provider. Can integrate with issue tracking systems to include requirements in the review.
|
|
54
|
+
|
|
55
|
+
### Examples
|
|
56
|
+
```shell
|
|
57
|
+
# Review PR #42
|
|
58
|
+
gsloth pr 42
|
|
59
|
+
|
|
60
|
+
# Review PR #42 with GitHub issue #23 as requirements
|
|
61
|
+
gsloth pr 42 23
|
|
62
|
+
|
|
63
|
+
# Review PR #42 with JIRA issue PROJ-123
|
|
64
|
+
gsloth pr 42 PROJ-123 -p jira
|
|
65
|
+
|
|
66
|
+
# Review PR #42 with additional context from files
|
|
67
|
+
gsloth pr 42 -f architecture.md notes.txt
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## review
|
|
71
|
+
|
|
72
|
+
Review any diff or content provided via stdin, files, or content providers.
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
gsloth review [contentId]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Arguments
|
|
79
|
+
- `[contentId]` - Optional content ID to retrieve content from provider
|
|
80
|
+
|
|
81
|
+
### Options
|
|
82
|
+
- `-f, --file [files...]` - Input files to add before the content
|
|
83
|
+
- `-r, --requirements <requirements>` - Requirements for this review
|
|
84
|
+
- `-p, --requirements-provider <provider>` - Requirements provider
|
|
85
|
+
- `--content-provider <provider>` - Content provider
|
|
86
|
+
- `-m, --message <message>` - Extra message to provide before the content
|
|
87
|
+
|
|
88
|
+
### Description
|
|
89
|
+
Flexible review command that can process content from various sources including stdin, files, or configured providers.
|
|
90
|
+
|
|
91
|
+
### Examples
|
|
92
|
+
```shell
|
|
93
|
+
# Review current git changes
|
|
94
|
+
git --no-pager diff | gsloth review
|
|
95
|
+
|
|
96
|
+
# Review specific commit range
|
|
97
|
+
git --no-pager diff origin/main...feature-branch | gsloth review
|
|
98
|
+
|
|
99
|
+
# Review with requirements file
|
|
100
|
+
gsloth review -r requirements.md
|
|
101
|
+
|
|
102
|
+
# Review with custom message
|
|
103
|
+
git diff | gsloth review -m "Please focus on security implications"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## ask
|
|
107
|
+
|
|
108
|
+
Ask questions about code or general programming topics.
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
gsloth ask [message]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Arguments
|
|
115
|
+
- `[message]` - The question or message
|
|
116
|
+
|
|
117
|
+
### Options
|
|
118
|
+
- `-f, --file [files...]` - Input files to include with the question
|
|
119
|
+
|
|
120
|
+
### Description
|
|
121
|
+
Ask questions with optional file context. At least one input source (message, file, or stdin) is required.
|
|
122
|
+
|
|
123
|
+
### Examples
|
|
124
|
+
```shell
|
|
125
|
+
# Ask a general question
|
|
126
|
+
gsloth ask "which types of primitives are available in JavaScript?"
|
|
127
|
+
|
|
128
|
+
# Ask about a specific file
|
|
129
|
+
gsloth ask "Please explain this code" -f index.js
|
|
130
|
+
|
|
131
|
+
# Ask about multiple files
|
|
132
|
+
gsloth ask "How do these modules interact?" -f module1.js module2.js
|
|
133
|
+
|
|
134
|
+
# Use with stdin
|
|
135
|
+
cat error.log | gsloth ask "What might be causing these errors?"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## chat
|
|
139
|
+
|
|
140
|
+
Start an interactive chat session with Gaunt Sloth.
|
|
141
|
+
|
|
142
|
+
```shell
|
|
143
|
+
gsloth chat [message]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Arguments
|
|
147
|
+
- `[message]` - Initial message to start the chat
|
|
148
|
+
|
|
149
|
+
### Description
|
|
150
|
+
Opens an interactive chat session where you can have a conversation with the AI. The session maintains context throughout the conversation. Chat history is saved to `.gsloth/CHAT_<timestamp>.md`.
|
|
151
|
+
|
|
152
|
+
### Features
|
|
153
|
+
- Interactive conversation with context memory
|
|
154
|
+
- Type 'exit' or press Ctrl+C to end the session
|
|
155
|
+
- Chat history automatically saved
|
|
156
|
+
- Streaming disabled for better interactive experience
|
|
157
|
+
|
|
158
|
+
### Examples
|
|
159
|
+
```shell
|
|
160
|
+
# Start a chat session
|
|
161
|
+
gsloth chat
|
|
162
|
+
|
|
163
|
+
# Start with an initial message
|
|
164
|
+
gsloth chat "Let's discuss the architecture of this project"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## code
|
|
168
|
+
|
|
169
|
+
Write code interactively with full file system access within your project.
|
|
170
|
+
|
|
171
|
+
```shell
|
|
172
|
+
gsloth code [message]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Arguments
|
|
176
|
+
- `[message]` - Initial message to start the code session
|
|
177
|
+
|
|
178
|
+
### Description
|
|
179
|
+
Opens an interactive coding session where the AI has full read access to your project files. This command is specifically designed for code writing tasks with enhanced context awareness. Code session history is saved to `gth_<timestamp>_CODE.md`.
|
|
180
|
+
|
|
181
|
+
### Features
|
|
182
|
+
- Full file system read access within project
|
|
183
|
+
- Interactive coding session with context memory
|
|
184
|
+
- Type 'exit' or press Ctrl+C to end the session
|
|
185
|
+
- Code history automatically saved
|
|
186
|
+
- Streaming disabled for better interactive experience
|
|
187
|
+
|
|
188
|
+
### Examples
|
|
189
|
+
```shell
|
|
190
|
+
# Start a code session
|
|
191
|
+
gsloth code
|
|
192
|
+
|
|
193
|
+
# Start with specific coding task
|
|
194
|
+
gsloth code "Help me refactor the authentication module"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Command-Specific Configuration
|
|
198
|
+
|
|
199
|
+
Commands can be configured individually in your configuration file. See [CONFIGURATION.md](./CONFIGURATION.md) for detailed configuration options.
|
|
200
|
+
|
|
201
|
+
### Example Configuration
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"llm": {
|
|
205
|
+
"type": "anthropic",
|
|
206
|
+
"model": "claude-3-5-sonnet-20241022"
|
|
207
|
+
},
|
|
208
|
+
"commands": {
|
|
209
|
+
"pr": {
|
|
210
|
+
"contentProvider": "github",
|
|
211
|
+
"requirementsProvider": "github"
|
|
212
|
+
},
|
|
213
|
+
"review": {
|
|
214
|
+
"contentProvider": "file",
|
|
215
|
+
"requirementsProvider": "file"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Output Files
|
|
222
|
+
|
|
223
|
+
All command outputs are saved as markdown files:
|
|
224
|
+
- If `.gsloth` directory exists: Files are saved to `.gsloth/`
|
|
225
|
+
- Otherwise: Files are saved to the project root
|
|
226
|
+
- File naming: `gth_<timestamp>_<COMMAND>.md` for interactive sessions (same as for other commands)
|
|
227
|
+
|
|
228
|
+
## Exit Codes
|
|
229
|
+
|
|
230
|
+
- `0` - Success
|
|
231
|
+
- `1` - Error occurred during command execution
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -54,9 +54,12 @@ It is always worth checking sourcecode in [config.ts](../src/config.ts) for more
|
|
|
54
54
|
| `commands.pr` | Optional | - | Configuration for the PR command. |
|
|
55
55
|
| `commands.pr.contentProvider` | Optional | `github` | Content provider used for PR review (`gsloth pr`). |
|
|
56
56
|
| `commands.pr.requirementsProvider` | Optional | `github` | Requirements provider used for PR review. If not specified, falls back to the global `requirementsProvider`. |
|
|
57
|
+
| `commands.pr.filesystem` | Optional | - | File system access configuration for PR command. Options: `'all'`, `'none'`, or specific file patterns for read-only access. |
|
|
57
58
|
| `commands.review` | Optional | - | Configuration for the review command. |
|
|
58
59
|
| `commands.review.contentProvider` | Optional | - | Content provider specifically for the review command. If not specified, falls back to the global `contentProvider`. |
|
|
59
60
|
| `commands.review.requirementsProvider` | Optional | - | Requirements provider specifically for the review command. If not specified, falls back to the global `requirementsProvider`. |
|
|
61
|
+
| `commands.chat` | Optional | - | Configuration for the chat command (interactive chat sessions). |
|
|
62
|
+
| `commands.code` | Optional | - | Configuration for the code command (interactive coding sessions with file system access). |
|
|
60
63
|
| `requirementsProviderConfig` | Optional | - | Configuration for requirements providers. Contains provider-specific configurations. |
|
|
61
64
|
| `requirementsProviderConfig.jira` | Optional | - | Configuration for the Jira requirements provider (Atlassian REST API v3 with Personal Access Token). |
|
|
62
65
|
| `requirementsProviderConfig.jira.username` | Optional | - | Jira username (email). Can also be set via JIRA_USERNAME environment variable. |
|
package/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Suppress deprecation warnings programmatically
|
|
4
|
+
process.removeAllListeners('warning');
|
|
5
|
+
process.on('warning', (warning) => {
|
|
6
|
+
if (warning.name === 'DeprecationWarning' || warning.name === 'ExperimentalWarning') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
console.warn(warning);
|
|
10
|
+
});
|
|
2
11
|
|
|
3
12
|
// This is a minimalistic entry point that sets the installDir in systemUtils
|
|
4
13
|
// and delegates to the compiled TypeScript code in dist/index.js
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
17
17
|
import { getGslothFilePath } from '#src/filePathUtils.js';
|
|
18
18
|
import { generateStandardFileName, appendToFile } from '#src/utils.js';
|
|
19
|
+
import { readBackstory, readGuidelines, readSystemPrompt, readChatPrompt } from '#src/prompt.js';
|
|
19
20
|
|
|
20
21
|
export function chatCommand(program: Command) {
|
|
21
22
|
program
|
|
@@ -38,7 +39,16 @@ export function chatCommand(program: Command) {
|
|
|
38
39
|
const processMessage = async (userInput: string) => {
|
|
39
40
|
const messages: BaseMessage[] = [];
|
|
40
41
|
if (isFirstMessage) {
|
|
41
|
-
|
|
42
|
+
const systemPromptParts = [readBackstory(), readGuidelines(config.projectGuidelines)];
|
|
43
|
+
const chatPrompt = readChatPrompt();
|
|
44
|
+
if (chatPrompt) {
|
|
45
|
+
systemPromptParts.push(chatPrompt);
|
|
46
|
+
}
|
|
47
|
+
const systemPrompt = readSystemPrompt();
|
|
48
|
+
if (systemPrompt) {
|
|
49
|
+
systemPromptParts.push(systemPrompt);
|
|
50
|
+
}
|
|
51
|
+
messages.push(new SystemMessage(systemPromptParts.join('\n')));
|
|
42
52
|
}
|
|
43
53
|
messages.push(new HumanMessage(userInput));
|
|
44
54
|
|
|
@@ -78,7 +88,7 @@ export function chatCommand(program: Command) {
|
|
|
78
88
|
if (message) {
|
|
79
89
|
await processMessage(message);
|
|
80
90
|
} else {
|
|
81
|
-
display(
|
|
91
|
+
display('\nGaunt Sloth is ready to chat. Type your prompt.');
|
|
82
92
|
display(chalk.gray("Type 'exit' or hit Ctrl+C to exit chat\n"));
|
|
83
93
|
}
|
|
84
94
|
if (!shouldExit) askQuestion();
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { initConfig } from '#src/config.js';
|
|
2
|
+
import { display } from '#src/consoleUtils.js';
|
|
3
|
+
import { invoke } from '#src/llmUtils.js';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { MemorySaver } from '@langchain/langgraph';
|
|
8
|
+
import { HumanMessage, SystemMessage, type BaseMessage } from '@langchain/core/messages';
|
|
9
|
+
import {
|
|
10
|
+
createInterface,
|
|
11
|
+
error,
|
|
12
|
+
exit,
|
|
13
|
+
stdin as input,
|
|
14
|
+
stdout as output,
|
|
15
|
+
} from '#src/systemUtils.js';
|
|
16
|
+
import { RunnableConfig } from '@langchain/core/runnables';
|
|
17
|
+
import { getGslothFilePath } from '#src/filePathUtils.js';
|
|
18
|
+
import { generateStandardFileName, appendToFile } from '#src/utils.js';
|
|
19
|
+
import { readBackstory, readGuidelines, readSystemPrompt, readCodePrompt } from '#src/prompt.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Adds the code command to the program
|
|
23
|
+
* @param program - The commander program
|
|
24
|
+
*/
|
|
25
|
+
export function codeCommand(program: Command): void {
|
|
26
|
+
program
|
|
27
|
+
.command('code')
|
|
28
|
+
.description(
|
|
29
|
+
'Interactively write code with sloth (has full file system access within your project)'
|
|
30
|
+
)
|
|
31
|
+
.argument('[message]', 'Initial message to start the code session')
|
|
32
|
+
.action(async (message: string) => {
|
|
33
|
+
try {
|
|
34
|
+
// Force streaming Off for code, it does not play nicely with the input interface
|
|
35
|
+
const config = { ...(await initConfig()), streamOutput: false };
|
|
36
|
+
const checkpointSaver = new MemorySaver();
|
|
37
|
+
const rl = createInterface({ input, output });
|
|
38
|
+
let isFirstMessage = true;
|
|
39
|
+
let shouldExit = false;
|
|
40
|
+
const thread_id = uuidv4();
|
|
41
|
+
const codeLogFileName = getGslothFilePath(generateStandardFileName('CODE'));
|
|
42
|
+
|
|
43
|
+
display(chalk.gray(`Code session will be logged to ${codeLogFileName}\n`));
|
|
44
|
+
|
|
45
|
+
const processMessage = async (userInput: string) => {
|
|
46
|
+
const messages: BaseMessage[] = [];
|
|
47
|
+
if (isFirstMessage) {
|
|
48
|
+
const systemPromptParts = [readBackstory(), readGuidelines(config.projectGuidelines)];
|
|
49
|
+
const codePrompt = readCodePrompt();
|
|
50
|
+
if (codePrompt) {
|
|
51
|
+
systemPromptParts.push(codePrompt);
|
|
52
|
+
}
|
|
53
|
+
const systemPrompt = readSystemPrompt();
|
|
54
|
+
if (systemPrompt) {
|
|
55
|
+
systemPromptParts.push(systemPrompt);
|
|
56
|
+
}
|
|
57
|
+
messages.push(new SystemMessage(systemPromptParts.join('\n')));
|
|
58
|
+
}
|
|
59
|
+
messages.push(new HumanMessage(userInput));
|
|
60
|
+
|
|
61
|
+
const runConfig = {
|
|
62
|
+
configurable: { thread_id },
|
|
63
|
+
} as RunnableConfig;
|
|
64
|
+
|
|
65
|
+
const aiResponse = await invoke('code', messages, config, runConfig, checkpointSaver);
|
|
66
|
+
|
|
67
|
+
const logEntry = `## User\n\n${userInput}\n\n## Assistant\n\n${aiResponse}\n\n`;
|
|
68
|
+
appendToFile(codeLogFileName, logEntry);
|
|
69
|
+
|
|
70
|
+
isFirstMessage = false;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const askQuestion = () => {
|
|
74
|
+
rl.question(chalk.magenta(' > '), async (userInput) => {
|
|
75
|
+
if (userInput.toLowerCase() === 'exit') {
|
|
76
|
+
rl.close();
|
|
77
|
+
shouldExit = true;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (isFirstMessage && !userInput.trim()) {
|
|
81
|
+
rl.close();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!userInput.trim()) {
|
|
85
|
+
rl.close();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await processMessage(userInput);
|
|
89
|
+
display(chalk.gray("Type 'exit' or hit Ctrl+C to exit code session\n"));
|
|
90
|
+
if (!shouldExit) askQuestion();
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
if (message) {
|
|
95
|
+
await processMessage(message);
|
|
96
|
+
} else {
|
|
97
|
+
display('\nGaunt Sloth is ready to code. Type your prompt.');
|
|
98
|
+
display(chalk.gray("Type 'exit' or hit Ctrl+C to exit code session\n"));
|
|
99
|
+
}
|
|
100
|
+
if (!shouldExit) askQuestion();
|
|
101
|
+
} catch (err) {
|
|
102
|
+
error(`Error in code command: ${err}`);
|
|
103
|
+
exit(1);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -58,6 +58,9 @@ interface BaseSlothConfig {
|
|
|
58
58
|
chat?: {
|
|
59
59
|
filesystem?: string[] | 'all' | 'none';
|
|
60
60
|
};
|
|
61
|
+
code?: {
|
|
62
|
+
filesystem?: string[] | 'all' | 'none';
|
|
63
|
+
};
|
|
61
64
|
};
|
|
62
65
|
requirementsProviderConfig?: Record<string, unknown>;
|
|
63
66
|
contentProviderConfig?: Record<string, unknown>;
|
|
@@ -93,6 +96,9 @@ export const DEFAULT_CONFIG: Partial<SlothConfig> = {
|
|
|
93
96
|
contentProvider: 'github', // gh pr diff NN
|
|
94
97
|
requirementsProvider: 'github', // gh issue view NN
|
|
95
98
|
},
|
|
99
|
+
code: {
|
|
100
|
+
filesystem: 'all',
|
|
101
|
+
},
|
|
96
102
|
},
|
|
97
103
|
};
|
|
98
104
|
|
package/src/constants.ts
CHANGED
|
@@ -5,3 +5,5 @@ export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
|
|
|
5
5
|
export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
|
|
6
6
|
export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
|
|
7
7
|
export const GSLOTH_SYSTEM_PROMPT = '.gsloth.system.md';
|
|
8
|
+
export const GSLOTH_CHAT_PROMPT = '.gsloth.chat.md';
|
|
9
|
+
export const GSLOTH_CODE_PROMPT = '.gsloth.code.md';
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { initCommand } from '#src/commands/initCommand.js';
|
|
|
4
4
|
import { reviewCommand } from '#src/commands/reviewCommand.js';
|
|
5
5
|
import { prCommand } from '#src/commands/prCommand.js';
|
|
6
6
|
import { chatCommand } from '#src/commands/chatCommand.js';
|
|
7
|
+
import { codeCommand } from '#src/commands/codeCommand.js';
|
|
7
8
|
import { getSlothVersion } from '#src/utils.js';
|
|
8
9
|
import { argv, readStdin } from '#src/systemUtils.js';
|
|
9
10
|
import { setVerbose } from '#src/llmUtils.js';
|
|
@@ -29,5 +30,6 @@ reviewCommand(program);
|
|
|
29
30
|
prCommand(program);
|
|
30
31
|
askCommand(program);
|
|
31
32
|
chatCommand(program);
|
|
33
|
+
codeCommand(program);
|
|
32
34
|
|
|
33
35
|
await readStdin(program);
|
package/src/llmUtils.ts
CHANGED
|
@@ -17,7 +17,7 @@ const llmGlobalSettings = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export async function invoke(
|
|
20
|
-
command: 'ask' | 'pr' | 'review' | 'chat' | undefined,
|
|
20
|
+
command: 'ask' | 'pr' | 'review' | 'chat' | 'code' | undefined,
|
|
21
21
|
messages: Message[],
|
|
22
22
|
config: SlothConfig,
|
|
23
23
|
runConfig?: RunnableConfig,
|
package/src/prompt.ts
CHANGED
|
@@ -5,7 +5,12 @@ import {
|
|
|
5
5
|
} from '#src/utils.js';
|
|
6
6
|
import { displayError } from '#src/consoleUtils.js';
|
|
7
7
|
import { exit } from '#src/systemUtils.js';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
GSLOTH_BACKSTORY,
|
|
10
|
+
GSLOTH_SYSTEM_PROMPT,
|
|
11
|
+
GSLOTH_CHAT_PROMPT,
|
|
12
|
+
GSLOTH_CODE_PROMPT,
|
|
13
|
+
} from '#src/constants.js';
|
|
9
14
|
import { getGslothConfigReadPath } from '#src/filePathUtils.js';
|
|
10
15
|
|
|
11
16
|
export function readBackstory(): string {
|
|
@@ -32,6 +37,14 @@ export function readSystemPrompt(): string {
|
|
|
32
37
|
return readFileFromCurrentOrInstallDir(GSLOTH_SYSTEM_PROMPT, true);
|
|
33
38
|
}
|
|
34
39
|
|
|
40
|
+
export function readChatPrompt(): string {
|
|
41
|
+
return readFileFromCurrentOrInstallDir(GSLOTH_CHAT_PROMPT, true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function readCodePrompt(): string {
|
|
45
|
+
return readFileFromCurrentOrInstallDir(GSLOTH_CODE_PROMPT, true);
|
|
46
|
+
}
|
|
47
|
+
|
|
35
48
|
function readConfigPromptFile(guidelinesFilename: string): string {
|
|
36
49
|
try {
|
|
37
50
|
const filePath = getGslothConfigReadPath(guidelinesFilename);
|