gaunt-sloth 2.0.0-alpha.2 → 2.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/cli.js +43 -10
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/commandIntrospection.d.ts +6 -6
- package/dist/commands/commandIntrospection.js +12 -12
- package/dist/commands/commandIntrospection.js.map +1 -1
- package/dist/commands/commandUtils.d.ts +8 -8
- package/dist/commands/commandUtils.js +20 -20
- package/dist/commands/commandUtils.js.map +1 -1
- package/dist/commands/getCommand.js +7 -7
- package/dist/commands/getCommand.js.map +1 -1
- package/dist/commands/initCommand.js +1 -1
- package/dist/commands/initCommand.js.map +1 -1
- package/dist/commands/prCommand.js +14 -15
- package/dist/commands/prCommand.js.map +1 -1
- package/dist/commands/prDiscovery.js +27 -29
- package/dist/commands/prDiscovery.js.map +1 -1
- package/dist/commands/reviewCommand.js +10 -10
- package/dist/commands/reviewCommand.js.map +1 -1
- package/dist/modules/startSession.js +9 -7
- package/dist/modules/startSession.js.map +1 -1
- package/dist/tools/gthJiraLogWorkTool.js +3 -3
- package/dist/tools/gthJiraLogWorkTool.js.map +1 -1
- package/dist/tui/components/App.js +93 -5
- package/dist/tui/components/App.js.map +1 -1
- package/dist/tui/components/ApprovalPrompt.d.ts +17 -0
- package/dist/tui/components/ApprovalPrompt.js +25 -0
- package/dist/tui/components/ApprovalPrompt.js.map +1 -0
- package/dist/tui/components/LiveTurn.js +4 -3
- package/dist/tui/components/LiveTurn.js.map +1 -1
- package/dist/tui/markdown.js +0 -0
- package/dist/tui/markdown.js.map +1 -1
- package/dist/tui/slashCommands.d.ts +13 -0
- package/dist/tui/slashCommands.js +31 -0
- package/dist/tui/slashCommands.js.map +1 -1
- package/dist/tui/tuiSessionModule.js +63 -1
- package/dist/tui/tuiSessionModule.js.map +1 -1
- package/dist/tui/types.d.ts +24 -1
- package/dist/tui/viewModel.d.ts +6 -0
- package/dist/tui/viewModel.js +1 -0
- package/dist/tui/viewModel.js.map +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -41,6 +41,55 @@ npm install -g gaunt-sloth
|
|
|
41
41
|
|
|
42
42
|
For full usage documentation see the [root README](../../README.md) and [docs/COMMANDS.md](../../docs/COMMANDS.md).
|
|
43
43
|
|
|
44
|
+
## ACP server (editor integration)
|
|
45
|
+
|
|
46
|
+
Gaunt Sloth can run as an [Agent Client Protocol](https://agentclientprotocol.com/) (ACP)
|
|
47
|
+
server, so an ACP host — Zed, JetBrains, a future Pukeko client — can spawn it as a coding
|
|
48
|
+
agent. It speaks ACP JSON-RPC over **stdio** (no port, no flags beyond the switch below); the
|
|
49
|
+
host launches it as a subprocess.
|
|
50
|
+
|
|
51
|
+
Run it through this package:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install -g gaunt-sloth@alpha
|
|
55
|
+
gaunt-sloth --acp-agent
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Install the app (`gaunt-sloth`), not `@gaunt-sloth/agent`.** The agent package also ships a
|
|
59
|
+
standalone `gaunt-sloth-acp` binary, but the LLM providers (`@langchain/anthropic`, `openai`,
|
|
60
|
+
`google`, …) are `peerDependencies` of `@gaunt-sloth/core` that **only this app package
|
|
61
|
+
declares as real dependencies**. A bare `@gaunt-sloth/agent` install leaves those peers unmet,
|
|
62
|
+
so its ACP server has no provider to build a model from. `gaunt-sloth --acp-agent` runs the
|
|
63
|
+
exact same ACP server but resolves providers out of the app's dependency tree, so every
|
|
64
|
+
configured provider works. (`stdout` is the protocol channel and is kept clean — gsloth's
|
|
65
|
+
status/config output is redirected to `stderr`.)
|
|
66
|
+
|
|
67
|
+
Provider credentials and model selection come from your usual gsloth config
|
|
68
|
+
(`.gsloth.config.*` / env vars such as `ANTHROPIC_API_KEY`); the ACP server reads them via the
|
|
69
|
+
same `initConfig` path as the CLI. Run the host from your project directory (or set its `cwd`)
|
|
70
|
+
so config and the per-session workspace resolve correctly.
|
|
71
|
+
|
|
72
|
+
### Zed
|
|
73
|
+
|
|
74
|
+
Add to Zed `settings.json` (or Settings -> External Agents -> Add Agent -> Custom Agent):
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"agent_servers": {
|
|
79
|
+
"Gaunt Sloth": {
|
|
80
|
+
"type": "custom",
|
|
81
|
+
"command": "gaunt-sloth",
|
|
82
|
+
"args": ["--acp-agent"],
|
|
83
|
+
"env": {}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Point `command` at the global `gaunt-sloth` binary (after `npm install -g gaunt-sloth@alpha`),
|
|
90
|
+
or at an absolute path to `cli.js` for a local build. Other ACP hosts (JetBrains, etc.) take
|
|
91
|
+
the same `command` + `args` pair.
|
|
92
|
+
|
|
44
93
|
## Related packages
|
|
45
94
|
|
|
46
95
|
- [`@gaunt-sloth/core`](../core) — Core utilities, config, and agent infrastructure
|
package/cli.js
CHANGED
|
@@ -9,15 +9,48 @@ process.on('warning', (warning) => {
|
|
|
9
9
|
console.warn(warning);
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
12
|
+
// --- ACP server bypass -----------------------------------------------------
|
|
13
|
+
// `gaunt-sloth --acp-agent` runs the Agent Client Protocol (ACP) server instead
|
|
14
|
+
// of the normal CLI, so an ACP host (Zed, JetBrains, a future Pukeko client) can
|
|
15
|
+
// spawn the fat `gaunt-sloth` package as a coding-agent subprocess.
|
|
16
|
+
//
|
|
17
|
+
// Why route ACP through the app rather than the standalone `gaunt-sloth-acp`
|
|
18
|
+
// binary in @gaunt-sloth/agent: the LLM providers (@langchain/anthropic, openai,
|
|
19
|
+
// google, …) are peerDependencies of @gaunt-sloth/core, and only this app package
|
|
20
|
+
// declares them as real dependencies. A bare `@gaunt-sloth/agent` install leaves
|
|
21
|
+
// those peers unmet, so its ACP server has no providers to construct a model from.
|
|
22
|
+
// Starting the same ACP server from here resolves providers out of the app's tree.
|
|
23
|
+
//
|
|
24
|
+
// ACP speaks JSON-RPC over stdio, so stdout MUST stay a clean protocol channel:
|
|
25
|
+
// redirect console.log/info (used by initConfig/status output) to stderr BEFORE
|
|
26
|
+
// touching config, exactly as the standalone `gaunt-sloth-acp` entry does.
|
|
27
|
+
if (process.argv.includes('--acp-agent')) {
|
|
28
|
+
for (const method of ['log', 'info']) {
|
|
29
|
+
console[method] = (...args) => process.stderr.write(args.join(' ') + '\n');
|
|
30
|
+
}
|
|
31
|
+
const [{ initConfig }, { displayError }, { startAcpServer }] = await Promise.all([
|
|
32
|
+
import('@gaunt-sloth/core/config.js'),
|
|
33
|
+
import('@gaunt-sloth/core/utils/consoleUtils.js'),
|
|
34
|
+
import('@gaunt-sloth/agent'),
|
|
35
|
+
]);
|
|
36
|
+
try {
|
|
37
|
+
const config = await initConfig({});
|
|
38
|
+
await startAcpServer(config);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
displayError(`ACP server failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
// This is a minimalistic entry point that sets the installDir in systemUtils
|
|
45
|
+
// and delegates to the compiled TypeScript code in dist/cli.js
|
|
46
|
+
const { setEntryPoint } = await import('./dist/utils/systemUtils.js');
|
|
15
47
|
|
|
16
|
-
// Set the installation directory in systemUtils
|
|
17
|
-
setEntryPoint(import.meta.url);
|
|
48
|
+
// Set the installation directory in systemUtils
|
|
49
|
+
setEntryPoint(import.meta.url);
|
|
18
50
|
|
|
19
|
-
// Import and run the compiled TypeScript code
|
|
20
|
-
import('./dist/cli.js').catch((err) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
51
|
+
// Import and run the compiled TypeScript code
|
|
52
|
+
import('./dist/cli.js').catch((err) => {
|
|
53
|
+
console.error('Failed to load application:', err);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|
|
56
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { coerceBooleanOrString } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
|
13
13
|
const program = new Command();
|
|
14
14
|
program
|
|
15
15
|
.name('gsloth')
|
|
16
|
-
.description('Gaunt Sloth
|
|
16
|
+
.description('Gaunt Sloth reviewing your PRs')
|
|
17
17
|
.version(getSlothVersion())
|
|
18
18
|
.option('--verbose', 'Set LangChain/LangGraph to verbose mode, ' +
|
|
19
19
|
'causing LangChain/LangGraph to log many details to the console. ' +
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,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,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAG1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC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AAO,EAAE,kBAAkB,CAAC,CAAC;AACvC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AACxC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AACzC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AACzC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AACzC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AACxC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAExC,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ContentSourceType, type RequirementSourceType } from '#src/commands/commandUtils.js';
|
|
3
3
|
export type PromptCommandType = 'ask' | 'review' | 'pr' | 'pr-discovery' | 'chat' | 'code' | 'exec';
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
4
|
+
export type SourceCommandType = 'review' | 'pr';
|
|
5
|
+
export type SourceInputType = 'content' | 'requirements';
|
|
6
6
|
export declare function getAskSystemPrompt(config: GthConfig): string;
|
|
7
7
|
export declare function getExecSystemPrompt(config: GthConfig): string;
|
|
8
8
|
export declare function getReviewSystemPrompt(config: GthConfig): string;
|
|
9
9
|
export declare function getCommandSystemPrompt(command: PromptCommandType, config: GthConfig): string;
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
10
|
+
export declare function getEffectiveRequirementSource(command: SourceCommandType, config: GthConfig, cliSource?: RequirementSourceType): RequirementSourceType | undefined;
|
|
11
|
+
export declare function getEffectiveContentSource(command: SourceCommandType, config: GthConfig, cliSource?: ContentSourceType): ContentSourceType | undefined;
|
|
12
|
+
export declare function getCommandSourceInput(command: SourceCommandType, inputType: SourceInputType, id: string | undefined, config: GthConfig, cliSource?: RequirementSourceType | ContentSourceType): Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getContentFromSource, getRequirementsFromSource, } from '#src/commands/commandUtils.js';
|
|
2
2
|
import { buildSystemMessages, readBackstory, readChatPrompt, readCodePrompt, readExecPrompt, readGuidelines, readReviewInstructions, readSystemPrompt, } from '@gaunt-sloth/core/utils/llmUtils.js';
|
|
3
3
|
import { readPrDiscoveryPrompt } from '#src/commands/prDiscovery.js';
|
|
4
4
|
export function getAskSystemPrompt(config) {
|
|
@@ -50,21 +50,21 @@ function flattenSystemMessageContent(config, modePrompt) {
|
|
|
50
50
|
}
|
|
51
51
|
return '';
|
|
52
52
|
}
|
|
53
|
-
export function
|
|
54
|
-
return (
|
|
55
|
-
config?.commands?.[command]?.
|
|
56
|
-
config?.
|
|
53
|
+
export function getEffectiveRequirementSource(command, config, cliSource) {
|
|
54
|
+
return (cliSource ??
|
|
55
|
+
config?.commands?.[command]?.requirementSource ??
|
|
56
|
+
config?.requirementSource);
|
|
57
57
|
}
|
|
58
|
-
export function
|
|
59
|
-
return (
|
|
60
|
-
config?.commands?.[command]?.
|
|
61
|
-
config?.
|
|
58
|
+
export function getEffectiveContentSource(command, config, cliSource) {
|
|
59
|
+
return (cliSource ??
|
|
60
|
+
config?.commands?.[command]?.contentSource ??
|
|
61
|
+
config?.contentSource ??
|
|
62
62
|
(command === 'pr' ? 'github' : undefined));
|
|
63
63
|
}
|
|
64
|
-
export async function
|
|
64
|
+
export async function getCommandSourceInput(command, inputType, id, config, cliSource) {
|
|
65
65
|
if (inputType === 'requirements') {
|
|
66
|
-
return
|
|
66
|
+
return getRequirementsFromSource(getEffectiveRequirementSource(command, config, cliSource), id, config);
|
|
67
67
|
}
|
|
68
|
-
return
|
|
68
|
+
return getContentFromSource(getEffectiveContentSource(command, config, cliSource), id, config);
|
|
69
69
|
}
|
|
70
70
|
//# sourceMappingURL=commandIntrospection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandIntrospection.js","sourceRoot":"","sources":["../../src/commands/commandIntrospection.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"commandIntrospection.js","sourceRoot":"","sources":["../../src/commands/commandIntrospection.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAMrE,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,MAAM,KAAK,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,YAAY,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,OAAO,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,KAAK,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9F,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,YAAY,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,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C,EAAE,CAAC,CAAC;aAClF,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,OAA0B,EAC1B,MAAiB,EACjB,SAAiC;IAEjC,OAAO,CACL,SAAS;QACR,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAuD;QACpF,MAAM,EAAE,iBAAuD,CACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAA0B,EAC1B,MAAiB,EACjB,SAA6B;IAE7B,OAAO,CACL,SAAS;QACR,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,aAA+C;QAC5E,MAAM,EAAE,aAA+C;QACxD,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAA0B,EAC1B,SAA0B,EAC1B,EAAsB,EACtB,MAAiB,EACjB,SAAqD;IAErD,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;QACjC,OAAO,yBAAyB,CAC9B,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAkC,CAAC,EAClF,EAAE,EACF,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,oBAAoB,CACzB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,SAA8B,CAAC,EAC1E,EAAE,EACF,MAAM,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Requirement sources. Aliases are mapped to actual package paths.
|
|
4
4
|
*/
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const REQUIREMENTS_SOURCES: {
|
|
6
6
|
readonly 'jira-legacy': "@gaunt-sloth/review/sources/jiraIssueLegacySource.js";
|
|
7
7
|
readonly jira: "@gaunt-sloth/review/sources/jiraIssueSource.js";
|
|
8
8
|
readonly github: "@gaunt-sloth/review/sources/ghIssueSource.js";
|
|
9
9
|
readonly text: "@gaunt-sloth/review/sources/textSource.js";
|
|
10
10
|
readonly file: "@gaunt-sloth/review/sources/fileSource.js";
|
|
11
11
|
};
|
|
12
|
-
export type
|
|
12
|
+
export type RequirementSourceType = keyof typeof REQUIREMENTS_SOURCES;
|
|
13
13
|
/**
|
|
14
|
-
* Content
|
|
14
|
+
* Content sources. Aliases are mapped to actual package paths.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const CONTENT_SOURCES: {
|
|
17
17
|
readonly github: "@gaunt-sloth/review/sources/ghPrDiffSource.js";
|
|
18
18
|
readonly text: "@gaunt-sloth/review/sources/textSource.js";
|
|
19
19
|
readonly file: "@gaunt-sloth/review/sources/fileSource.js";
|
|
20
20
|
};
|
|
21
|
-
export type
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
21
|
+
export type ContentSourceType = keyof typeof CONTENT_SOURCES;
|
|
22
|
+
export declare function getRequirementsFromSource(requirementSource: RequirementSourceType | undefined, requirementsId: string | undefined, config: GthConfig): Promise<string>;
|
|
23
|
+
export declare function getContentFromSource(contentSource: ContentSourceType | undefined, contentId: string | undefined, config: GthConfig): Promise<string>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { displayError } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
2
2
|
import { wrapContent } from '@gaunt-sloth/core/utils/llmUtils.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Requirement sources. Aliases are mapped to actual package paths.
|
|
5
5
|
*/
|
|
6
|
-
export const
|
|
6
|
+
export const REQUIREMENTS_SOURCES = {
|
|
7
7
|
'jira-legacy': '@gaunt-sloth/review/sources/jiraIssueLegacySource.js',
|
|
8
8
|
jira: '@gaunt-sloth/review/sources/jiraIssueSource.js',
|
|
9
9
|
github: '@gaunt-sloth/review/sources/ghIssueSource.js',
|
|
@@ -11,38 +11,38 @@ export const REQUIREMENTS_PROVIDERS = {
|
|
|
11
11
|
file: '@gaunt-sloth/review/sources/fileSource.js',
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* Content
|
|
14
|
+
* Content sources. Aliases are mapped to actual package paths.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const CONTENT_SOURCES = {
|
|
17
17
|
github: '@gaunt-sloth/review/sources/ghPrDiffSource.js',
|
|
18
18
|
text: '@gaunt-sloth/review/sources/textSource.js',
|
|
19
19
|
file: '@gaunt-sloth/review/sources/fileSource.js',
|
|
20
20
|
};
|
|
21
|
-
export async function
|
|
22
|
-
const requirements = await
|
|
23
|
-
return wrapContent(requirements,
|
|
21
|
+
export async function getRequirementsFromSource(requirementSource, requirementsId, config) {
|
|
22
|
+
const requirements = await getFromSource(requirementSource, requirementsId, (config?.requirementSourceConfig ?? {})[requirementSource], REQUIREMENTS_SOURCES);
|
|
23
|
+
return wrapContent(requirements, requirementSource, 'requirements');
|
|
24
24
|
}
|
|
25
|
-
export async function
|
|
26
|
-
const content = await
|
|
27
|
-
return wrapContent(content,
|
|
25
|
+
export async function getContentFromSource(contentSource, contentId, config) {
|
|
26
|
+
const content = await getFromSource(contentSource, contentId, (config?.contentSourceConfig ?? {})[contentSource], CONTENT_SOURCES);
|
|
27
|
+
return wrapContent(content, contentSource, contentSource === 'github' ? 'GitHub diff' : 'content');
|
|
28
28
|
}
|
|
29
|
-
async function
|
|
29
|
+
async function getFromSource(source, id,
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
config,
|
|
32
|
-
if (typeof
|
|
33
|
-
// Use one of the predefined
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
const { get } = await import(
|
|
31
|
+
config, legitPredefinedSources) {
|
|
32
|
+
if (typeof source === 'string') {
|
|
33
|
+
// Use one of the predefined sources
|
|
34
|
+
if (legitPredefinedSources[source]) {
|
|
35
|
+
const sourcePath = legitPredefinedSources[source];
|
|
36
|
+
const { get } = await import(sourcePath);
|
|
37
37
|
return await get(config, id);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
displayError(`Unknown
|
|
40
|
+
displayError(`Unknown source: ${source}. Continuing without it.`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
else if (typeof
|
|
43
|
+
else if (typeof source === 'function') {
|
|
44
44
|
// Type assertion to handle function call
|
|
45
|
-
return await
|
|
45
|
+
return await source(id);
|
|
46
46
|
}
|
|
47
47
|
return '';
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../src/commands/commandUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../src/commands/commandUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,aAAa,EAAE,sDAAsD;IACrE,IAAI,EAAE,gDAAgD;IACtD,MAAM,EAAE,8CAA8C;IACtD,IAAI,EAAE,2CAA2C;IACjD,IAAI,EAAE,2CAA2C;CACzC,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,+CAA+C;IACvD,IAAI,EAAE,2CAA2C;IACjD,IAAI,EAAE,2CAA2C;CACzC,CAAC;AAIX,MAAM,CAAC,KAAK,UAAU,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AO,MAAO,MAAsD,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { initConfig } from '@gaunt-sloth/core/config.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getCommandSourceInput, getCommandSystemPrompt, } from '#src/commands/commandIntrospection.js';
|
|
3
3
|
import { display, displayError } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
4
4
|
import { setExitCode } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
5
5
|
const PROMPT_COMMANDS = ['ask', 'review', 'pr', 'pr-discovery', 'chat', 'code', 'exec'];
|
|
6
|
-
const
|
|
6
|
+
const SOURCE_COMMANDS = ['review', 'pr'];
|
|
7
7
|
const INPUT_TYPES = ['content', 'requirements'];
|
|
8
8
|
export function getCommand(program, commandLineConfigOverrides) {
|
|
9
9
|
program
|
|
10
10
|
.command('get')
|
|
11
|
-
.description('Print the effective prompt or
|
|
11
|
+
.description('Print the effective prompt or source-backed command input')
|
|
12
12
|
.argument('<command>', 'Command to introspect')
|
|
13
13
|
.argument('<subject>', 'Either prompt, content, or requirements')
|
|
14
|
-
.argument('[id]', '
|
|
14
|
+
.argument('[id]', 'Source-backed content identifier')
|
|
15
15
|
.action(async (command, subject, id) => {
|
|
16
16
|
try {
|
|
17
17
|
const config = await initConfig(commandLineConfigOverrides);
|
|
@@ -28,13 +28,13 @@ export function getCommand(program, commandLineConfigOverrides) {
|
|
|
28
28
|
if (!INPUT_TYPES.includes(subject)) {
|
|
29
29
|
throw new Error(`Unsupported subject: ${subject}.`);
|
|
30
30
|
}
|
|
31
|
-
if (!
|
|
32
|
-
throw new Error(`Unsupported
|
|
31
|
+
if (!SOURCE_COMMANDS.includes(command)) {
|
|
32
|
+
throw new Error(`Unsupported source-backed command: ${command}.`);
|
|
33
33
|
}
|
|
34
34
|
if (!id) {
|
|
35
35
|
throw new Error(`Subject "${subject}" requires an ID.`);
|
|
36
36
|
}
|
|
37
|
-
display(await
|
|
37
|
+
display(await getCommandSourceInput(command, subject, id, config));
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
40
|
displayError(error instanceof Error ? error.message : String(error));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCommand.js","sourceRoot":"","sources":["../../src/commands/getCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"getCommand.js","sourceRoot":"","sources":["../../src/commands/getCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAIvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AACjG,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAU,CAAC;AAClD,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,cAAc,CAAU,CAAC;AAEzD,MAAM,UAAU,UAAU,CACxB,OAAgB,EAChB,0BAAsD;IAEtD,OAAO;SACJ,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,2DAA2D,CAAC;SACxE,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAC;SAC9C,QAAQ,CAAC,WAAW,EAAE,yCAAyC,CAAC;SAChE,QAAQ,CAAC,MAAM,EAAE,kCAAkC,CAAC;SACpD,MAAM,CAAC,KAAK,EAAE,OAAe,EAAE,OAAe,EAAE,EAAsB,EAAE,EAAE;QACzE,IAAI,CAAC;YAC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
|
15
15
|
export function initCommand(program) {
|
|
16
16
|
program
|
|
17
17
|
.command('init')
|
|
18
|
-
.description('Initialize
|
|
18
|
+
.description('Initialize Gaunt Sloth in your project. This will write necessary config files.')
|
|
19
19
|
.addArgument(new Argument('[type]', 'Config type (optional, runs the interactive dialog if omitted)').choices(availableDefaultConfigs))
|
|
20
20
|
.action(async (config) => {
|
|
21
21
|
if (config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCommand.js","sourceRoot":"","sources":["../../src/commands/initCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAW,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,
|
|
1
|
+
{"version":3,"file":"initCommand.js","sourceRoot":"","sources":["../../src/commands/initCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAW,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,iFAAiF,CAAC;SAC9F,WAAW,CACV,IAAI,QAAQ,CACV,QAAQ,EACR,gEAAgE,CACjE,CAAC,OAAO,CAAC,uBAAuB,CAAC,CACnC;SACA,MAAM,CAAC,KAAK,EAAE,MAAmB,EAAE,EAAE;QACpC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,MAAM,iBAAiB,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
2
|
import { displayError } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
3
3
|
import { setExitCode } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { getCommandSourceInput, getEffectiveContentSource, getEffectiveRequirementSource, getReviewSystemPrompt, } from '#src/commands/commandIntrospection.js';
|
|
5
|
+
import { REQUIREMENTS_SOURCES } from './commandUtils.js';
|
|
6
6
|
import jiraLogWork from '#src/helpers/jira/jiraLogWork.js';
|
|
7
7
|
import { wrapContent } from '@gaunt-sloth/core/utils/llmUtils.js';
|
|
8
8
|
import { runPrDiscovery } from '#src/commands/prDiscovery.js';
|
|
@@ -11,24 +11,24 @@ export function prCommand(program, commandLineConfigOverrides) {
|
|
|
11
11
|
program
|
|
12
12
|
.command('pr')
|
|
13
13
|
.description('Review provided Pull Request in current directory. ' +
|
|
14
|
-
'This command is similar to `review`, but default content
|
|
14
|
+
'This command is similar to `review`, but default content source is `github`. ' +
|
|
15
15
|
'(assuming that GitHub CLI is installed and authenticated for current project')
|
|
16
16
|
.argument('[prId]', "Pull request ID to review. Omit both prId and requirementsId to discover the change requirements from the current branch's PR.")
|
|
17
|
-
.argument('[requirementsId]', 'Optional requirements ID argument to retrieve requirements with
|
|
18
|
-
.addOption(new Option('-p, --requirements-
|
|
17
|
+
.argument('[requirementsId]', 'Optional requirements ID argument to retrieve requirements with requirement source')
|
|
18
|
+
.addOption(new Option('-p, --requirements-source <requirementSource>', 'Requirement source for this review.').choices(Object.keys(REQUIREMENTS_SOURCES)))
|
|
19
19
|
.option('-f, --file [files...]', 'Input files. Content of these files will be added BEFORE the diff, but after requirements')
|
|
20
20
|
.option('-m, --message <message>', 'Extra message to provide just before the content')
|
|
21
21
|
.action(async (prId, requirementsId, options) => {
|
|
22
22
|
const { initConfig } = await import('@gaunt-sloth/core/config.js');
|
|
23
23
|
const config = await initConfig(commandLineConfigOverrides); // Initialize and get config
|
|
24
24
|
const content = [];
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const requirementSource = getEffectiveRequirementSource('pr', config, options.requirementsSource);
|
|
26
|
+
const contentSource = getEffectiveContentSource('pr', config);
|
|
27
27
|
if (options.file) {
|
|
28
28
|
content.push(readMultipleFilesFromProjectDir(options.file));
|
|
29
29
|
}
|
|
30
30
|
const isDiscovery = !prId && !requirementsId;
|
|
31
|
-
const looksLikeRequirementsOnlyMode =
|
|
31
|
+
const looksLikeRequirementsOnlyMode = contentSource === 'github' && Boolean(prId) && !requirementsId && !/^\d+$/.test(prId);
|
|
32
32
|
if (looksLikeRequirementsOnlyMode) {
|
|
33
33
|
displayError(`Unsupported PR command arguments: "${prId}" was provided as the pull request ID. ` +
|
|
34
34
|
'`gth pr <requirementsId>` requirements-only mode is not supported. ' +
|
|
@@ -62,14 +62,14 @@ export function prCommand(program, commandLineConfigOverrides) {
|
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
64
|
// Handle requirements
|
|
65
|
-
const requirements = await
|
|
65
|
+
const requirements = await getCommandSourceInput('pr', 'requirements', requirementsId, config, requirementSource);
|
|
66
66
|
if (requirements) {
|
|
67
67
|
content.push(requirements);
|
|
68
68
|
}
|
|
69
|
-
// Get PR diff using the
|
|
69
|
+
// Get PR diff using the source
|
|
70
70
|
try {
|
|
71
|
-
const prContent = await
|
|
72
|
-
// A
|
|
71
|
+
const prContent = await getCommandSourceInput('pr', 'content', prId, config, contentSource);
|
|
72
|
+
// A source may resolve to an empty result instead of throwing - e.g. ghPrDiffSource
|
|
73
73
|
// returns null (with a warning) for an invalid PR number. Without this guard the review
|
|
74
74
|
// would silently proceed against no diff; fail loudly as the throwing path used to.
|
|
75
75
|
if (!prContent) {
|
|
@@ -98,11 +98,10 @@ export function prCommand(program, commandLineConfigOverrides) {
|
|
|
98
98
|
// discovery mode (current branch's PR), which `gh pr view` resolves on its own.
|
|
99
99
|
{ prId });
|
|
100
100
|
if (requirementsId &&
|
|
101
|
-
(config.commands?.pr?.
|
|
101
|
+
(config.commands?.pr?.requirementSource ?? config.requirementSource) === 'jira' &&
|
|
102
102
|
config.commands?.pr?.logWorkForReviewInSeconds) {
|
|
103
103
|
// TODO we need to figure out some sort of post-processors
|
|
104
|
-
let jiraConfig = config.builtInToolsConfig?.jira ||
|
|
105
|
-
config.requirementsProviderConfig?.jira;
|
|
104
|
+
let jiraConfig = config.builtInToolsConfig?.jira || config.requirementSourceConfig?.jira;
|
|
106
105
|
await jiraLogWork(jiraConfig, requirementsId, config.commands?.pr?.logWorkForReviewInSeconds, 'code review');
|
|
107
106
|
}
|
|
108
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prCommand.js","sourceRoot":"","sources":["../../src/commands/prCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"prCommand.js","sourceRoot":"","sources":["../../src/commands/prCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,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