gaunt-sloth-assistant 0.4.2 → 0.5.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.
Files changed (135) hide show
  1. package/.claude/settings.local.json +15 -0
  2. package/.gsloth.backstory.md +0 -0
  3. package/.gsloth.guidelines.md +0 -0
  4. package/.gsloth.review.md +0 -0
  5. package/.gsloth.system.md +10 -0
  6. package/.prettierrc.json +0 -0
  7. package/CLAUDE.md +1 -0
  8. package/LICENSE +0 -0
  9. package/README.md +11 -1
  10. package/ROADMAP.md +0 -0
  11. package/assets/gaunt-sloth-logo.png +0 -0
  12. package/assets/release-notes/v0_4_0.md +0 -0
  13. package/assets/release-notes/v0_5_0.md +10 -0
  14. package/assets/release-notes/v0_5_1.md +47 -0
  15. package/dist/commands/askCommand.d.ts +0 -0
  16. package/dist/commands/askCommand.js +9 -5
  17. package/dist/commands/askCommand.js.map +1 -1
  18. package/dist/commands/commandUtils.d.ts +25 -0
  19. package/dist/commands/commandUtils.js +48 -0
  20. package/dist/commands/commandUtils.js.map +1 -0
  21. package/dist/commands/initCommand.d.ts +0 -0
  22. package/dist/commands/initCommand.js +0 -0
  23. package/dist/commands/initCommand.js.map +0 -0
  24. package/dist/commands/prCommand.d.ts +2 -0
  25. package/dist/commands/prCommand.js +52 -0
  26. package/dist/commands/prCommand.js.map +1 -0
  27. package/dist/commands/reviewCommand.d.ts +1 -2
  28. package/dist/commands/reviewCommand.js +17 -98
  29. package/dist/commands/reviewCommand.js.map +1 -1
  30. package/dist/config.d.ts +22 -41
  31. package/dist/config.js +107 -88
  32. package/dist/config.js.map +1 -1
  33. package/dist/configs/anthropic.d.ts +0 -0
  34. package/dist/configs/anthropic.js +0 -0
  35. package/dist/configs/anthropic.js.map +0 -0
  36. package/dist/configs/fake.d.ts +0 -0
  37. package/dist/configs/fake.js +0 -0
  38. package/dist/configs/fake.js.map +0 -0
  39. package/dist/configs/groq.d.ts +0 -0
  40. package/dist/configs/groq.js +0 -0
  41. package/dist/configs/groq.js.map +0 -0
  42. package/dist/configs/vertexai.d.ts +0 -0
  43. package/dist/configs/vertexai.js +0 -0
  44. package/dist/configs/vertexai.js.map +0 -0
  45. package/dist/consoleUtils.d.ts +0 -0
  46. package/dist/consoleUtils.js +0 -0
  47. package/dist/consoleUtils.js.map +0 -0
  48. package/dist/constants.d.ts +7 -0
  49. package/dist/constants.js +8 -0
  50. package/dist/constants.js.map +1 -0
  51. package/dist/filePathUtils.d.ts +0 -0
  52. package/dist/filePathUtils.js +0 -0
  53. package/dist/filePathUtils.js.map +0 -0
  54. package/dist/index.d.ts +0 -0
  55. package/dist/index.js +4 -2
  56. package/dist/index.js.map +1 -1
  57. package/dist/llmUtils.d.ts +2 -2
  58. package/dist/llmUtils.js +128 -28
  59. package/dist/llmUtils.js.map +1 -1
  60. package/dist/modules/questionAnsweringModule.d.ts +2 -1
  61. package/dist/modules/questionAnsweringModule.js +7 -8
  62. package/dist/modules/questionAnsweringModule.js.map +1 -1
  63. package/dist/modules/reviewModule.d.ts +2 -1
  64. package/dist/modules/reviewModule.js +7 -11
  65. package/dist/modules/reviewModule.js.map +1 -1
  66. package/dist/modules/types.d.ts +0 -0
  67. package/dist/modules/types.js +0 -0
  68. package/dist/modules/types.js.map +0 -0
  69. package/dist/prompt.d.ts +1 -0
  70. package/dist/prompt.js +4 -1
  71. package/dist/prompt.js.map +1 -1
  72. package/dist/providers/file.d.ts +0 -0
  73. package/dist/providers/file.js +0 -0
  74. package/dist/providers/file.js.map +0 -0
  75. package/dist/providers/ghIssueProvider.d.ts +0 -0
  76. package/dist/providers/ghIssueProvider.js +3 -1
  77. package/dist/providers/ghIssueProvider.js.map +1 -1
  78. package/dist/providers/ghPrDiffProvider.d.ts +0 -0
  79. package/dist/providers/ghPrDiffProvider.js +3 -1
  80. package/dist/providers/ghPrDiffProvider.js.map +1 -1
  81. package/dist/providers/jiraIssueLegacyProvider.d.ts +0 -0
  82. package/dist/providers/jiraIssueLegacyProvider.js +0 -0
  83. package/dist/providers/jiraIssueLegacyProvider.js.map +0 -0
  84. package/dist/providers/jiraIssueProvider.d.ts +0 -0
  85. package/dist/providers/jiraIssueProvider.js +3 -1
  86. package/dist/providers/jiraIssueProvider.js.map +1 -1
  87. package/dist/providers/text.d.ts +0 -0
  88. package/dist/providers/text.js +0 -0
  89. package/dist/providers/text.js.map +0 -0
  90. package/dist/providers/types.d.ts +0 -0
  91. package/dist/providers/types.js +0 -0
  92. package/dist/providers/types.js.map +0 -0
  93. package/dist/systemUtils.d.ts +0 -0
  94. package/dist/systemUtils.js +0 -0
  95. package/dist/systemUtils.js.map +0 -0
  96. package/dist/utils.d.ts +0 -0
  97. package/dist/utils.js +0 -0
  98. package/dist/utils.js.map +0 -0
  99. package/docs/CONFIGURATION.md +60 -26
  100. package/docs/DEVELOPMENT.md +0 -0
  101. package/docs/RELEASE-HOWTO.md +0 -0
  102. package/eslint.config.js +0 -0
  103. package/maintenance/doc-maintenance.md +0 -0
  104. package/package.json +11 -7
  105. package/src/commands/askCommand.ts +9 -5
  106. package/src/commands/commandUtils.ts +77 -0
  107. package/src/commands/initCommand.ts +0 -0
  108. package/src/commands/prCommand.ts +93 -0
  109. package/src/commands/reviewCommand.ts +33 -155
  110. package/src/config.ts +128 -128
  111. package/src/configs/anthropic.ts +0 -0
  112. package/src/configs/fake.ts +0 -0
  113. package/src/configs/groq.ts +0 -0
  114. package/src/configs/vertexai.ts +0 -0
  115. package/src/consoleUtils.ts +0 -0
  116. package/src/constants.ts +7 -0
  117. package/src/filePathUtils.ts +0 -0
  118. package/src/index.ts +4 -2
  119. package/src/llmUtils.ts +149 -36
  120. package/src/modules/questionAnsweringModule.ts +9 -13
  121. package/src/modules/reviewModule.ts +14 -11
  122. package/src/modules/types.ts +0 -0
  123. package/src/prompt.ts +5 -1
  124. package/src/providers/file.ts +0 -0
  125. package/src/providers/ghIssueProvider.ts +3 -1
  126. package/src/providers/ghPrDiffProvider.ts +3 -1
  127. package/src/providers/jiraIssueLegacyProvider.ts +0 -0
  128. package/src/providers/jiraIssueProvider.ts +5 -1
  129. package/src/providers/text.ts +0 -0
  130. package/src/providers/types.ts +0 -0
  131. package/src/systemUtils.ts +0 -0
  132. package/src/utils.ts +0 -0
  133. package/tsconfig.json +0 -0
  134. package/vitest-it.config.ts +0 -0
  135. package/vitest.config.ts +0 -0
@@ -1,22 +1,25 @@
1
- import { slothContext } from '#src/config.js';
1
+ import type { SlothConfig } from '#src/config.js';
2
2
  import { display, displayDebug, displayError, displaySuccess } from '#src/consoleUtils.js';
3
- import { stdout } from '#src/systemUtils.js';
4
3
  import { generateStandardFileName, ProgressIndicator } from '#src/utils.js';
5
4
  import { writeFileSync } from 'node:fs';
6
5
  import { invoke } from '#src/llmUtils.js';
7
6
  import { getGslothFilePath } from '#src/filePathUtils.js';
8
7
 
9
- export async function review(source: string, preamble: string, diff: string): Promise<void> {
10
- const progressIndicator = new ProgressIndicator('Reviewing.');
11
- const outputContent = await invoke(slothContext.config.llm, slothContext.session, preamble, diff);
12
- progressIndicator.stop();
8
+ export async function review(
9
+ source: string,
10
+ preamble: string,
11
+ diff: string,
12
+ config: SlothConfig,
13
+ command: 'pr' | 'review' = 'review'
14
+ ): Promise<void> {
15
+ const progressIndicator = config.streamOutput ? undefined : new ProgressIndicator('Reviewing.');
16
+ const outputContent = await invoke(config.llm, preamble, diff, config, command);
17
+ progressIndicator?.stop();
13
18
  const filename = generateStandardFileName(source);
14
19
  const filePath = getGslothFilePath(filename);
15
- stdout.write('\n');
16
- display(`writing ${filePath}`);
17
- stdout.write('\n');
18
- // TODO highlight LLM output with something like Prism.JS (maybe system emoj are enough ✅⚠️❌)
19
- display(outputContent);
20
+ if (!config.streamOutput) {
21
+ display('\n' + outputContent);
22
+ }
20
23
  try {
21
24
  writeFileSync(filePath, outputContent);
22
25
  displaySuccess(`This report can be found in ${filePath}`);
File without changes
package/src/prompt.ts CHANGED
@@ -5,7 +5,7 @@ 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 { GSLOTH_BACKSTORY } from '#src/config.js';
8
+ import { GSLOTH_BACKSTORY, GSLOTH_SYSTEM_PROMPT } from '#src/constants.js';
9
9
  import { getGslothConfigReadPath } from '#src/filePathUtils.js';
10
10
 
11
11
  export function readBackstory(): string {
@@ -28,6 +28,10 @@ export function readReviewInstructions(reviewInstructions: string): string {
28
28
  return readConfigPromptFile(reviewInstructions);
29
29
  }
30
30
 
31
+ export function readSystemPrompt(): string {
32
+ return readFileFromCurrentOrInstallDir(GSLOTH_SYSTEM_PROMPT, true);
33
+ }
34
+
31
35
  function readConfigPromptFile(guidelinesFilename: string): string {
32
36
  try {
33
37
  const filePath = getGslothConfigReadPath(guidelinesFilename);
File without changes
@@ -1,5 +1,5 @@
1
1
  import { displayWarning } from '#src/consoleUtils.js';
2
- import { execAsync } from '#src/utils.js';
2
+ import { execAsync, ProgressIndicator } from '#src/utils.js';
3
3
  import type { ProviderConfig } from './types.js';
4
4
 
5
5
  /**
@@ -19,7 +19,9 @@ export async function get(
19
19
 
20
20
  try {
21
21
  // Use the GitHub CLI to fetch issue details
22
+ const progress = new ProgressIndicator(`Fetching GitHub issue #${issueId}`);
22
23
  const issueContent = await execAsync(`gh issue view ${issueId}`);
24
+ progress.stop();
23
25
 
24
26
  if (!issueContent) {
25
27
  displayWarning(`No content found for GitHub issue #${issueId}`);
@@ -1,5 +1,5 @@
1
1
  import { displayWarning } from '#src/consoleUtils.js';
2
- import { execAsync } from '#src/utils.js';
2
+ import { execAsync, ProgressIndicator } from '#src/utils.js';
3
3
  import type { ProviderConfig } from './types.js';
4
4
 
5
5
  /**
@@ -19,7 +19,9 @@ export async function get(
19
19
 
20
20
  try {
21
21
  // Use the GitHub CLI to fetch PR diff
22
+ const progress = new ProgressIndicator(`Fetching GitHub PR #${prId} diff`);
22
23
  const prDiffContent = await execAsync(`gh pr diff ${prId}`);
24
+ progress.stop();
23
25
 
24
26
  if (!prDiffContent) {
25
27
  displayWarning(`No diff content found for GitHub PR #${prId}`);
File without changes
@@ -1,6 +1,7 @@
1
1
  import { display, displayError, displayWarning } from '#src/consoleUtils.js';
2
2
  import { env } from '#src/systemUtils.js';
3
3
  import type { JiraConfig } from './types.js';
4
+ import { ProgressIndicator } from '#src/utils.js';
4
5
 
5
6
  interface JiraIssueResponse {
6
7
  fields: {
@@ -105,7 +106,6 @@ async function getJiraIssue(config: JiraConfig, jiraKey: string): Promise<JiraIs
105
106
  if (config.displayUrl) {
106
107
  display(`Loading Jira issue ${config.displayUrl}${jiraKey}`);
107
108
  }
108
- display(`Retrieving jira from api ${apiUrl.replace(/^https?:\/\//, '')}`);
109
109
 
110
110
  // This filter will be necessary for V3: `&expand=renderedFields` to convert ADF to HTML
111
111
  const filters = '?fields=summary,description'; // Limit JSON to summary and description
@@ -122,10 +122,14 @@ async function getJiraIssue(config: JiraConfig, jiraKey: string): Promise<JiraIs
122
122
  'Accept-Language': 'en-US,en;q=0.9', // Prevents errors in other languages
123
123
  };
124
124
 
125
+ const progressIndicator = new ProgressIndicator(
126
+ `Retrieving jira from api ${apiUrl.replace(/^https?:\/\//, '')}`
127
+ );
125
128
  const response = await fetch(apiUrl + filters, {
126
129
  method: 'GET',
127
130
  headers: headers,
128
131
  });
132
+ progressIndicator.stop();
129
133
 
130
134
  if (!response?.ok) {
131
135
  try {
File without changes
File without changes
File without changes
package/src/utils.ts CHANGED
File without changes
package/tsconfig.json CHANGED
File without changes
File without changes
package/vitest.config.ts CHANGED
File without changes