gaunt-sloth-assistant 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.gsloth.preamble.review.md → .gsloth.guidelines.md} +0 -8
- package/.gsloth.review.md +7 -0
- package/README.md +1 -1
- package/dist/commands/askCommand.js +5 -4
- package/dist/commands/askCommand.js.map +1 -1
- package/dist/commands/reviewCommand.js +22 -8
- package/dist/commands/reviewCommand.js.map +1 -1
- package/dist/config.d.ts +8 -4
- package/dist/config.js +8 -6
- package/dist/config.js.map +1 -1
- package/dist/configs/anthropic.d.ts +2 -3
- package/dist/configs/anthropic.js.map +1 -1
- package/dist/configs/vertexai.d.ts +2 -2
- package/dist/configs/vertexai.js.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/llmUtils.d.ts +4 -0
- package/dist/llmUtils.js +39 -0
- package/dist/llmUtils.js.map +1 -0
- package/dist/modules/questionAnsweringModule.d.ts +0 -11
- package/dist/modules/questionAnsweringModule.js +4 -43
- package/dist/modules/questionAnsweringModule.js.map +1 -1
- package/dist/modules/reviewModule.d.ts +0 -3
- package/dist/modules/reviewModule.js +3 -34
- package/dist/modules/reviewModule.js.map +1 -1
- package/dist/prompt.d.ts +3 -2
- package/dist/prompt.js +25 -12
- package/dist/prompt.js.map +1 -1
- package/dist/systemUtils.d.ts +10 -0
- package/dist/systemUtils.js +34 -0
- package/dist/systemUtils.js.map +1 -1
- package/dist/utils.d.ts +5 -5
- package/dist/utils.js +45 -39
- package/dist/utils.js.map +1 -1
- package/docs/CONFIGURATION.md +4 -4
- package/docs/RELEASE-HOWTO.md +6 -0
- package/gth-ASK-2025-05-16T14-11-39.md +3 -0
- package/gth-ASK-2025-05-16T14-18-27.md +3 -0
- package/gth-ASK-2025-05-16T14-18-56.md +1 -0
- package/gth-ASK-2025-05-16T14-41-20.md +3 -0
- package/gth-ASK-2025-05-16T14-43-31.md +51 -0
- package/gth-ASK-2025-05-16T16-05-52.md +62 -0
- package/gth-DIFF-review-2025-05-16T16-07-53.md +56 -0
- package/gth-DIFF-review-2025-05-16T16-18-55.md +292 -0
- package/package.json +1 -1
- package/src/commands/askCommand.ts +5 -4
- package/src/commands/reviewCommand.ts +23 -9
- package/src/config.ts +15 -12
- package/src/configs/anthropic.ts +5 -3
- package/src/configs/vertexai.ts +2 -2
- package/src/index.ts +12 -3
- package/src/llmUtils.ts +54 -0
- package/src/modules/questionAnsweringModule.ts +6 -59
- package/src/modules/reviewModule.ts +3 -53
- package/src/prompt.ts +32 -17
- package/src/systemUtils.ts +38 -0
- package/src/utils.ts +49 -42
@@ -115,11 +115,3 @@ Make sure that API keys are accidentally not included into diff.
|
|
115
115
|
- Resource usage
|
116
116
|
|
117
117
|
---
|
118
|
-
|
119
|
-
Provide specific feedback on any areas of concern or suggestions for improvement. Please categorize your feedback (e.g., "Bug," "Suggestion," "Nitpick").
|
120
|
-
|
121
|
-
Important! In the end conclude if you would recommend to approve this PR or not. Use ✅⚠️❌ symbols to highlight your feedback appropriately.
|
122
|
-
|
123
|
-
Thank you for your thorough review!
|
124
|
-
|
125
|
-
Important! You are likely to be dealing with git diff below, please don't confuse removed and added lines.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Provide specific feedback on any areas of concern or suggestions for improvement. Please categorize your feedback (e.g., "Bug," "Suggestion," "Nitpick").
|
2
|
+
|
3
|
+
Important! In the end conclude if you would recommend to approve this PR or not. Use ✅⚠️❌ symbols to highlight your feedback appropriately.
|
4
|
+
|
5
|
+
Thank you for your thorough review!
|
6
|
+
|
7
|
+
Important! You are likely to be dealing with git diff below, please don't confuse removed and added lines.
|
package/README.md
CHANGED
@@ -135,7 +135,7 @@ npm install gaunt-sloth-assistant -g
|
|
135
135
|
|
136
136
|
## Configuration
|
137
137
|
|
138
|
-
> Gaunt Sloth currently only functions from the directory which has a configuration file (`.gsloth.config.js`, `.gsloth.config.json`, or `.gsloth.config.mjs`) and `.gsloth.
|
138
|
+
> Gaunt Sloth currently only functions from the directory which has a configuration file (`.gsloth.config.js`, `.gsloth.config.json`, or `.gsloth.config.mjs`) and `.gsloth.guidelines.md`.
|
139
139
|
> Global configuration to invoke gsloth anywhere is in [ROADMAP](ROADMAP.md).
|
140
140
|
|
141
141
|
Configuration can be created with `gsloth init [vendor]` command.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { readBackstory, readGuidelines } from '#src/prompt.js';
|
2
2
|
import { readMultipleFilesFromCurrentDir } from '#src/utils.js';
|
3
|
-
import { initConfig } from '#src/config.js';
|
3
|
+
import { initConfig, slothContext } from '#src/config.js';
|
4
4
|
/**
|
5
5
|
* Adds the ask command to the program
|
6
6
|
* @param program - The commander program
|
@@ -13,14 +13,15 @@ export function askCommand(program) {
|
|
13
13
|
.option('-f, --file [files...]', 'Input files. Content of these files will be added BEFORE the message')
|
14
14
|
// TODO add option consuming extra message as argument
|
15
15
|
.action(async (message, options) => {
|
16
|
-
const preamble = [
|
16
|
+
const preamble = [readBackstory(), readGuidelines(slothContext.config.projectGuidelines)];
|
17
17
|
const content = [message];
|
18
18
|
if (options.file) {
|
19
19
|
content.push(readMultipleFilesFromCurrentDir(options.file));
|
20
20
|
}
|
21
21
|
await initConfig();
|
22
22
|
const { askQuestion } = await import('#src/modules/questionAnsweringModule.js');
|
23
|
-
|
23
|
+
// TODO make the prefix configurable
|
24
|
+
await askQuestion('gth-ASK', preamble.join('\n'), content.join('\n'));
|
24
25
|
});
|
25
26
|
}
|
26
27
|
//# sourceMappingURL=askCommand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"askCommand.js","sourceRoot":"","sources":["../../src/commands/askCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"askCommand.js","sourceRoot":"","sources":["../../src/commands/askCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM1D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO;SACJ,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,gBAAgB,CAAC;SAC7B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;SAClC,MAAM,CACL,uBAAuB,EACvB,sEAAsE,CACvE;QACD,sDAAsD;SACrD,MAAM,CAAC,KAAK,EAAE,OAAe,EAAE,OAA0B,EAAE,EAAE;QAC5D,MAAM,QAAQ,GAAG,CAAC,aAAa,EAAE,EAAE,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC1F,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,UAAU,EAAE,CAAC;QACnB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,yCAAyC,CAAC,CAAC;QAChF,oCAAoC;QACpC,MAAM,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { Option } from 'commander';
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { slothContext } from '#src/config.js';
|
3
|
+
import { readBackstory, readGuidelines, readReviewInstructions } from '#src/prompt.js';
|
4
4
|
import { readMultipleFilesFromCurrentDir } from '#src/utils.js';
|
5
5
|
import { displayError } from '#src/consoleUtils.js';
|
6
|
+
import { getStringFromStdin } from '#src/systemUtils.js';
|
6
7
|
/**
|
7
8
|
* Requirements providers. Expected to be in `.providers/` dir
|
8
9
|
*/
|
@@ -36,7 +37,11 @@ export function reviewCommand(program, context) {
|
|
36
37
|
.action(async (contentId, options) => {
|
37
38
|
const { initConfig } = await import('#src/config.js');
|
38
39
|
await initConfig();
|
39
|
-
const
|
40
|
+
const systemMessage = [
|
41
|
+
readBackstory(),
|
42
|
+
readGuidelines(slothContext.config.projectGuidelines),
|
43
|
+
readReviewInstructions(slothContext.config.projectReviewInstructions),
|
44
|
+
];
|
40
45
|
const content = [];
|
41
46
|
const requirementsId = options.requirements;
|
42
47
|
const requirementsProvider = options.requirementsProvider ??
|
@@ -57,14 +62,16 @@ export function reviewCommand(program, context) {
|
|
57
62
|
if (options.file) {
|
58
63
|
content.push(readMultipleFilesFromCurrentDir(options.file));
|
59
64
|
}
|
60
|
-
|
61
|
-
|
65
|
+
let stringFromStdin = getStringFromStdin();
|
66
|
+
if (stringFromStdin) {
|
67
|
+
content.push(stringFromStdin);
|
62
68
|
}
|
63
69
|
if (options.message) {
|
64
70
|
content.push(options.message);
|
65
71
|
}
|
66
72
|
const { review } = await import('#src/modules/reviewModule.js');
|
67
|
-
|
73
|
+
// TODO make the prefix configurable
|
74
|
+
await review('gth-DIFF-review', systemMessage.join('\n'), content.join('\n'));
|
68
75
|
});
|
69
76
|
program
|
70
77
|
.command('pr')
|
@@ -78,7 +85,11 @@ export function reviewCommand(program, context) {
|
|
78
85
|
.action(async (prId, requirementsId, options) => {
|
79
86
|
const { initConfig } = await import('#src/config.js');
|
80
87
|
await initConfig();
|
81
|
-
const
|
88
|
+
const systemMessage = [
|
89
|
+
readBackstory(),
|
90
|
+
readGuidelines(slothContext.config.projectGuidelines),
|
91
|
+
readReviewInstructions(slothContext.config.projectReviewInstructions),
|
92
|
+
];
|
82
93
|
const content = [];
|
83
94
|
const requirementsProvider = options.requirementsProvider ??
|
84
95
|
context.config?.pr?.requirementsProvider ??
|
@@ -96,7 +107,10 @@ export function reviewCommand(program, context) {
|
|
96
107
|
const { get } = await import(providerPath);
|
97
108
|
content.push(await get(null, prId));
|
98
109
|
const { review } = await import('#src/modules/reviewModule.js');
|
99
|
-
|
110
|
+
// TODO make the prefix configurable
|
111
|
+
// TODO consider including requirements id
|
112
|
+
// TODO sanitize prId
|
113
|
+
await review(`gth-PR-${prId}-review`, systemMessage.join('\n'), content.join('\n'));
|
100
114
|
});
|
101
115
|
async function getRequirementsFromProvider(requirementsProvider, requirementsId) {
|
102
116
|
return getFromProvider(requirementsProvider, requirementsId, (context.config?.requirementsProviderConfig ?? {})[requirementsProvider], REQUIREMENTS_PROVIDERS);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"reviewCommand.js","sourceRoot":"","sources":["../../src/commands/reviewCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"reviewCommand.js","sourceRoot":"","sources":["../../src/commands/reviewCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;GAEG;AACH,MAAM,sBAAsB,GAAG;IAC7B,aAAa,EAAE,4BAA4B;IAC3C,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CACP,CAAC;AAIX;;GAEG;AACH,MAAM,iBAAiB,GAAG;IACxB,EAAE,EAAE,qBAAqB;IACzB,IAAI,EAAE,SAAS;IACf,I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AC;YAC/B,CAAC;iBAAM,CAAC;gBACN,YAAY,CAAC,qBAAqB,QAAQ,0BAA0B,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC1C,yCAAyC;YACzC,OAAO,MAAO,QAAwD,CAAC,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
2
2
|
export interface SlothConfig extends BaseSlothConfig {
|
3
|
-
llm:
|
3
|
+
llm: BaseChatModel;
|
4
4
|
contentProvider: string;
|
5
5
|
requirementsProvider: string;
|
6
|
+
projectGuidelines: string;
|
7
|
+
projectReviewInstructions: string;
|
6
8
|
commands: {
|
7
9
|
pr: {
|
8
10
|
contentProvider: string;
|
@@ -22,6 +24,8 @@ interface BaseSlothConfig {
|
|
22
24
|
llm: unknown;
|
23
25
|
contentProvider?: string;
|
24
26
|
requirementsProvider?: string;
|
27
|
+
projectGuidelines?: string;
|
28
|
+
projectReviewInstructions?: string;
|
25
29
|
commands?: {
|
26
30
|
pr: {
|
27
31
|
contentProvider: string;
|
@@ -43,7 +47,6 @@ interface BaseSlothConfig {
|
|
43
47
|
*/
|
44
48
|
export interface SlothContext {
|
45
49
|
config: SlothConfig;
|
46
|
-
stdin: string;
|
47
50
|
session: {
|
48
51
|
configurable: {
|
49
52
|
thread_id: string;
|
@@ -58,7 +61,8 @@ export declare const USER_PROJECT_CONFIG_JS = ".gsloth.config.js";
|
|
58
61
|
export declare const USER_PROJECT_CONFIG_JSON = ".gsloth.config.json";
|
59
62
|
export declare const USER_PROJECT_CONFIG_MJS = ".gsloth.config.mjs";
|
60
63
|
export declare const GSLOTH_BACKSTORY = ".gsloth.backstory.md";
|
61
|
-
export declare const
|
64
|
+
export declare const PROJECT_GUIDELINES = ".gsloth.guidelines.md";
|
65
|
+
export declare const PROJECT_REVIEW_INSTRUCTIONS = ".gsloth.review.md";
|
62
66
|
export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq"];
|
63
67
|
export type ConfigType = (typeof availableDefaultConfigs)[number];
|
64
68
|
export declare const DEFAULT_CONFIG: Partial<SlothConfig>;
|
package/dist/config.js
CHANGED
@@ -8,12 +8,15 @@ export const USER_PROJECT_CONFIG_JS = '.gsloth.config.js';
|
|
8
8
|
export const USER_PROJECT_CONFIG_JSON = '.gsloth.config.json';
|
9
9
|
export const USER_PROJECT_CONFIG_MJS = '.gsloth.config.mjs';
|
10
10
|
export const GSLOTH_BACKSTORY = '.gsloth.backstory.md';
|
11
|
-
export const
|
11
|
+
export const PROJECT_GUIDELINES = '.gsloth.guidelines.md';
|
12
|
+
export const PROJECT_REVIEW_INSTRUCTIONS = '.gsloth.review.md';
|
12
13
|
export const availableDefaultConfigs = ['vertexai', 'anthropic', 'groq'];
|
13
14
|
export const DEFAULT_CONFIG = {
|
14
15
|
llm: undefined,
|
15
16
|
contentProvider: 'file',
|
16
17
|
requirementsProvider: 'file',
|
18
|
+
projectGuidelines: PROJECT_GUIDELINES,
|
19
|
+
projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
|
17
20
|
commands: {
|
18
21
|
pr: {
|
19
22
|
contentProvider: 'gh',
|
@@ -141,7 +144,7 @@ export async function tryJsonConfig(jsonConfig) {
|
|
141
144
|
export async function createProjectConfig(configType) {
|
142
145
|
displayInfo(`Setting up your project\n`);
|
143
146
|
writeProjectReviewPreamble();
|
144
|
-
displayWarning(`Make sure you add as much detail as possible to your ${
|
147
|
+
displayWarning(`Make sure you add as much detail as possible to your ${PROJECT_GUIDELINES}.\n`);
|
145
148
|
// Check if the config type is in availableDefaultConfigs
|
146
149
|
if (!availableDefaultConfigs.includes(configType)) {
|
147
150
|
displayError(`Unsupported config type: ${configType}. Available types are: ${availableDefaultConfigs.join(', ')}`);
|
@@ -154,13 +157,13 @@ export async function createProjectConfig(configType) {
|
|
154
157
|
}
|
155
158
|
export function writeProjectReviewPreamble() {
|
156
159
|
const currentDir = getCurrentDir();
|
157
|
-
const reviewPreamblePath = path.join(currentDir,
|
160
|
+
const reviewPreamblePath = path.join(currentDir, PROJECT_GUIDELINES);
|
158
161
|
writeFileIfNotExistsWithMessages(reviewPreamblePath, 'You are doing generic code review.\n' +
|
159
162
|
' Important! Please remind user to prepare proper AI preamble in' +
|
160
|
-
|
163
|
+
PROJECT_GUIDELINES +
|
161
164
|
' for this project. Use decent amount of ⚠️ to highlight lack of config.' +
|
162
165
|
' Explicitly mention `' +
|
163
|
-
|
166
|
+
PROJECT_GUIDELINES +
|
164
167
|
'`.');
|
165
168
|
}
|
166
169
|
/**
|
@@ -172,7 +175,6 @@ export function reset() {
|
|
172
175
|
delete slothContext[key];
|
173
176
|
});
|
174
177
|
slothContext.config = DEFAULT_CONFIG;
|
175
|
-
slothContext.stdin = '';
|
176
178
|
slothContext.session = { configurable: { thread_id: uuidv4() } };
|
177
179
|
}
|
178
180
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,iBAAiB,CAAC;AACnC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,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,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","s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BAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IACrE,gCAAgC,CAC9B,kBAAkB,EAClB,sCAAsC;QACpC,iEAAiE;QACjE,kBAAkB;QAClB,yEAAyE;QACzE,uBAAuB;QACvB,kBAAkB;QAClB,IAAI,CACP,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK;IACnB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACxC,OAAQ,YAAmD,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IACH,YAAY,CAAC,MAAM,GAAG,cAA6B,CAAC;IACpD,YAAY,CAAC,OAAO,GAAG,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACnE,CAAC"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { LanguageModelLike } from '@langchain/core/language_models/base';
|
2
1
|
import type { AnthropicInput } from '@langchain/anthropic';
|
3
|
-
import type { BaseChatModelParams } from '@langchain/core/language_models/chat_models';
|
4
|
-
export declare function processJsonConfig(llmConfig: AnthropicInput & BaseChatModelParams): Promise<
|
2
|
+
import type { BaseChatModel, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
|
3
|
+
export declare function processJsonConfig(llmConfig: AnthropicInput & BaseChatModelParams): Promise<BaseChatModel>;
|
5
4
|
export declare function init(configFileName: string): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/configs/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/configs/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAOjE,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA+C;IAE/C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACvD,wEAAwE;IACxE,MAAM,eAAe,GAAG,GAAG,CAAC,iBAAiB,IAAI,SAAS,CAAC,MAAM,CAAC;IAClE,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC;QACjC,GAAG,SAAS;QACZ,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,4BAA4B;KACvD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,SAAS,GAAG;;;;;;;;;;;;;CAajB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;EAMlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAEtC,yDAAyD;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,gCAAgC,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,cAAc,CAAC,2BAA2B,cAAc,iCAAiC,CAAC,CAAC;AAC7F,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { LanguageModelLike } from '@langchain/core/language_models/base';
|
2
1
|
import { ChatVertexAIInput } from '@langchain/google-vertexai';
|
2
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
3
3
|
export declare function init(configFileName: string): void;
|
4
|
-
export declare function processJsonConfig(llmConfig: ChatVertexAIInput): Promise<
|
4
|
+
export declare function processJsonConfig(llmConfig: ChatVertexAIInput): Promise<BaseChatModel>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vertexai.js","sourceRoot":"","sources":["../../src/configs/vertexai.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"vertexai.js","sourceRoot":"","sources":["../../src/configs/vertexai.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAIjE,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;CAejB,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;EAMlB,CAAC;AAEH,MAAM,UAAU,IAAI,CAAC,cAAsB;IACzC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAEtC,yDAAyD;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,gCAAgC,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC1D,cAAc,CACZ,+GAA+G,CAChH,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAA4B;IAClE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAC5D,OAAO,IAAI,QAAQ,CAAC,YAAY,CAAC;QAC/B,GAAG,SAAS;QACZ,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,8BAA8B;KACzD,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.js
CHANGED
@@ -3,12 +3,21 @@ import { askCommand } from '#src/commands/askCommand.js';
|
|
3
3
|
import { initCommand } from '#src/commands/initCommand.js';
|
4
4
|
import { reviewCommand } from '#src/commands/reviewCommand.js';
|
5
5
|
import { slothContext } from '#src/config.js';
|
6
|
-
import { getSlothVersion
|
6
|
+
import { getSlothVersion } from '#src/utils.js';
|
7
|
+
import { argv, readStdin } from '#src/systemUtils.js';
|
8
|
+
import { setVerbose } from '#src/llmUtils.js';
|
7
9
|
const program = new Command();
|
8
10
|
program
|
9
11
|
.name('gsloth')
|
10
12
|
.description('Gaunt Sloth Assistant reviewing your PRs')
|
11
|
-
.version(getSlothVersion())
|
13
|
+
.version(getSlothVersion())
|
14
|
+
.option('--verbose', 'Print entire prompt sent to LLM.');
|
15
|
+
// Parse global options before binding any commands
|
16
|
+
program.parseOptions(argv);
|
17
|
+
if (program.getOptionValue('verbose')) {
|
18
|
+
// Set global prompt debug
|
19
|
+
setVerbose(true);
|
20
|
+
}
|
12
21
|
initCommand(program);
|
13
22
|
reviewCommand(program, slothContext);
|
14
23
|
askCommand(program);
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,
|
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,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,eAAe,EAAE,CAAC;KAC1B,MAAM,CAAC,WAAW,EAAE,kCAAkC,CAAC,CAAC;AAE3D,mDAAmD;AACnD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC3B,IAAI,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;IACtC,0BAA0B;IAC1B,UAAU,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC;AAED,WAAW,CAAC,OAAO,CAAC,CAAC;AACrB,aAAa,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACrC,UAAU,CAAC,OAAO,CAAC,CAAC;AACpB,4CAA4C;AAE5C,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
2
|
+
import { BaseLanguageModelCallOptions } from '@langchain/core/language_models/base';
|
3
|
+
export declare function invoke(llm: BaseChatModel, options: Partial<BaseLanguageModelCallOptions>, systemMessage: string, prompt: string): Promise<string>;
|
4
|
+
export declare function setVerbose(debug: boolean): void;
|
package/dist/llmUtils.js
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
2
|
+
import { END, MemorySaver, MessagesAnnotation, START, StateGraph } from '@langchain/langgraph';
|
3
|
+
const llmGlobalSettings = {
|
4
|
+
verbose: false,
|
5
|
+
};
|
6
|
+
export async function invoke(llm, options, systemMessage, prompt) {
|
7
|
+
if (llmGlobalSettings.verbose) {
|
8
|
+
llm.verbose = true;
|
9
|
+
}
|
10
|
+
// This node receives the current state (messages) and invokes the LLM
|
11
|
+
const callModel = async (state) => {
|
12
|
+
// state.messages will contain the list including the system systemMessage and user diff
|
13
|
+
const response = await llm.invoke(state.messages);
|
14
|
+
// MessagesAnnotation expects the node to return the new message(s) to be added to the state.
|
15
|
+
// Wrap the response in an array if it's a single message object.
|
16
|
+
return { messages: response };
|
17
|
+
};
|
18
|
+
// Define the graph structure with MessagesAnnotation state
|
19
|
+
const workflow = new StateGraph(MessagesAnnotation)
|
20
|
+
// Define the node and edge
|
21
|
+
.addNode('model', callModel)
|
22
|
+
.addEdge(START, 'model') // Start at the 'model' node
|
23
|
+
.addEdge('model', END); // End after the 'model' node completes
|
24
|
+
// Set up memory (optional but good practice for potential future multi-turn interactions)
|
25
|
+
const memory = new MemorySaver();
|
26
|
+
// Compile the workflow into a runnable app
|
27
|
+
const app = workflow.compile({ checkpointer: memory });
|
28
|
+
// Construct the initial the messages including the systemMessage as a system message
|
29
|
+
const messages = [new SystemMessage(systemMessage), new HumanMessage(prompt)];
|
30
|
+
const output = await app.invoke({ messages }, options);
|
31
|
+
const lastMessage = output.messages[output.messages.length - 1];
|
32
|
+
return typeof lastMessage.content === 'string'
|
33
|
+
? lastMessage.content
|
34
|
+
: JSON.stringify(lastMessage.content);
|
35
|
+
}
|
36
|
+
export function setVerbose(debug) {
|
37
|
+
llmGlobalSettings.verbose = debug;
|
38
|
+
}
|
39
|
+
//# sourceMappingURL=ll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AqF;IACrF,MAAM,QAAQ,GAAc,CAAC,IAAI,aAAa,CAAC,aAAa,CAAC,EAAE,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAChE,OAAO,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ;QAC5C,CAAC,CAAC,WAAW,CAAC,OAAO;QACrB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,iBAAiB,CAAC,OAAO,GAAG,KAAK,CAAC;AACpC,CAAC"}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import type { SlothContext } from '#src/config.js';
|
2
|
-
import type { ProgressCallback } from '#src/modules/types.js';
|
3
1
|
/**
|
4
2
|
* Ask a question and get an answer from the LLM
|
5
3
|
* @param source - The source of the question (used for file naming)
|
@@ -7,12 +5,3 @@ import type { ProgressCallback } from '#src/modules/types.js';
|
|
7
5
|
* @param content - The content of the question
|
8
6
|
*/
|
9
7
|
export declare function askQuestion(source: string, preamble: string, content: string): Promise<void>;
|
10
|
-
/**
|
11
|
-
* Inner function to ask a question and get an answer from the LLM
|
12
|
-
* @param context - The context object
|
13
|
-
* @param indicateProgress - Function to indicate progress
|
14
|
-
* @param preamble - The preamble to send to the LLM
|
15
|
-
* @param content - The content of the question
|
16
|
-
* @returns The answer from the LLM
|
17
|
-
*/
|
18
|
-
export declare function askQuestionInner(context: SlothContext, indicateProgress: ProgressCallback, preamble: string, content: string): Promise<string>;
|
@@ -2,10 +2,9 @@ import { slothContext } from '#src/config.js';
|
|
2
2
|
import { display, displayError, displaySuccess } from '#src/consoleUtils.js';
|
3
3
|
import { getCurrentDir } from '#src/systemUtils.js';
|
4
4
|
import { fileSafeLocalDate, ProgressIndicator, toFileSafeString } from '#src/utils.js';
|
5
|
-
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
6
|
-
import { END, MemorySaver, MessagesAnnotation, START, StateGraph } from '@langchain/langgraph';
|
7
5
|
import { writeFileSync } from 'node:fs';
|
8
6
|
import * as path from 'node:path';
|
7
|
+
import { invoke } from '#src/llmUtils.js';
|
9
8
|
/**
|
10
9
|
* Ask a question and get an answer from the LLM
|
11
10
|
* @param source - The source of the question (used for file naming)
|
@@ -14,10 +13,11 @@ import * as path from 'node:path';
|
|
14
13
|
*/
|
15
14
|
export async function askQuestion(source, preamble, content) {
|
16
15
|
const progressIndicator = new ProgressIndicator('Thinking.');
|
17
|
-
const outputContent = await
|
16
|
+
const outputContent = await invoke(slothContext.config.llm, slothContext.session, preamble, content);
|
17
|
+
progressIndicator.stop();
|
18
18
|
const filePath = path.resolve(getCurrentDir(), toFileSafeString(source) + '-' + fileSafeLocalDate() + '.md');
|
19
19
|
display(`\nwriting ${filePath}`);
|
20
|
-
// TODO highlight LLM output with something like Prism.JS
|
20
|
+
// TODO highlight LLM output with something like Prism.JS (maybe system emoj are enough ✅⚠️❌)
|
21
21
|
display('\n' + outputContent);
|
22
22
|
try {
|
23
23
|
writeFileSync(filePath, outputContent);
|
@@ -30,43 +30,4 @@ export async function askQuestion(source, preamble, content) {
|
|
30
30
|
// exit(1);
|
31
31
|
}
|
32
32
|
}
|
33
|
-
/**
|
34
|
-
* Inner function to ask a question and get an answer from the LLM
|
35
|
-
* @param context - The context object
|
36
|
-
* @param indicateProgress - Function to indicate progress
|
37
|
-
* @param preamble - The preamble to send to the LLM
|
38
|
-
* @param content - The content of the question
|
39
|
-
* @returns The answer from the LLM
|
40
|
-
*/
|
41
|
-
export async function askQuestionInner(context, indicateProgress, preamble, content) {
|
42
|
-
// This node receives the current state (messages) and invokes the LLM
|
43
|
-
const callModel = async (state) => {
|
44
|
-
// state.messages will contain the list including the system preamble and user diff
|
45
|
-
const response = await context.config.llm.invoke(state.messages);
|
46
|
-
// MessagesAnnotation expects the node to return the new message(s) to be added to the state.
|
47
|
-
// Wrap the response in an array if it's a single message object.
|
48
|
-
return { messages: response };
|
49
|
-
};
|
50
|
-
// Define the graph structure with MessagesAnnotation state
|
51
|
-
const workflow = new StateGraph(MessagesAnnotation)
|
52
|
-
// Define the node and edge
|
53
|
-
.addNode('model', callModel)
|
54
|
-
.addEdge(START, 'model') // Start at the 'model' node
|
55
|
-
.addEdge('model', END); // End after the 'model' node completes
|
56
|
-
// Set up memory (optional but good practice for potential future multi-turn interactions)
|
57
|
-
const memory = new MemorySaver();
|
58
|
-
// Compile the workflow into a runnable app
|
59
|
-
const app = workflow.compile({ checkpointer: memory });
|
60
|
-
// Construct the initial the messages including the preamble as a system message
|
61
|
-
const messages = [new SystemMessage(preamble), new HumanMessage(content)];
|
62
|
-
indicateProgress();
|
63
|
-
// TODO create proper progress indicator for async tasks.
|
64
|
-
const progress = setInterval(() => indicateProgress(), 1000);
|
65
|
-
const output = await app.invoke({ messages }, context.session);
|
66
|
-
clearInterval(progress);
|
67
|
-
const lastMessage = output.messages[output.messages.length - 1];
|
68
|
-
return typeof lastMessage.content === 'string'
|
69
|
-
? lastMessage.content
|
70
|
-
: JSON.stringify(lastMessage.content);
|
71
|
-
}
|
72
33
|
//# sourceMappingURL=questionAnsweringModule.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"questionAnsweringModule.js","sourceRoot":"","sources":["../../src/modules/questionAnsweringModule.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"questionAnsweringModule.js","sourceRoot":"","sources":["../../src/modules/questionAnsweringModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB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W;IACb,CAAC;AACH,CAAC"}
|
@@ -1,4 +1 @@
|
|
1
|
-
import type { SlothContext } from '#src/config.js';
|
2
|
-
import type { ProgressCallback } from '#src/modules/types.js';
|
3
1
|
export declare function review(source: string, preamble: string, diff: string): Promise<void>;
|
4
|
-
export declare function reviewInner(context: SlothContext, indicateProgress: ProgressCallback, preamble: string, diff: string): Promise<string>;
|
@@ -2,13 +2,13 @@ import { slothContext } from '#src/config.js';
|
|
2
2
|
import { display, displayDebug, displayError, displaySuccess } from '#src/consoleUtils.js';
|
3
3
|
import { getCurrentDir, stdout } from '#src/systemUtils.js';
|
4
4
|
import { fileSafeLocalDate, ProgressIndicator, toFileSafeString } from '#src/utils.js';
|
5
|
-
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
6
|
-
import { END, MemorySaver, MessagesAnnotation, START, StateGraph } from '@langchain/langgraph';
|
7
5
|
import { writeFileSync } from 'node:fs';
|
8
6
|
import path from 'node:path';
|
7
|
+
import { invoke } from '#src/llmUtils.js';
|
9
8
|
export async function review(source, preamble, diff) {
|
10
9
|
const progressIndicator = new ProgressIndicator('Reviewing.');
|
11
|
-
const outputContent = await
|
10
|
+
const outputContent = await invoke(slothContext.config.llm, slothContext.session, preamble, diff);
|
11
|
+
progressIndicator.stop();
|
12
12
|
const filePath = path.resolve(getCurrentDir(), toFileSafeString(source) + '-' + fileSafeLocalDate() + '.md');
|
13
13
|
stdout.write('\n');
|
14
14
|
display(`writing ${filePath}`);
|
@@ -26,35 +26,4 @@ export async function review(source, preamble, diff) {
|
|
26
26
|
// exit(1);
|
27
27
|
}
|
28
28
|
}
|
29
|
-
export async function reviewInner(context, indicateProgress, preamble, diff) {
|
30
|
-
// This node receives the current state (messages) and invokes the LLM
|
31
|
-
const callModel = async (state) => {
|
32
|
-
// state.messages will contain the list including the system preamble and user diff
|
33
|
-
const response = await context.config.llm.invoke(state.messages);
|
34
|
-
// MessagesAnnotation expects the node to return the new message(s) to be added to the state.
|
35
|
-
// Wrap the response in an array if it's a single message object.
|
36
|
-
return { messages: response };
|
37
|
-
};
|
38
|
-
// Define the graph structure with MessagesAnnotation state
|
39
|
-
const workflow = new StateGraph(MessagesAnnotation)
|
40
|
-
// Define the node and edge
|
41
|
-
.addNode('model', callModel)
|
42
|
-
.addEdge(START, 'model') // Start at the 'model' node
|
43
|
-
.addEdge('model', END); // End after the 'model' node completes
|
44
|
-
// Set up memory (optional but good practice for potential future multi-turn interactions)
|
45
|
-
const memory = new MemorySaver(); // TODO extract to config
|
46
|
-
// Compile the workflow into a runnable app
|
47
|
-
const app = workflow.compile({ checkpointer: memory });
|
48
|
-
// Construct the initial the messages including the preamble as a system message
|
49
|
-
const messages = [new SystemMessage(preamble), new HumanMessage(diff)];
|
50
|
-
indicateProgress();
|
51
|
-
// TODO create proper progress indicator for async tasks.
|
52
|
-
const progress = setInterval(() => indicateProgress(), 1000);
|
53
|
-
const output = await app.invoke({ messages }, context.session);
|
54
|
-
clearInterval(progress);
|
55
|
-
const lastMessage = output.messages[output.messages.length - 1];
|
56
|
-
return typeof lastMessage.content === 'string'
|
57
|
-
? lastMessage.content
|
58
|
-
: JSON.stringify(lastMessage.content);
|
59
|
-
}
|
60
29
|
//# sourceMappingURL=reviewModule.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"reviewModule.js","sourceRoot":"","sources":["../../src/modules/reviewModule.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"reviewModule.js","sourceRoot":"","sources":["../../src/modules/reviewModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;A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
export declare function
|
2
|
-
export declare function
|
1
|
+
export declare function readBackstory(): string;
|
2
|
+
export declare function readGuidelines(guidelinesFilename: string): string;
|
3
|
+
export declare function readReviewInstructions(reviewInstructions: string): string;
|
3
4
|
/**
|
4
5
|
* This function expects https://cli.github.com/ to be installed and authenticated.
|
5
6
|
* It does something like `gh pr diff 42`
|