gaunt-sloth-assistant 0.8.0 → 0.8.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/.gsloth.backstory.md +16 -3
- package/.gsloth.guidelines.md +64 -36
- package/dist/config.d.ts +2 -0
- package/dist/config.js +6 -2
- package/dist/config.js.map +1 -1
- package/dist/consoleUtils.d.ts +1 -0
- package/dist/consoleUtils.js +27 -10
- package/dist/consoleUtils.js.map +1 -1
- package/dist/core/Invocation.d.ts +1 -1
- package/dist/core/Invocation.js +4 -4
- package/dist/core/Invocation.js.map +1 -1
- package/dist/modules/interactiveSessionModule.js +5 -6
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/systemUtils.d.ts +8 -0
- package/dist/systemUtils.js +13 -0
- package/dist/systemUtils.js.map +1 -1
- package/dist/tools/gthStatusUpdateTool.js +2 -3
- package/dist/tools/gthStatusUpdateTool.js.map +1 -1
- package/package.json +7 -8
- package/src/config.ts +10 -2
- package/src/consoleUtils.ts +29 -10
- package/src/core/Invocation.ts +4 -4
- package/src/modules/interactiveSessionModule.ts +10 -6
- package/src/systemUtils.ts +14 -0
- package/src/tools/gthStatusUpdateTool.ts +2 -3
package/.gsloth.backstory.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
Your name is Gaunt Sloth,
|
|
2
|
-
|
|
1
|
+
Your name is Gaunt Sloth, a programmer with comprehensive expertise across programming languages. Maintain a
|
|
2
|
+
professional, direct communication style. Begin responses with substance, not pleasantries or self-promotion.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Your priority is code correctness and bug prevention over social niceties, though you remain courteous in all
|
|
5
|
+
interactions. Focus on technical accuracy and practical solutions.
|
|
6
|
+
|
|
7
|
+
Use visual indicators when providing feedback:
|
|
8
|
+
|
|
9
|
+
- ✅ for correct implementations (and approvals)
|
|
10
|
+
- ⚠️ for potential issues or areas needing attention
|
|
11
|
+
- ❌ for errors or problematic approaches (and rejections)
|
|
12
|
+
|
|
13
|
+
You may enhance communication with relevant emojis throughout your responses to improve clarity and readability,
|
|
14
|
+
but do not include foolish smiley faces.
|
|
15
|
+
|
|
16
|
+
Never include decorative emojis within code snippets — only use them in code when they're part of the actual
|
|
17
|
+
logic, string literals, or were present in the original code being discussed.
|
package/.gsloth.guidelines.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Gaunt Sloth Assistant is a command-line Node.js utility helping developers to access LLM from the command line.
|
|
4
4
|
|
|
5
5
|
## Technologies Used
|
|
6
|
+
|
|
6
7
|
- NodeJS 22 (LTS)
|
|
7
8
|
- Vitest 3 for tests
|
|
8
9
|
- Typescript 5
|
|
@@ -21,12 +22,14 @@ Please abstain from using relative imports, only use them when no other choices
|
|
|
21
22
|
(currently the only exception is entry point index.js)
|
|
22
23
|
|
|
23
24
|
### Architecture and Flow
|
|
25
|
+
|
|
24
26
|
- Make sure proper separation of LangChain components (LLMs, chains, agents, tools)
|
|
25
27
|
- Check for clear data flow between components
|
|
26
28
|
- Ensure proper state management in LangGraph workflows
|
|
27
29
|
- Validate error handling and fallback mechanisms
|
|
28
30
|
|
|
29
31
|
### Security
|
|
32
|
+
|
|
30
33
|
- Make sure API key handling and environment variables
|
|
31
34
|
- Make sure no personal data is present in code
|
|
32
35
|
- ** Make sure that API keys are accidentally not included into diff.**
|
|
@@ -53,7 +56,8 @@ Use [llmUtils.ts](src/llmUtils.ts) to access LLM.
|
|
|
53
56
|
- Always import the tested file dynamically within the test.
|
|
54
57
|
- Mocks are hoisted, so it is better to simply place them at the top of the file to avoid confusion.
|
|
55
58
|
- Make sure that beforeEach is always present and always calls vi.resetAllMocks(); as a first thing.
|
|
56
|
-
- Create variables with vi.fn() without adding implementations to them, then apply these functions with vi.mock outside
|
|
59
|
+
- Create variables with vi.fn() without adding implementations to them, then apply these functions with vi.mock outside
|
|
60
|
+
of the describe.
|
|
57
61
|
- Apply mock implementations and return values to mocks within individual tests.
|
|
58
62
|
- When mock implementations are common for all test cases, apply them in beforeEach.
|
|
59
63
|
- Make sure test actually testing a function, rather than simply testing the mock.
|
|
@@ -65,49 +69,73 @@ import {beforeEach, describe, expect, it, vi} from 'vitest';
|
|
|
65
69
|
import {writeFileSync} from "node:fs";
|
|
66
70
|
|
|
67
71
|
const consoleUtilsMock = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
display: vi.fn(),
|
|
73
|
+
displayError: vi.fn(),
|
|
74
|
+
displayInfo: vi.fn(),
|
|
75
|
+
displayWarning: vi.fn(),
|
|
76
|
+
displaySuccess: vi.fn(),
|
|
77
|
+
displayDebug: vi.fn(),
|
|
74
78
|
};
|
|
75
79
|
vi.mock('#src/consoleUtils.js', () => consoleUtilsMock);
|
|
76
80
|
|
|
77
81
|
let fsUtilsMock = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
existsSync: vi.fn(),
|
|
83
|
+
readFileSync: vi.fn(),
|
|
84
|
+
writeFileSync: vi.fn(),
|
|
81
85
|
};
|
|
82
86
|
vi.mock('node:fs', () => fsUtilsMock);
|
|
83
87
|
|
|
84
88
|
describe('specialUtil', () => {
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
vi.resetAllMocks(); // Always reset all mocks in beforeEach
|
|
91
|
+
|
|
92
|
+
// Set up default mock values
|
|
93
|
+
fsUtilsMock.existsSync.mockImplementation(() => true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('specialFunction should eventually write test contents to a file', async () => {
|
|
97
|
+
fsMock.readFileSync.mockImplementation((path: string) => {
|
|
98
|
+
if (path.includes('inputFile.txt')) return 'TEST CONTENT';
|
|
99
|
+
return '';
|
|
100
|
+
});
|
|
87
101
|
|
|
88
|
-
|
|
89
|
-
fsUtilsMock.existsSync.mockImplementation(() => true);
|
|
90
|
-
});
|
|
102
|
+
const {specialFunction} = await import('#src/specialUtil.js'); // Always import tested file within the test
|
|
91
103
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
// Function under test
|
|
105
|
+
specialFunction();
|
|
106
|
+
|
|
107
|
+
expect(fsUtilsMock.writeFileSync).toHaveBeenCalledWith('outputFile.txt', 'TEST CONTENT\nEXTRA CONTENT');
|
|
108
|
+
expect(consoleUtilsMock.displayDebug).not.toHaveBeenCalled();
|
|
109
|
+
expect(consoleUtilsMock.displayWarning).not.toHaveBeenCalled();
|
|
110
|
+
expect(consoleUtilsMock.display).not.toHaveBeenCalled();
|
|
111
|
+
expect(consoleUtilsMock.displayError).not.toHaveBeenCalled();
|
|
112
|
+
expect(consoleUtilsMock.displayInfo).not.toHaveBeenCalled();
|
|
113
|
+
expect(consoleUtilsMock.displaySuccess).toHaveBeenCalledWith('Successfully transferred to outputFile.txt');
|
|
96
114
|
});
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
When mocking class constructors follow this pattern:
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
// With export default
|
|
122
|
+
const gthFileSystemToolkitGetToolsMock = vi.fn();
|
|
123
|
+
vi.mock('#src/tools/GthFileSystemToolkit.js', () => {
|
|
124
|
+
const GthFileSystemToolkit = vi.fn();
|
|
125
|
+
GthFileSystemToolkit.prototype.getTools = gthFileSystemToolkitGetToolsMock;
|
|
126
|
+
return {
|
|
127
|
+
default: GthFileSystemToolkit,
|
|
128
|
+
};
|
|
129
|
+
});
|
|
97
130
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
expect(consoleUtilsMock.display).not.toHaveBeenCalled();
|
|
107
|
-
expect(consoleUtilsMock.displayError).not.toHaveBeenCalled();
|
|
108
|
-
expect(consoleUtilsMock.displayInfo).not.toHaveBeenCalled();
|
|
109
|
-
expect(consoleUtilsMock.displaySuccess).toHaveBeenCalledWith('Successfully transferred to outputFile.txt');
|
|
110
|
-
});
|
|
131
|
+
// With named exports
|
|
132
|
+
const otherToolkitMock = vi.fn();
|
|
133
|
+
vi.mock('#src/tools/OtherToolkit.js', () => {
|
|
134
|
+
const OtherToolkit = vi.fn();
|
|
135
|
+
OtherToolkit.prototype.getTools = otherToolkitMock;
|
|
136
|
+
return {
|
|
137
|
+
OtherToolkit,
|
|
138
|
+
};
|
|
111
139
|
});
|
|
112
140
|
```
|
|
113
141
|
|
|
@@ -118,10 +146,10 @@ Please follow this workflow:
|
|
|
118
146
|
- Analyze requirements.
|
|
119
147
|
- Develop changes.
|
|
120
148
|
- Make sure all tests pass `npm run test` and fix if possible.
|
|
121
|
-
|
|
149
|
+
- Request relevant documentation if some of the test failures are unclear.
|
|
122
150
|
- Once all tests are green check lint with `npm run lint`.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
- If any lint failures are present try fixing them with `npm run lint -- --fix`.
|
|
152
|
+
- If autofix didn't help, try fixing them yourself.
|
|
153
|
+
- Prefer testing all user outputs, including testing absence of unexpected outputs.
|
|
126
154
|
|
|
127
155
|
---
|
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface SlothConfig extends BaseSlothConfig {
|
|
|
9
9
|
projectGuidelines: string;
|
|
10
10
|
projectReviewInstructions: string;
|
|
11
11
|
streamOutput: boolean;
|
|
12
|
+
useColour: boolean;
|
|
12
13
|
filesystem: string[] | 'all' | 'read' | 'none';
|
|
13
14
|
builtInTools?: string[];
|
|
14
15
|
tools?: StructuredToolInterface[] | BaseToolkit[];
|
|
@@ -29,6 +30,7 @@ interface BaseSlothConfig {
|
|
|
29
30
|
projectGuidelines?: string;
|
|
30
31
|
projectReviewInstructions?: string;
|
|
31
32
|
streamOutput?: boolean;
|
|
33
|
+
useColour?: boolean;
|
|
32
34
|
filesystem?: string[] | 'all' | 'read' | 'none';
|
|
33
35
|
prebuiltToolsConfig?: PreBuiltToolsConfig;
|
|
34
36
|
customToolsConfig?: CustomToolsConfig;
|
package/dist/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { displayDebug, displayError, displayInfo, displayWarning } from '#src/consoleUtils.js';
|
|
2
2
|
import { importExternalFile, writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { error, exit } from '#src/systemUtils.js';
|
|
4
|
+
import { error, exit, setUseColour } from '#src/systemUtils.js';
|
|
5
5
|
import { getGslothConfigReadPath, getGslothConfigWritePath } from '#src/filePathUtils.js';
|
|
6
6
|
import { PROJECT_GUIDELINES, PROJECT_REVIEW_INSTRUCTIONS, USER_PROJECT_CONFIG_JS, USER_PROJECT_CONFIG_JSON, USER_PROJECT_CONFIG_MJS, } from '#src/constants.js';
|
|
7
7
|
export const availableDefaultConfigs = ['vertexai', 'anthropic', 'groq', 'deepseek'];
|
|
@@ -12,6 +12,7 @@ export const DEFAULT_CONFIG = {
|
|
|
12
12
|
projectGuidelines: PROJECT_GUIDELINES,
|
|
13
13
|
projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
|
|
14
14
|
streamOutput: true,
|
|
15
|
+
useColour: true,
|
|
15
16
|
filesystem: 'read',
|
|
16
17
|
commands: {
|
|
17
18
|
pr: {
|
|
@@ -208,11 +209,14 @@ Important! You are likely to be dealing with git diff below, please don't confus
|
|
|
208
209
|
*/
|
|
209
210
|
function mergeConfig(partialConfig) {
|
|
210
211
|
const config = partialConfig;
|
|
211
|
-
|
|
212
|
+
const mergedConfig = {
|
|
212
213
|
...DEFAULT_CONFIG,
|
|
213
214
|
...config,
|
|
214
215
|
commands: { ...DEFAULT_CONFIG.commands, ...(config?.commands ?? {}) },
|
|
215
216
|
};
|
|
217
|
+
// Set the useColour value in systemUtils
|
|
218
|
+
setUseColour(mergedConfig.useColour);
|
|
219
|
+
return mergedConfig;
|
|
216
220
|
}
|
|
217
221
|
/**
|
|
218
222
|
* Merge raw with default config
|
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;
|
|
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,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAG1F,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAgF3B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAU,CAAC;AAG9F,MAAM,CAAC,MAAM,cAAc,GAAyB;IAClD,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,MAAM;IACvB,oBAAoB,EAAE,MAAM;IAC5B,iBAAiB,EAAE,kBAAkB;IACrC,yBAAyB,EAAE,2BAA2B;IACtD,YAAY,EAA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C;AACxE,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,MAAM,cAAc,GAAG,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,wBAAwB,CAAC,2BAA2B,CAAC,CAAC;IAEzE;;;;OAIG;IACH,MAAM,kBAAkB,GAAG;;;;2EAI8C,kBAAkB;;qBAExE,kBAAkB;CACtC,CAAC;IAEA;;;;OAIG;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,MAAM,YAAY,GAAG;QACnB,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;IAEF,yCAAyC;IACzC,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAErC,OAAO,YAAY,CAAC;AACtB,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/consoleUtils.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export declare function displayWarning(message: string): void;
|
|
|
4
4
|
export declare function displaySuccess(message: string): void;
|
|
5
5
|
export declare function displayInfo(message: string): void;
|
|
6
6
|
export declare function display(message: string): void;
|
|
7
|
+
export declare function formatInputPrompt(message: string): string;
|
|
7
8
|
export declare function displayDebug(message: string | Error | undefined): void;
|
|
8
9
|
export declare const defaultStatusCallbacks: StatusUpdateCallback;
|
package/dist/consoleUtils.js
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as su from '#src/systemUtils.js';
|
|
2
|
+
// ANSI color codes
|
|
3
|
+
const ANSI_COLORS = {
|
|
4
|
+
red: '\x1b[31m',
|
|
5
|
+
yellow: '\x1b[33m',
|
|
6
|
+
green: '\x1b[32m',
|
|
7
|
+
magenta: '\x1b[35m',
|
|
8
|
+
dim: '\x1b[2m',
|
|
9
|
+
reset: '\x1b[0m',
|
|
10
|
+
};
|
|
11
|
+
// Helper functions for ANSI coloring
|
|
12
|
+
function colorText(text, color) {
|
|
13
|
+
if (!su.getUseColour()) {
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
16
|
+
return `${ANSI_COLORS[color]}${text}${ANSI_COLORS.reset}`;
|
|
17
|
+
}
|
|
4
18
|
export function displayError(message) {
|
|
5
|
-
|
|
19
|
+
su.log(colorText(message, 'red'));
|
|
6
20
|
}
|
|
7
21
|
export function displayWarning(message) {
|
|
8
|
-
|
|
22
|
+
su.warn(colorText(message, 'yellow'));
|
|
9
23
|
}
|
|
10
24
|
export function displaySuccess(message) {
|
|
11
|
-
|
|
25
|
+
su.log(colorText(message, 'green'));
|
|
12
26
|
}
|
|
13
27
|
export function displayInfo(message) {
|
|
14
|
-
|
|
28
|
+
su.info(colorText(message, 'dim'));
|
|
15
29
|
}
|
|
16
30
|
export function display(message) {
|
|
17
|
-
log(message);
|
|
31
|
+
su.log(message);
|
|
32
|
+
}
|
|
33
|
+
export function formatInputPrompt(message) {
|
|
34
|
+
return colorText(message, 'magenta');
|
|
18
35
|
}
|
|
19
36
|
export function displayDebug(message) {
|
|
20
37
|
// TODO make it controlled by config
|
|
21
38
|
if (message instanceof Error) {
|
|
22
|
-
|
|
39
|
+
su.debug(message.stack || '');
|
|
23
40
|
}
|
|
24
41
|
else if (message !== undefined) {
|
|
25
|
-
|
|
42
|
+
su.debug(message);
|
|
26
43
|
}
|
|
27
44
|
}
|
|
28
45
|
// Create status update callback
|
package/dist/consoleUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleUtils.js","sourceRoot":"","sources":["../src/consoleUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"consoleUtils.js","sourceRoot":"","sources":["../src/consoleUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI1C,mBAAmB;AACnB,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,qCAAqC;AACrC,SAAS,SAAS,CAAC,IAAY,EAAE,KAA+B;IAC9D,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAA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StatusUpdateCallback);
|
|
16
16
|
setVerbose(verbose: boolean): void;
|
|
17
|
-
init(command: GthCommand | undefined,
|
|
17
|
+
init(command: GthCommand | undefined, configIn: SlothConfig, checkpointSaver?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
18
18
|
getEffectiveConfig(config: SlothConfig, command: GthCommand | undefined): SlothConfig;
|
|
19
19
|
invoke(messages: Message[], runConfig?: RunnableConfig): Promise<string>;
|
|
20
20
|
cleanup(): Promise<void>;
|
package/dist/core/Invocation.js
CHANGED
|
@@ -18,15 +18,15 @@ export class Invocation {
|
|
|
18
18
|
setVerbose(verbose) {
|
|
19
19
|
this.verbose = verbose;
|
|
20
20
|
}
|
|
21
|
-
async init(command,
|
|
21
|
+
async init(command, configIn, checkpointSaver) {
|
|
22
22
|
if (this.verbose) {
|
|
23
|
-
|
|
23
|
+
configIn.llm.verbose = true;
|
|
24
24
|
}
|
|
25
25
|
// Merge command-specific filesystem config if provided
|
|
26
|
-
this.config = this.getEffectiveConfig(
|
|
26
|
+
this.config = this.getEffectiveConfig(configIn, command);
|
|
27
27
|
this.mcpClient = await this.getMcpClient(this.config);
|
|
28
28
|
// Get default filesystem tools (filtered based on config)
|
|
29
|
-
const defaultTools = await getDefaultTools(config);
|
|
29
|
+
const defaultTools = await getDefaultTools(this.config);
|
|
30
30
|
// Get user config tools
|
|
31
31
|
const flattenedConfigTools = this.extractAndFlattenTools(this.config.tools || []);
|
|
32
32
|
// Get MCP tools
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Invocation.js","sourceRoot":"","sources":["../../src/core/Invocation.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAA4B,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA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M;oBACT,YAAY;iBACb,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,8BAA8B;gBAC9B,UAAU,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;YAClC,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,oBAAoB,CAAC;gBAC9B,gBAAgB,EAAE,IAAI;gBACtB,4BAA4B,EAAE,IAAI;gBAClC,wBAAwB,EAAE,KAAK;gBAC/B,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { initConfig } from '#src/config.js';
|
|
2
|
-
import { defaultStatusCallbacks, display } from '#src/consoleUtils.js';
|
|
2
|
+
import { defaultStatusCallbacks, display, displayInfo, formatInputPrompt, } from '#src/consoleUtils.js';
|
|
3
3
|
import * as crypto from 'crypto';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
4
|
import { MemorySaver } from '@langchain/langgraph';
|
|
6
5
|
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
7
6
|
import { createInterface, error, exit, stdin as input, stdout as output, } from '#src/systemUtils.js';
|
|
@@ -21,7 +20,7 @@ export async function createInteractiveSession(sessionConfig, message) {
|
|
|
21
20
|
let shouldExit = false;
|
|
22
21
|
const thread_id = crypto.randomUUID();
|
|
23
22
|
const logFileName = getGslothFilePath(generateStandardFileName(sessionConfig.mode.toUpperCase()));
|
|
24
|
-
|
|
23
|
+
displayInfo(`${sessionConfig.mode} session will be logged to ${logFileName}\n`);
|
|
25
24
|
const processMessage = async (userInput) => {
|
|
26
25
|
const messages = [];
|
|
27
26
|
if (isFirstMessage) {
|
|
@@ -46,7 +45,7 @@ export async function createInteractiveSession(sessionConfig, message) {
|
|
|
46
45
|
isFirstMessage = false;
|
|
47
46
|
};
|
|
48
47
|
const askQuestion = () => {
|
|
49
|
-
rl.question(
|
|
48
|
+
rl.question(formatInputPrompt(' > '), async (userInput) => {
|
|
50
49
|
if (!userInput.trim()) {
|
|
51
50
|
rl.close(); // This is not the end of the loop, simply skipping inference if no input
|
|
52
51
|
return;
|
|
@@ -59,7 +58,7 @@ export async function createInteractiveSession(sessionConfig, message) {
|
|
|
59
58
|
}
|
|
60
59
|
await processMessage(userInput);
|
|
61
60
|
display('\n\n');
|
|
62
|
-
|
|
61
|
+
displayInfo(sessionConfig.exitMessage);
|
|
63
62
|
if (!shouldExit)
|
|
64
63
|
askQuestion();
|
|
65
64
|
});
|
|
@@ -69,7 +68,7 @@ export async function createInteractiveSession(sessionConfig, message) {
|
|
|
69
68
|
}
|
|
70
69
|
else {
|
|
71
70
|
display(sessionConfig.readyMessage);
|
|
72
|
-
|
|
71
|
+
displayInfo(sessionConfig.exitMessage);
|
|
73
72
|
}
|
|
74
73
|
if (!shouldExit)
|
|
75
74
|
askQuestion();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,WAAW,EACX,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAoB,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EACL,eAAe,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AAC;oBACvC,EAAE,CAAC,KAAK,EAAE,CAAC;oBACX,UAAU,GAAG,IAAI,CAAC;oBAClB,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;oBAC3B,OAAO;gBACT,CAAC;gBACD,MAAM,cAAc,CAAC,SAAS,CAAC,CAAC;gBAChC,OAAO,CAAC,MAAM,CAAC,CAAC;gBAChB,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBACvC,IAAI,CAAC,UAAU;oBAAE,WAAW,EAAE,CAAC;YACjC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACpC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,WAAW,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,YAAY,aAAa,CAAC,IAAI,aAAa,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
package/dist/systemUtils.d.ts
CHANGED
|
@@ -6,6 +6,14 @@ export declare const getInstallDir: () => string;
|
|
|
6
6
|
* Cached string from stdin. Should only be called after readStdin completes execution.
|
|
7
7
|
*/
|
|
8
8
|
export declare const getStringFromStdin: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Get the current useColour setting.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getUseColour: () => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Set the useColour setting.
|
|
15
|
+
*/
|
|
16
|
+
export declare const setUseColour: (useColour: boolean) => void;
|
|
9
17
|
export declare const exit: (code?: number) => never;
|
|
10
18
|
export declare const stdin: NodeJS.ReadStream & {
|
|
11
19
|
fd: 0;
|
package/dist/systemUtils.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createInterface } from 'node:readline';
|
|
|
5
5
|
const innerState = {
|
|
6
6
|
installDir: undefined,
|
|
7
7
|
stringFromStdin: '',
|
|
8
|
+
useColour: false,
|
|
8
9
|
};
|
|
9
10
|
// Process-related functions and objects
|
|
10
11
|
export const getCurrentDir = () => process.cwd();
|
|
@@ -20,6 +21,18 @@ export const getInstallDir = () => {
|
|
|
20
21
|
export const getStringFromStdin = () => {
|
|
21
22
|
return innerState.stringFromStdin;
|
|
22
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Get the current useColour setting.
|
|
26
|
+
*/
|
|
27
|
+
export const getUseColour = () => {
|
|
28
|
+
return innerState.useColour;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Set the useColour setting.
|
|
32
|
+
*/
|
|
33
|
+
export const setUseColour = (useColour) => {
|
|
34
|
+
innerState.useColour = useColour;
|
|
35
|
+
};
|
|
23
36
|
export const exit = (code) => process.exit(code || 0);
|
|
24
37
|
export const stdin = process.stdin;
|
|
25
38
|
export const stdout = process.stdout;
|
package/dist/systemUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemUtils.js","sourceRoot":"","sources":["../src/systemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAuC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"systemUtils.js","sourceRoot":"","sources":["../src/systemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,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AC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { tool } from '@langchain/core/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import
|
|
4
|
-
import { display } from '#src/consoleUtils.js';
|
|
3
|
+
import { displayInfo } from '#src/consoleUtils.js';
|
|
5
4
|
const toolDefinition = {
|
|
6
5
|
name: 'gth_status_update',
|
|
7
6
|
description: `Gaunt Sloth Status Update Tool. Use this tool to update status in the console. Example: gth_status_update "Working on something important", be brief, feel free to use emojis. Update after using tools.`,
|
|
8
7
|
schema: z.string(),
|
|
9
8
|
};
|
|
10
9
|
const toolImpl = (s) => {
|
|
11
|
-
|
|
10
|
+
displayInfo(s);
|
|
12
11
|
};
|
|
13
12
|
export function get(_) {
|
|
14
13
|
return tool(toolImpl, toolDefinition);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gthStatusUpdateTool.js","sourceRoot":"","sources":["../../src/tools/gthStatusUpdateTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"gthStatusUpdateTool.js","sourceRoot":"","sources":["../../src/tools/gthStatusUpdateTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,0MAA0M;IACvN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC;AACF,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAQ,EAAE;IACnC,WAAW,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,CAAc;IAChC,OAAO,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AACxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaunt-sloth-assistant",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andrew Kondratev",
|
|
@@ -29,9 +29,8 @@
|
|
|
29
29
|
"@langchain/deepseek": "^0.0.2",
|
|
30
30
|
"@langchain/google-vertexai": "^0.2.14",
|
|
31
31
|
"@langchain/groq": "^0.2.3",
|
|
32
|
-
"@langchain/langgraph": "^0.3.
|
|
32
|
+
"@langchain/langgraph": "^0.3.6",
|
|
33
33
|
"@langchain/mcp-adapters": "^0.5.2",
|
|
34
|
-
"chalk": "^5.4.1",
|
|
35
34
|
"commander": "^14.0.0",
|
|
36
35
|
"diff": "^8.0.2",
|
|
37
36
|
"express": "^5.1.0",
|
|
@@ -41,14 +40,14 @@
|
|
|
41
40
|
"@eslint/js": "^9.26.0",
|
|
42
41
|
"@types/diff": "^7.0.2",
|
|
43
42
|
"@types/express": "^5.0.3",
|
|
44
|
-
"@types/node": "^24.0.
|
|
43
|
+
"@types/node": "^24.0.10",
|
|
45
44
|
"@types/uuid": "^10.0.0",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^8.35.
|
|
47
|
-
"@typescript-eslint/parser": "^8.35.
|
|
48
|
-
"eslint": "^9.30.
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
|
46
|
+
"@typescript-eslint/parser": "^8.35.1",
|
|
47
|
+
"eslint": "^9.30.1",
|
|
49
48
|
"eslint-config-prettier": "^10.1.5",
|
|
50
49
|
"eslint-plugin-prettier": "^5.5.1",
|
|
51
|
-
"globals": "^16.
|
|
50
|
+
"globals": "^16.3.0",
|
|
52
51
|
"prettier": "3.6.0",
|
|
53
52
|
"typescript": "^5.8.3",
|
|
54
53
|
"vitest": "^3.2.4"
|
package/src/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { displayDebug, displayError, displayInfo, displayWarning } from '#src/consoleUtils.js';
|
|
2
2
|
import { importExternalFile, writeFileIfNotExistsWithMessages } from '#src/utils.js';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { error, exit } from '#src/systemUtils.js';
|
|
4
|
+
import { error, exit, setUseColour } from '#src/systemUtils.js';
|
|
5
5
|
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
6
6
|
import { getGslothConfigReadPath, getGslothConfigWritePath } from '#src/filePathUtils.js';
|
|
7
7
|
import type { Connection } from '@langchain/mcp-adapters';
|
|
@@ -22,6 +22,7 @@ export interface SlothConfig extends BaseSlothConfig {
|
|
|
22
22
|
projectGuidelines: string;
|
|
23
23
|
projectReviewInstructions: string;
|
|
24
24
|
streamOutput: boolean;
|
|
25
|
+
useColour: boolean;
|
|
25
26
|
filesystem: string[] | 'all' | 'read' | 'none';
|
|
26
27
|
builtInTools?: string[];
|
|
27
28
|
tools?: StructuredToolInterface[] | BaseToolkit[];
|
|
@@ -44,6 +45,7 @@ interface BaseSlothConfig {
|
|
|
44
45
|
projectGuidelines?: string;
|
|
45
46
|
projectReviewInstructions?: string;
|
|
46
47
|
streamOutput?: boolean;
|
|
48
|
+
useColour?: boolean;
|
|
47
49
|
filesystem?: string[] | 'all' | 'read' | 'none';
|
|
48
50
|
prebuiltToolsConfig?: PreBuiltToolsConfig;
|
|
49
51
|
customToolsConfig?: CustomToolsConfig;
|
|
@@ -100,6 +102,7 @@ export const DEFAULT_CONFIG: Partial<SlothConfig> = {
|
|
|
100
102
|
projectGuidelines: PROJECT_GUIDELINES,
|
|
101
103
|
projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
|
|
102
104
|
streamOutput: true,
|
|
105
|
+
useColour: true,
|
|
103
106
|
filesystem: 'read',
|
|
104
107
|
commands: {
|
|
105
108
|
pr: {
|
|
@@ -305,11 +308,16 @@ Important! You are likely to be dealing with git diff below, please don't confus
|
|
|
305
308
|
*/
|
|
306
309
|
function mergeConfig(partialConfig: Partial<SlothConfig>): SlothConfig {
|
|
307
310
|
const config = partialConfig as SlothConfig;
|
|
308
|
-
|
|
311
|
+
const mergedConfig = {
|
|
309
312
|
...DEFAULT_CONFIG,
|
|
310
313
|
...config,
|
|
311
314
|
commands: { ...DEFAULT_CONFIG.commands, ...(config?.commands ?? {}) },
|
|
312
315
|
};
|
|
316
|
+
|
|
317
|
+
// Set the useColour value in systemUtils
|
|
318
|
+
setUseColour(mergedConfig.useColour);
|
|
319
|
+
|
|
320
|
+
return mergedConfig;
|
|
313
321
|
}
|
|
314
322
|
|
|
315
323
|
/**
|
package/src/consoleUtils.ts
CHANGED
|
@@ -1,36 +1,55 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { debug as systemDebug, error as systemError, log } from '#src/systemUtils.js';
|
|
1
|
+
import * as su from '#src/systemUtils.js';
|
|
3
2
|
import { StatusUpdateCallback } from '#src/core/Invocation.js';
|
|
4
3
|
import { StatusLevel } from '#src/core/types.js';
|
|
5
4
|
|
|
6
|
-
//
|
|
5
|
+
// ANSI color codes
|
|
6
|
+
const ANSI_COLORS = {
|
|
7
|
+
red: '\x1b[31m',
|
|
8
|
+
yellow: '\x1b[33m',
|
|
9
|
+
green: '\x1b[32m',
|
|
10
|
+
magenta: '\x1b[35m',
|
|
11
|
+
dim: '\x1b[2m',
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Helper functions for ANSI coloring
|
|
16
|
+
function colorText(text: string, color: keyof typeof ANSI_COLORS): string {
|
|
17
|
+
if (!su.getUseColour()) {
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
return `${ANSI_COLORS[color]}${text}${ANSI_COLORS.reset}`;
|
|
21
|
+
}
|
|
7
22
|
|
|
8
23
|
export function displayError(message: string): void {
|
|
9
|
-
|
|
24
|
+
su.log(colorText(message, 'red'));
|
|
10
25
|
}
|
|
11
26
|
|
|
12
27
|
export function displayWarning(message: string): void {
|
|
13
|
-
|
|
28
|
+
su.warn(colorText(message, 'yellow'));
|
|
14
29
|
}
|
|
15
30
|
|
|
16
31
|
export function displaySuccess(message: string): void {
|
|
17
|
-
|
|
32
|
+
su.log(colorText(message, 'green'));
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
export function displayInfo(message: string): void {
|
|
21
|
-
|
|
36
|
+
su.info(colorText(message, 'dim'));
|
|
22
37
|
}
|
|
23
38
|
|
|
24
39
|
export function display(message: string): void {
|
|
25
|
-
log(message);
|
|
40
|
+
su.log(message);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function formatInputPrompt(message: string): string {
|
|
44
|
+
return colorText(message, 'magenta');
|
|
26
45
|
}
|
|
27
46
|
|
|
28
47
|
export function displayDebug(message: string | Error | undefined): void {
|
|
29
48
|
// TODO make it controlled by config
|
|
30
49
|
if (message instanceof Error) {
|
|
31
|
-
|
|
50
|
+
su.debug(message.stack || '');
|
|
32
51
|
} else if (message !== undefined) {
|
|
33
|
-
|
|
52
|
+
su.debug(message);
|
|
34
53
|
}
|
|
35
54
|
}
|
|
36
55
|
|
package/src/core/Invocation.ts
CHANGED
|
@@ -34,19 +34,19 @@ export class Invocation {
|
|
|
34
34
|
|
|
35
35
|
async init(
|
|
36
36
|
command: GthCommand | undefined,
|
|
37
|
-
|
|
37
|
+
configIn: SlothConfig,
|
|
38
38
|
checkpointSaver?: BaseCheckpointSaver | undefined
|
|
39
39
|
): Promise<void> {
|
|
40
40
|
if (this.verbose) {
|
|
41
|
-
|
|
41
|
+
configIn.llm.verbose = true;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// Merge command-specific filesystem config if provided
|
|
45
|
-
this.config = this.getEffectiveConfig(
|
|
45
|
+
this.config = this.getEffectiveConfig(configIn, command);
|
|
46
46
|
this.mcpClient = await this.getMcpClient(this.config);
|
|
47
47
|
|
|
48
48
|
// Get default filesystem tools (filtered based on config)
|
|
49
|
-
const defaultTools = await getDefaultTools(config);
|
|
49
|
+
const defaultTools = await getDefaultTools(this.config);
|
|
50
50
|
|
|
51
51
|
// Get user config tools
|
|
52
52
|
const flattenedConfigTools = this.extractAndFlattenTools(this.config.tools || []);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { initConfig } from '#src/config.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
defaultStatusCallbacks,
|
|
4
|
+
display,
|
|
5
|
+
displayInfo,
|
|
6
|
+
formatInputPrompt,
|
|
7
|
+
} from '#src/consoleUtils.js';
|
|
3
8
|
import * as crypto from 'crypto';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
9
|
import { MemorySaver } from '@langchain/langgraph';
|
|
6
10
|
import { type BaseMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
7
11
|
import {
|
|
@@ -41,7 +45,7 @@ export async function createInteractiveSession(sessionConfig: SessionConfig, mes
|
|
|
41
45
|
generateStandardFileName(sessionConfig.mode.toUpperCase())
|
|
42
46
|
);
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
displayInfo(`${sessionConfig.mode} session will be logged to ${logFileName}\n`);
|
|
45
49
|
|
|
46
50
|
const processMessage = async (userInput: string) => {
|
|
47
51
|
const messages: BaseMessage[] = [];
|
|
@@ -72,7 +76,7 @@ export async function createInteractiveSession(sessionConfig: SessionConfig, mes
|
|
|
72
76
|
};
|
|
73
77
|
|
|
74
78
|
const askQuestion = () => {
|
|
75
|
-
rl.question(
|
|
79
|
+
rl.question(formatInputPrompt(' > '), async (userInput) => {
|
|
76
80
|
if (!userInput.trim()) {
|
|
77
81
|
rl.close(); // This is not the end of the loop, simply skipping inference if no input
|
|
78
82
|
return;
|
|
@@ -85,7 +89,7 @@ export async function createInteractiveSession(sessionConfig: SessionConfig, mes
|
|
|
85
89
|
}
|
|
86
90
|
await processMessage(userInput);
|
|
87
91
|
display('\n\n');
|
|
88
|
-
|
|
92
|
+
displayInfo(sessionConfig.exitMessage);
|
|
89
93
|
if (!shouldExit) askQuestion();
|
|
90
94
|
});
|
|
91
95
|
};
|
|
@@ -94,7 +98,7 @@ export async function createInteractiveSession(sessionConfig: SessionConfig, mes
|
|
|
94
98
|
await processMessage(message);
|
|
95
99
|
} else {
|
|
96
100
|
display(sessionConfig.readyMessage);
|
|
97
|
-
|
|
101
|
+
displayInfo(sessionConfig.exitMessage);
|
|
98
102
|
}
|
|
99
103
|
if (!shouldExit) askQuestion();
|
|
100
104
|
} catch (err) {
|
package/src/systemUtils.ts
CHANGED
|
@@ -16,11 +16,13 @@ import { createInterface, type Interface as ReadLineInterface } from 'node:readl
|
|
|
16
16
|
interface InnerState {
|
|
17
17
|
installDir: string | null | undefined;
|
|
18
18
|
stringFromStdin: string;
|
|
19
|
+
useColour: boolean;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const innerState: InnerState = {
|
|
22
23
|
installDir: undefined,
|
|
23
24
|
stringFromStdin: '',
|
|
25
|
+
useColour: false,
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
// Process-related functions and objects
|
|
@@ -37,6 +39,18 @@ export const getInstallDir = (): string => {
|
|
|
37
39
|
export const getStringFromStdin = (): string => {
|
|
38
40
|
return innerState.stringFromStdin;
|
|
39
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Get the current useColour setting.
|
|
44
|
+
*/
|
|
45
|
+
export const getUseColour = (): boolean => {
|
|
46
|
+
return innerState.useColour;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Set the useColour setting.
|
|
50
|
+
*/
|
|
51
|
+
export const setUseColour = (useColour: boolean): void => {
|
|
52
|
+
innerState.useColour = useColour;
|
|
53
|
+
};
|
|
40
54
|
export const exit = (code?: number): never => process.exit(code || 0);
|
|
41
55
|
export const stdin = process.stdin;
|
|
42
56
|
export const stdout = process.stdout;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { tool } from '@langchain/core/tools';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import
|
|
4
|
-
import { display } from '#src/consoleUtils.js';
|
|
3
|
+
import { displayInfo } from '#src/consoleUtils.js';
|
|
5
4
|
import { SlothConfig } from '#src/config.js';
|
|
6
5
|
|
|
7
6
|
const toolDefinition = {
|
|
@@ -10,7 +9,7 @@ const toolDefinition = {
|
|
|
10
9
|
schema: z.string(),
|
|
11
10
|
};
|
|
12
11
|
const toolImpl = (s: string): void => {
|
|
13
|
-
|
|
12
|
+
displayInfo(s);
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
export function get(_: SlothConfig) {
|