gaunt-sloth 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +55 -5
- package/cli.js +43 -10
- package/dist/cli.js +33 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/adkEvalRunner.d.ts +66 -0
- package/dist/commands/adkEvalRunner.js +69 -0
- package/dist/commands/adkEvalRunner.js.map +1 -0
- package/dist/commands/agUiEvalRunner.d.ts +73 -0
- package/dist/commands/agUiEvalRunner.js +216 -0
- package/dist/commands/agUiEvalRunner.js.map +1 -0
- package/dist/commands/askCommand.d.ts +3 -2
- package/dist/commands/askCommand.js +26 -7
- package/dist/commands/askCommand.js.map +1 -1
- package/dist/commands/batchCommand.d.ts +78 -0
- package/dist/commands/batchCommand.js +245 -0
- package/dist/commands/batchCommand.js.map +1 -0
- package/dist/commands/cliOptionParsers.d.ts +12 -0
- package/dist/commands/cliOptionParsers.js +18 -0
- package/dist/commands/cliOptionParsers.js.map +1 -0
- 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 +16 -16
- package/dist/commands/commandUtils.js +20 -20
- package/dist/commands/commandUtils.js.map +1 -1
- package/dist/commands/configCommand.d.ts +24 -0
- package/dist/commands/configCommand.js +117 -0
- package/dist/commands/configCommand.js.map +1 -0
- package/dist/commands/configSetup.d.ts +1 -1
- package/dist/commands/configSetup.js +17 -2
- package/dist/commands/configSetup.js.map +1 -1
- package/dist/commands/evalCommand.d.ts +41 -0
- package/dist/commands/evalCommand.js +483 -0
- package/dist/commands/evalCommand.js.map +1 -0
- package/dist/commands/execCommand.js +4 -1
- package/dist/commands/execCommand.js.map +1 -1
- package/dist/commands/firstRunDialog.d.ts +39 -5
- package/dist/commands/firstRunDialog.js +72 -10
- package/dist/commands/firstRunDialog.js.map +1 -1
- package/dist/commands/getCommand.js +7 -7
- package/dist/commands/getCommand.js.map +1 -1
- package/dist/commands/historyCommand.d.ts +17 -0
- package/dist/commands/historyCommand.js +102 -0
- package/dist/commands/historyCommand.js.map +1 -0
- package/dist/commands/initCommand.d.ts +3 -0
- package/dist/commands/initCommand.js +9 -4
- package/dist/commands/initCommand.js.map +1 -1
- package/dist/commands/insightsCommand.d.ts +8 -0
- package/dist/commands/insightsCommand.js +32 -0
- package/dist/commands/insightsCommand.js.map +1 -0
- package/dist/commands/modelsCommand.d.ts +25 -0
- package/dist/commands/modelsCommand.js +96 -0
- package/dist/commands/modelsCommand.js.map +1 -0
- package/dist/commands/prCommand.js +14 -15
- package/dist/commands/prCommand.js.map +1 -1
- package/dist/commands/prDiscovery.d.ts +2 -2
- package/dist/commands/prDiscovery.js +27 -29
- package/dist/commands/prDiscovery.js.map +1 -1
- package/dist/commands/reviewCommand.js +15 -10
- package/dist/commands/reviewCommand.js.map +1 -1
- package/dist/commands/workflowCommand.d.ts +19 -0
- package/dist/commands/workflowCommand.js +77 -0
- package/dist/commands/workflowCommand.js.map +1 -0
- package/dist/helpers/jira/jiraLogWork.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 +321 -21
- package/dist/tui/components/App.js.map +1 -1
- package/dist/tui/components/ApprovalPrompt.d.ts +18 -0
- package/dist/tui/components/ApprovalPrompt.js +26 -0
- package/dist/tui/components/ApprovalPrompt.js.map +1 -0
- package/dist/tui/components/DebugPanel.d.ts +29 -9
- package/dist/tui/components/DebugPanel.js +46 -23
- package/dist/tui/components/DebugPanel.js.map +1 -1
- package/dist/tui/components/FetchProgress.d.ts +36 -0
- package/dist/tui/components/FetchProgress.js +39 -0
- package/dist/tui/components/FetchProgress.js.map +1 -0
- package/dist/tui/components/LiveTurn.d.ts +26 -4
- package/dist/tui/components/LiveTurn.js +104 -18
- package/dist/tui/components/LiveTurn.js.map +1 -1
- package/dist/tui/components/NoticeBar.d.ts +32 -0
- package/dist/tui/components/NoticeBar.js +39 -0
- package/dist/tui/components/NoticeBar.js.map +1 -0
- package/dist/tui/components/PromptInput.d.ts +26 -1
- package/dist/tui/components/PromptInput.js +93 -7
- package/dist/tui/components/PromptInput.js.map +1 -1
- package/dist/tui/components/Rule.js.map +1 -1
- package/dist/tui/components/SelectList.d.ts +98 -9
- package/dist/tui/components/SelectList.js +209 -26
- package/dist/tui/components/SelectList.js.map +1 -1
- package/dist/tui/components/SlashCommandMenu.d.ts +20 -0
- package/dist/tui/components/SlashCommandMenu.js +28 -0
- package/dist/tui/components/SlashCommandMenu.js.map +1 -0
- package/dist/tui/components/StatusBar.d.ts +7 -1
- package/dist/tui/components/StatusBar.js +7 -3
- package/dist/tui/components/StatusBar.js.map +1 -1
- package/dist/tui/components/Transcript.js +6 -1
- package/dist/tui/components/Transcript.js.map +1 -1
- package/dist/tui/debugRender.d.ts +41 -6
- package/dist/tui/debugRender.js +126 -12
- package/dist/tui/debugRender.js.map +1 -1
- package/dist/tui/debugSearch.d.ts +40 -0
- package/dist/tui/debugSearch.js +73 -0
- package/dist/tui/debugSearch.js.map +1 -0
- package/dist/tui/markdown.js +0 -0
- package/dist/tui/markdown.js.map +1 -1
- package/dist/tui/pasteParser.d.ts +21 -0
- package/dist/tui/pasteParser.js +24 -0
- package/dist/tui/pasteParser.js.map +1 -0
- package/dist/tui/selectCancelled.d.ts +13 -0
- package/dist/tui/selectCancelled.js +17 -0
- package/dist/tui/selectCancelled.js.map +1 -0
- package/dist/tui/slashCommands.d.ts +220 -1
- package/dist/tui/slashCommands.js +408 -1
- package/dist/tui/slashCommands.js.map +1 -1
- package/dist/tui/tuiSessionModule.js +249 -24
- package/dist/tui/tuiSessionModule.js.map +1 -1
- package/dist/tui/types.d.ts +96 -7
- package/dist/tui/viewModel.d.ts +34 -0
- package/dist/tui/viewModel.js +67 -0
- package/dist/tui/viewModel.js.map +1 -1
- package/dist/utils/stdinPolicy.d.ts +31 -0
- package/dist/utils/stdinPolicy.js +37 -0
- package/dist/utils/stdinPolicy.js.map +1 -0
- package/package.json +21 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agUiEvalRunner.js","sourceRoot":"","sources":["../../src/commands/agUiEvalRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkDxC;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,gBAAgB,CAAC,IAAgC;IAC9D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,QAA4B,CAAC;IACjC,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,MAAM,WAAW,GAAG,CAAC,KAAa,EAAQ,EAAE;QAC1C,MAAM,OAAO,GAAG,KAAK;aAClB,KAAK,CAAC,OAAO,CAAC;aACd,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC1C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;aAChD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,IAAI,KAAoF,CAAC;QACzF,IAAI,CAAC;YACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,sDAAsD;YACtD,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,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -16,8 +16,9 @@ interface AskCommandOptions {
|
|
|
16
16
|
*
|
|
17
17
|
* Filesystem mode is overridden on the per-command `commands.ask` slice (where
|
|
18
18
|
* `getEffectiveConfig` reads it from), and `askWriteMode` is set so the agent's tool resolution
|
|
19
|
-
* enables dev tools for `ask`.
|
|
20
|
-
* so
|
|
19
|
+
* enables dev tools for `ask`. CFG-18: the dev/shell tools live in the unified `builtInTools`
|
|
20
|
+
* registry, so `ask --write` reuses exec's (falling back to code's) `builtInTools` config — copied
|
|
21
|
+
* onto `commands.ask.builtInTools` — rather than a separate `devTools` key. Returns the config
|
|
21
22
|
* untouched when `--write` is not set.
|
|
22
23
|
*
|
|
23
24
|
* Exported for unit testing.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { initConfig } from '@gaunt-sloth/core/config.js';
|
|
2
2
|
import { getAskSystemPrompt } from '#src/commands/commandIntrospection.js';
|
|
3
|
-
import { getStringFromStdin } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
4
|
-
import { displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
3
|
+
import { getStringFromStdin, setExitCode } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
4
|
+
import { displayError, displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
5
5
|
import { wrapContent } from '@gaunt-sloth/core/utils/llmUtils.js';
|
|
6
6
|
import { readMultipleFilesFromProjectDir } from '@gaunt-sloth/core/utils/fileUtils.js';
|
|
7
7
|
/**
|
|
@@ -10,8 +10,9 @@ import { readMultipleFilesFromProjectDir } from '@gaunt-sloth/core/utils/fileUti
|
|
|
10
10
|
*
|
|
11
11
|
* Filesystem mode is overridden on the per-command `commands.ask` slice (where
|
|
12
12
|
* `getEffectiveConfig` reads it from), and `askWriteMode` is set so the agent's tool resolution
|
|
13
|
-
* enables dev tools for `ask`.
|
|
14
|
-
* so
|
|
13
|
+
* enables dev tools for `ask`. CFG-18: the dev/shell tools live in the unified `builtInTools`
|
|
14
|
+
* registry, so `ask --write` reuses exec's (falling back to code's) `builtInTools` config — copied
|
|
15
|
+
* onto `commands.ask.builtInTools` — rather than a separate `devTools` key. Returns the config
|
|
15
16
|
* untouched when `--write` is not set.
|
|
16
17
|
*
|
|
17
18
|
* Exported for unit testing.
|
|
@@ -21,7 +22,7 @@ export function applyAskWriteMode(config, options) {
|
|
|
21
22
|
return config;
|
|
22
23
|
}
|
|
23
24
|
displayWarning('ask --write: filesystem and dev tools enabled — this run can read/write files and run commands.');
|
|
24
|
-
const
|
|
25
|
+
const askBuiltInTools = config.commands?.exec?.builtInTools ?? config.commands?.code?.builtInTools;
|
|
25
26
|
return {
|
|
26
27
|
...config,
|
|
27
28
|
askWriteMode: true,
|
|
@@ -30,7 +31,7 @@ export function applyAskWriteMode(config, options) {
|
|
|
30
31
|
ask: {
|
|
31
32
|
...config.commands?.ask,
|
|
32
33
|
filesystem: 'all',
|
|
33
|
-
...(
|
|
34
|
+
...(askBuiltInTools ? { builtInTools: askBuiltInTools } : {}),
|
|
34
35
|
},
|
|
35
36
|
},
|
|
36
37
|
};
|
|
@@ -48,6 +49,11 @@ export function askCommand(program, commandLineConfigOverrides) {
|
|
|
48
49
|
.option('-f, --file [files...]', 'Input files. Content of these files will be added BEFORE the message')
|
|
49
50
|
.option('--write', 'Let ask act, not just chat: enable full filesystem + dev tools (like exec/code) so it can ' +
|
|
50
51
|
'read/write files and run commands. Grants write access — use with care.')
|
|
52
|
+
.addHelpText('after', '\n' +
|
|
53
|
+
'Examples:\n' +
|
|
54
|
+
' $ gsloth ask "which types of primitives are available in JavaScript?"\n' +
|
|
55
|
+
' $ gsloth ask "Please explain this code" -f index.js\n' +
|
|
56
|
+
' $ cat error.log | gsloth ask "What might be causing these errors?"\n')
|
|
51
57
|
.action(async (message, options) => {
|
|
52
58
|
const config = applyAskWriteMode(await initConfig(commandLineConfigOverrides), options);
|
|
53
59
|
const content = [];
|
|
@@ -67,7 +73,20 @@ export function askCommand(program, commandLineConfigOverrides) {
|
|
|
67
73
|
}
|
|
68
74
|
const { runSingleShot } = await import('@gaunt-sloth/core/runtime/singleShot.js');
|
|
69
75
|
const { createResolvers } = await import('@gaunt-sloth/agent/resolvers.js');
|
|
70
|
-
await
|
|
76
|
+
const { resolveAgentFactory } = await import('@gaunt-sloth/agent/core/resolveAgentFactory.js');
|
|
77
|
+
let ok = false;
|
|
78
|
+
try {
|
|
79
|
+
({ ok } = await runSingleShot('ASK', getAskSystemPrompt(config), content.join('\n'), config, createResolvers(), 'ask',
|
|
80
|
+
// ask defaults to the lean backend; an explicit config.agent.backend overrides it.
|
|
81
|
+
resolveAgentFactory(config, 'lean')));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
displayError(error instanceof Error ? error.message : String(error));
|
|
85
|
+
ok = false;
|
|
86
|
+
}
|
|
87
|
+
if (!ok) {
|
|
88
|
+
setExitCode(1);
|
|
89
|
+
}
|
|
71
90
|
});
|
|
72
91
|
}
|
|
73
92
|
//# sourceMappingURL=askCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"askCommand.js","sourceRoot":"","sources":["../../src/commands/askCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAErF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"askCommand.js","sourceRoot":"","sources":["../../src/commands/askCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAErF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,cA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AAC,OAAO,KAAK,EAAE,CAAC;YACf,YAAY,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,EAAE,GAAG,KAAK,CAAC;QACb,CAAC;QAED,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,WAAW,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { CommandLineConfigOverrides } from '@gaunt-sloth/core/config.js';
|
|
3
|
+
import type { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
4
|
+
import type { GthCommand } from '@gaunt-sloth/core/core/types.js';
|
|
5
|
+
import type { RunCellFn, RunConversationFn } from '@gaunt-sloth/batch';
|
|
6
|
+
/** Options for {@link buildProductionRunCell} — the bits that differ between `batch` (exec-mode,
|
|
7
|
+
* script content) and `eval` (ask-mode, a case's user-message prompt); everything else about the
|
|
8
|
+
* adapter (model-resolver cache, resolver cleanup, error handling) is shared. */
|
|
9
|
+
export interface ProductionRunCellOptions {
|
|
10
|
+
/** The `GthCommand` mode forwarded to `runSingleShot` — selects the agent's mode prompt/behavior
|
|
11
|
+
* (`'exec'` for `batch`, `'ask'` for `eval`). */
|
|
12
|
+
command: GthCommand;
|
|
13
|
+
/** Prefix for `runSingleShot`'s `source` naming (`<prefix>-<cell.id>`), used for output/session
|
|
14
|
+
* file naming — `'BATCH'` for `batch`, `'EVAL'` for `eval`. */
|
|
15
|
+
sourcePrefix: string;
|
|
16
|
+
/** `wrapContent` block-prefix label for the cell's content — `'script'` for `batch`'s
|
|
17
|
+
* prompt-executable scripts, `'message'` for `eval`'s case prompts. */
|
|
18
|
+
wrapBlockPrefix: string;
|
|
19
|
+
/** `wrapContent` human-readable prefix paired with {@link wrapBlockPrefix} (e.g.
|
|
20
|
+
* `'prompt-executable script'` / `'user message'`). */
|
|
21
|
+
wrapPrefix: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build the injectable {@link RunCellFn} that adapts the shared single-shot runtime
|
|
25
|
+
* (`runSingleShot`) to one matrix cell. Isolated in its own function so each cell run gets a fresh
|
|
26
|
+
* `createResolvers()` (its own MCP client instance) — matching batch's "N isolated model calls"
|
|
27
|
+
* contract (docs/batch-mechanism-vs-judgment.md) rather than sharing one resolver/client across
|
|
28
|
+
* concurrent cells.
|
|
29
|
+
*
|
|
30
|
+
* Shared between `gth batch` and `gth eval` (BATCH-2): both run N isolated single-shot calls
|
|
31
|
+
* through this exact `runSingleShot` wiring (model-resolver cache, resolver cleanup-on-every-path,
|
|
32
|
+
* error containment), differing only in which agent mode/prompt they run cells through and how the
|
|
33
|
+
* cell's content is framed — see {@link ProductionRunCellOptions}. `gth eval`'s wiring lives in
|
|
34
|
+
* `evalCommand.ts`, which imports this function rather than re-deriving it.
|
|
35
|
+
*
|
|
36
|
+
* batch/eval each write their own structured JSON per cell/case (`writeBatchOutput`/
|
|
37
|
+
* `writeEvalOutput`), so `writeOutputToFile` is forced off for every cell run — the per-cell `.md`
|
|
38
|
+
* report `runSingleShot` would otherwise write is not wanted here.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildProductionRunCell(baseConfig: GthConfig, preamble: string, commandLineConfigOverrides: CommandLineConfigOverrides, options: ProductionRunCellOptions): Promise<RunCellFn>;
|
|
41
|
+
/**
|
|
42
|
+
* BATCH-12 Task 2 — build the injectable {@link RunConversationFn} that adapts core's MULTI-TURN
|
|
43
|
+
* `runConversation` to `gth eval`'s conversation seam. The multi-turn analogue of
|
|
44
|
+
* {@link buildProductionRunCell}: same fresh-`createResolvers()` per conversation + cleanup-on-
|
|
45
|
+
* every-path discipline, but it runs a whole scripted conversation (agent/tools built ONCE, messages
|
|
46
|
+
* accumulated across turns) and returns one outcome per turn.
|
|
47
|
+
*
|
|
48
|
+
* No model axis (`gth eval` has no `--models`), so this takes the already-resolved SUT/identity
|
|
49
|
+
* `config` directly — mirroring how `evalCommand.ts` builds one config per identity and passes it in
|
|
50
|
+
* (it does NOT call `initConfig` here, so the command's `initConfig`-once-per-identity contract
|
|
51
|
+
* holds). `writeOutputToFile` is forced off (eval writes its own per-cell JSON via `writeEvalOutput`).
|
|
52
|
+
*
|
|
53
|
+
* A rare throw from `runConversation` (e.g. agent init failed) is deliberately NOT swallowed here:
|
|
54
|
+
* `runBatchMatrix` catches it as a failed cell and the runner surfaces the error on turn 1, which is
|
|
55
|
+
* more informative than an empty result. The `finally` still tears the resolvers down exactly once.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildProductionRunConversation(config: GthConfig, preamble: string, options: ProductionRunCellOptions): Promise<RunConversationFn>;
|
|
58
|
+
/** Parse `--models a,b,c` into a trimmed, non-empty list; `undefined` when the flag is absent. */
|
|
59
|
+
export declare function parseModelsOption(models: string | undefined): string[] | undefined;
|
|
60
|
+
/** Default output dir when `-o/--output` is omitted: a timestamped dir next to other gth reports. */
|
|
61
|
+
export declare function defaultBatchOutputDir(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Adds the `batch` command to the program.
|
|
64
|
+
*
|
|
65
|
+
* `gth batch <script.md> --over <csv|jsonl> [--models a,b,c] [-j 8] [--retry 2] [-o out/]` — runs a
|
|
66
|
+
* prompt-executable over a matrix (models × content-bound inputs), the way `exec` runs one. See
|
|
67
|
+
* docs/batch-eval-cli-surface.md and docs/batch-mechanism-vs-judgment.md for the design.
|
|
68
|
+
*
|
|
69
|
+
* Exit-code contract (BATCH-1, decisive design point): `gth batch` exits 0 iff the cells *ran* —
|
|
70
|
+
* it never fails because a cell's answer was poor quality (that is `gth eval`'s job, BATCH-2, not
|
|
71
|
+
* this command). Only a harness-level error (a malformed `--over` file, a missing script, etc.)
|
|
72
|
+
* sets a non-zero exit code; a per-cell failure is recorded in that cell's structured JSON output,
|
|
73
|
+
* never reflected in the process exit code.
|
|
74
|
+
*
|
|
75
|
+
* @param program - The commander program
|
|
76
|
+
* @param commandLineConfigOverrides - command line config overrides
|
|
77
|
+
*/
|
|
78
|
+
export declare function batchCommand(program: Command, commandLineConfigOverrides: CommandLineConfigOverrides): void;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { initConfig } from '@gaunt-sloth/core/config.js';
|
|
2
|
+
import { getExecSystemPrompt } from '#src/commands/commandIntrospection.js';
|
|
3
|
+
import { parseIntOption } from '#src/commands/cliOptionParsers.js';
|
|
4
|
+
import { displaySuccess, displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
5
|
+
import { wrapContent } from '@gaunt-sloth/core/utils/llmUtils.js';
|
|
6
|
+
import { fileSafeLocalDate, getGslothFilePath, readFileFromProjectDir, readMultipleFilesFromProjectDir, } from '@gaunt-sloth/core/utils/fileUtils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build a per-model {@link GthConfig} cache: one genuinely fresh `initConfig()` call (fresh `.llm`
|
|
9
|
+
* instance included) per DISTINCT `--models` value, not one per cell — a 20-cell matrix over 3
|
|
10
|
+
* models must only construct 3 model instances.
|
|
11
|
+
*
|
|
12
|
+
* BATCH-1 fix (CI review finding, critical): the previous approach gave a cell its own model by
|
|
13
|
+
* structurally cloning the shared `GthConfig.llm` instance (`Object.create` +
|
|
14
|
+
* `getOwnPropertyDescriptors`) and setting `.model` on the clone. That never runs the original
|
|
15
|
+
* class's constructor, so it never gets that instance's private (`#field`) slots — any LangChain
|
|
16
|
+
* chat-model class whose methods touch a `#privateField` internally (not just the public `model`
|
|
17
|
+
* field the old code checked for) would throw `TypeError: Cannot read private member from an
|
|
18
|
+
* object whose class did not declare it` the moment such a method ran on the clone. That risk is
|
|
19
|
+
* not provider-specific and cannot be ruled out by inspecting today's installed provider
|
|
20
|
+
* versions. This replaces cloning with construction: each distinct model gets a real
|
|
21
|
+
* `initConfig({ ...overrides, model })` call, which threads the override through
|
|
22
|
+
* `tryJsonConfig` (`packages/core/src/config/loader.ts`) so the provider's own
|
|
23
|
+
* `processJsonConfig()` builds the instance from scratch — the same supported path every other
|
|
24
|
+
* model comes from, correct for any provider.
|
|
25
|
+
*
|
|
26
|
+
* Cached by `Promise<GthConfig>` (not just by resolved value) so concurrent cells requesting the
|
|
27
|
+
* same not-yet-resolved model share one in-flight `initConfig()` call instead of racing to build
|
|
28
|
+
* the model twice.
|
|
29
|
+
*/
|
|
30
|
+
function createCellConfigResolver(baseConfig, commandLineConfigOverrides) {
|
|
31
|
+
const configForModel = new Map();
|
|
32
|
+
return (model) => {
|
|
33
|
+
if (!model) {
|
|
34
|
+
return Promise.resolve(baseConfig);
|
|
35
|
+
}
|
|
36
|
+
let cached = configForModel.get(model);
|
|
37
|
+
if (!cached) {
|
|
38
|
+
cached = initConfig({ ...commandLineConfigOverrides, model });
|
|
39
|
+
configForModel.set(model, cached);
|
|
40
|
+
}
|
|
41
|
+
return cached;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build the injectable {@link RunCellFn} that adapts the shared single-shot runtime
|
|
46
|
+
* (`runSingleShot`) to one matrix cell. Isolated in its own function so each cell run gets a fresh
|
|
47
|
+
* `createResolvers()` (its own MCP client instance) — matching batch's "N isolated model calls"
|
|
48
|
+
* contract (docs/batch-mechanism-vs-judgment.md) rather than sharing one resolver/client across
|
|
49
|
+
* concurrent cells.
|
|
50
|
+
*
|
|
51
|
+
* Shared between `gth batch` and `gth eval` (BATCH-2): both run N isolated single-shot calls
|
|
52
|
+
* through this exact `runSingleShot` wiring (model-resolver cache, resolver cleanup-on-every-path,
|
|
53
|
+
* error containment), differing only in which agent mode/prompt they run cells through and how the
|
|
54
|
+
* cell's content is framed — see {@link ProductionRunCellOptions}. `gth eval`'s wiring lives in
|
|
55
|
+
* `evalCommand.ts`, which imports this function rather than re-deriving it.
|
|
56
|
+
*
|
|
57
|
+
* batch/eval each write their own structured JSON per cell/case (`writeBatchOutput`/
|
|
58
|
+
* `writeEvalOutput`), so `writeOutputToFile` is forced off for every cell run — the per-cell `.md`
|
|
59
|
+
* report `runSingleShot` would otherwise write is not wanted here.
|
|
60
|
+
*/
|
|
61
|
+
export async function buildProductionRunCell(baseConfig, preamble, commandLineConfigOverrides, options) {
|
|
62
|
+
const { runSingleShot } = await import('@gaunt-sloth/core/runtime/singleShot.js');
|
|
63
|
+
const { createResolvers } = await import('@gaunt-sloth/agent/resolvers.js');
|
|
64
|
+
const { resolveAgentFactory } = await import('@gaunt-sloth/agent/core/resolveAgentFactory.js');
|
|
65
|
+
const resolveCellModelConfig = createCellConfigResolver(baseConfig, commandLineConfigOverrides);
|
|
66
|
+
return async (cell) => {
|
|
67
|
+
const modelConfig = await resolveCellModelConfig(cell.model);
|
|
68
|
+
const cellConfig = {
|
|
69
|
+
...modelConfig,
|
|
70
|
+
canInterruptInferenceWithEsc: false,
|
|
71
|
+
writeOutputToFile: false,
|
|
72
|
+
};
|
|
73
|
+
const content = wrapContent(cell.content, options.wrapBlockPrefix, options.wrapPrefix, true);
|
|
74
|
+
// BATCH-1 fix (CI review finding, critical): keep the resolvers reference and clean it up
|
|
75
|
+
// unconditionally (success or failure) — the previous code passed `createResolvers()` inline
|
|
76
|
+
// into `runSingleShot(...)` and discarded the reference, so `cleanupTools()` (which tears
|
|
77
|
+
// down any MCP-server-backed tools/processes the cell's resolution opened) was never called —
|
|
78
|
+
// an orphaned-process leak, one per cell.
|
|
79
|
+
const resolvers = createResolvers();
|
|
80
|
+
try {
|
|
81
|
+
const { ok, answer, tokensInput, tokensOutput, tools } = await runSingleShot(`${options.sourcePrefix}-${cell.id}`, preamble, content, cellConfig, resolvers, options.command,
|
|
82
|
+
// batch/eval default to the lean backend, same as exec/ask; an explicit
|
|
83
|
+
// config.agent.backend wins.
|
|
84
|
+
resolveAgentFactory(cellConfig, 'lean'));
|
|
85
|
+
return { ok, answer, tokensInput, tokensOutput, tools };
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// runSingleShot itself is documented to never throw for a normal LLM/tool failure (it
|
|
89
|
+
// returns false instead); this guards the rare case of a genuinely unexpected exception so
|
|
90
|
+
// one bad cell can never take the whole batch run down.
|
|
91
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
await resolvers.cleanupTools?.();
|
|
96
|
+
}
|
|
97
|
+
catch (cleanupError) {
|
|
98
|
+
// A cleanup failure must never mask or override the cell's real result (already returned
|
|
99
|
+
// above) — surface it as a warning only.
|
|
100
|
+
displayWarning(`Failed to clean up tools for cell ${cell.id}: ` +
|
|
101
|
+
`${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* BATCH-12 Task 2 — build the injectable {@link RunConversationFn} that adapts core's MULTI-TURN
|
|
108
|
+
* `runConversation` to `gth eval`'s conversation seam. The multi-turn analogue of
|
|
109
|
+
* {@link buildProductionRunCell}: same fresh-`createResolvers()` per conversation + cleanup-on-
|
|
110
|
+
* every-path discipline, but it runs a whole scripted conversation (agent/tools built ONCE, messages
|
|
111
|
+
* accumulated across turns) and returns one outcome per turn.
|
|
112
|
+
*
|
|
113
|
+
* No model axis (`gth eval` has no `--models`), so this takes the already-resolved SUT/identity
|
|
114
|
+
* `config` directly — mirroring how `evalCommand.ts` builds one config per identity and passes it in
|
|
115
|
+
* (it does NOT call `initConfig` here, so the command's `initConfig`-once-per-identity contract
|
|
116
|
+
* holds). `writeOutputToFile` is forced off (eval writes its own per-cell JSON via `writeEvalOutput`).
|
|
117
|
+
*
|
|
118
|
+
* A rare throw from `runConversation` (e.g. agent init failed) is deliberately NOT swallowed here:
|
|
119
|
+
* `runBatchMatrix` catches it as a failed cell and the runner surfaces the error on turn 1, which is
|
|
120
|
+
* more informative than an empty result. The `finally` still tears the resolvers down exactly once.
|
|
121
|
+
*/
|
|
122
|
+
export async function buildProductionRunConversation(config, preamble, options) {
|
|
123
|
+
const { runConversation } = await import('@gaunt-sloth/core/runtime/conversation.js');
|
|
124
|
+
const { createResolvers } = await import('@gaunt-sloth/agent/resolvers.js');
|
|
125
|
+
const { resolveAgentFactory } = await import('@gaunt-sloth/agent/core/resolveAgentFactory.js');
|
|
126
|
+
const cellConfig = {
|
|
127
|
+
...config,
|
|
128
|
+
canInterruptInferenceWithEsc: false,
|
|
129
|
+
writeOutputToFile: false,
|
|
130
|
+
};
|
|
131
|
+
return async (userMessages) => {
|
|
132
|
+
// Wrap each turn's user message the same way single-turn cells wrap their content, so a turn's
|
|
133
|
+
// framing matches an equivalent single-turn case exactly.
|
|
134
|
+
const wrapped = userMessages.map((message) => wrapContent(message, options.wrapBlockPrefix, options.wrapPrefix, true));
|
|
135
|
+
// Fresh resolvers (its own MCP client) per conversation, torn down once when the whole
|
|
136
|
+
// conversation ends — the agent/tools persist ACROSS the turns inside `runConversation`.
|
|
137
|
+
const resolvers = createResolvers();
|
|
138
|
+
try {
|
|
139
|
+
const turns = await runConversation(`${options.sourcePrefix}-conversation`, preamble, wrapped, cellConfig, resolvers, options.command, resolveAgentFactory(cellConfig, 'lean'));
|
|
140
|
+
return turns.map(({ ok, answer, tokensInput, tokensOutput, tools, error }) => ({
|
|
141
|
+
ok,
|
|
142
|
+
answer,
|
|
143
|
+
tokensInput,
|
|
144
|
+
tokensOutput,
|
|
145
|
+
tools,
|
|
146
|
+
error,
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
try {
|
|
151
|
+
await resolvers.cleanupTools?.();
|
|
152
|
+
}
|
|
153
|
+
catch (cleanupError) {
|
|
154
|
+
// A cleanup failure must never mask the conversation's real result — warn only.
|
|
155
|
+
displayWarning(`Failed to clean up tools for conversation: ` +
|
|
156
|
+
`${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** Parse `--models a,b,c` into a trimmed, non-empty list; `undefined` when the flag is absent. */
|
|
162
|
+
export function parseModelsOption(models) {
|
|
163
|
+
if (!models)
|
|
164
|
+
return undefined;
|
|
165
|
+
const list = models
|
|
166
|
+
.split(',')
|
|
167
|
+
.map((m) => m.trim())
|
|
168
|
+
.filter((m) => m.length > 0);
|
|
169
|
+
return list.length > 0 ? list : undefined;
|
|
170
|
+
}
|
|
171
|
+
/** Default output dir when `-o/--output` is omitted: a timestamped dir next to other gth reports. */
|
|
172
|
+
export function defaultBatchOutputDir() {
|
|
173
|
+
return getGslothFilePath(`gth_${fileSafeLocalDate()}_BATCH`);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Adds the `batch` command to the program.
|
|
177
|
+
*
|
|
178
|
+
* `gth batch <script.md> --over <csv|jsonl> [--models a,b,c] [-j 8] [--retry 2] [-o out/]` — runs a
|
|
179
|
+
* prompt-executable over a matrix (models × content-bound inputs), the way `exec` runs one. See
|
|
180
|
+
* docs/batch-eval-cli-surface.md and docs/batch-mechanism-vs-judgment.md for the design.
|
|
181
|
+
*
|
|
182
|
+
* Exit-code contract (BATCH-1, decisive design point): `gth batch` exits 0 iff the cells *ran* —
|
|
183
|
+
* it never fails because a cell's answer was poor quality (that is `gth eval`'s job, BATCH-2, not
|
|
184
|
+
* this command). Only a harness-level error (a malformed `--over` file, a missing script, etc.)
|
|
185
|
+
* sets a non-zero exit code; a per-cell failure is recorded in that cell's structured JSON output,
|
|
186
|
+
* never reflected in the process exit code.
|
|
187
|
+
*
|
|
188
|
+
* @param program - The commander program
|
|
189
|
+
* @param commandLineConfigOverrides - command line config overrides
|
|
190
|
+
*/
|
|
191
|
+
export function batchCommand(program, commandLineConfigOverrides) {
|
|
192
|
+
program
|
|
193
|
+
.command('batch')
|
|
194
|
+
.description('Run a markdown prompt-executable over a matrix of models and/or content-bound inputs ' +
|
|
195
|
+
'("xargs for prompts"). Exits 0 iff the cells ran — a poor answer is not a harness failure.')
|
|
196
|
+
.argument('<script>', 'Path to the .md prompt-executable script to run over the matrix')
|
|
197
|
+
.option('--over <path>', 'CSV or JSONL file whose rows/records bind into the script content via {{field}} ' +
|
|
198
|
+
'placeholders — one matrix cell per row (content binding only; a glob-of-files path ' +
|
|
199
|
+
'binding is not supported by this command)')
|
|
200
|
+
.option('--models <list>', 'Comma-separated list of models to fan out over (omit to use the configured model, no fan-out)')
|
|
201
|
+
.option('-j, --concurrency <n>', 'Max in-flight cells', parseIntOption)
|
|
202
|
+
.option('--retry <n>', 'Retry a failed cell up to n times (default: 0, no retry)', parseIntOption)
|
|
203
|
+
.option('-o, --output <dir>', 'Directory to write structured per-cell JSON + results.json summary to ' +
|
|
204
|
+
'(default: a timestamped dir alongside other gth reports)')
|
|
205
|
+
.action(async (script, options) => {
|
|
206
|
+
const config = await initConfig(commandLineConfigOverrides);
|
|
207
|
+
// Specific `.js` subpaths (not the bare package root) — matches the house convention
|
|
208
|
+
// (`@gaunt-sloth/core/runtime/singleShot.js`, `@gaunt-sloth/review/utils/fileUtils.js`, …)
|
|
209
|
+
// that vitest's workspace-import resolver (vitest.config.ts) recognizes and resolves
|
|
210
|
+
// straight to source, so specs exercise live `packages/batch/src` rather than a `dist/`
|
|
211
|
+
// build that could go stale between an edit and a test run.
|
|
212
|
+
const { buildMatrix } = await import('@gaunt-sloth/batch/matrix.js');
|
|
213
|
+
const { parseOverFile } = await import('@gaunt-sloth/batch/parseOver.js');
|
|
214
|
+
const { runBatchMatrix } = await import('@gaunt-sloth/batch/BatchRunner.js');
|
|
215
|
+
const { writeBatchOutput } = await import('@gaunt-sloth/batch/output.js');
|
|
216
|
+
const scriptContent = readMultipleFilesFromProjectDir([script]);
|
|
217
|
+
const models = parseModelsOption(options.models);
|
|
218
|
+
const rows = options.over
|
|
219
|
+
? parseOverFile(options.over, readFileFromProjectDir(options.over))
|
|
220
|
+
: undefined;
|
|
221
|
+
const cells = buildMatrix(scriptContent, models, rows);
|
|
222
|
+
const preamble = getExecSystemPrompt(config);
|
|
223
|
+
const runCell = await buildProductionRunCell(config, preamble, commandLineConfigOverrides, {
|
|
224
|
+
command: 'exec',
|
|
225
|
+
sourcePrefix: 'BATCH',
|
|
226
|
+
wrapBlockPrefix: 'script',
|
|
227
|
+
wrapPrefix: 'prompt-executable script',
|
|
228
|
+
});
|
|
229
|
+
const results = await runBatchMatrix(cells, {
|
|
230
|
+
runCell,
|
|
231
|
+
concurrency: options.concurrency,
|
|
232
|
+
retry: options.retry,
|
|
233
|
+
});
|
|
234
|
+
const outputDir = options.output ?? defaultBatchOutputDir();
|
|
235
|
+
const summary = writeBatchOutput(outputDir, results);
|
|
236
|
+
displaySuccess(`Batch complete: ${summary.passed}/${summary.total} cell(s) passed. ` +
|
|
237
|
+
`Results written to ${outputDir}`);
|
|
238
|
+
if (summary.failed > 0) {
|
|
239
|
+
// Visible, but deliberately does NOT set a non-zero exit code — see the exit-code
|
|
240
|
+
// contract above. A poor/failed cell is `eval`'s business, not batch's.
|
|
241
|
+
displayWarning(`${summary.failed} cell(s) failed — see ${outputDir}/results.json for details.`);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=batchCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batchCommand.js","sourceRoot":"","sources":["../../src/commands/batchCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,+BAA+B,GAChC,MAA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,OAAO,GAAG,MAAM,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,0BAA0B,EAAE;YACzF,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,OAAO;YACrB,eAAe,EAAE,QAAQ;YACzB,UAAU,EAAE,0BAA0B;SACvC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE;YAC1C,OAAO;YACP,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,qBAAqB,EAAE,CAAC;QAC5D,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAErD,cAAc,CACZ,mBAAmB,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,mBAAmB;YACnE,sBAAsB,SAAS,EAAE,CACpC,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,kFAAkF;YAClF,wEAAwE;YACxE,cAAc,CACZ,GAAG,OAAO,CAAC,MAAM,yBAAyB,SAAS,4BAA4B,CAChF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict Commander option parser for a non-negative integer CLI flag (`-j/--concurrency`,
|
|
3
|
+
* `--retry`, …). Shared by `batchCommand.ts` and `evalCommand.ts`.
|
|
4
|
+
*
|
|
5
|
+
* Unlike a bare `parseInt(value, 10)`, this rejects trailing-garbage input such as `"10abc"` —
|
|
6
|
+
* `parseInt` stops at the first non-digit and returns `10`, and `Number.isFinite` on that result
|
|
7
|
+
* is still `true`, so the garbage silently passed through undetected. A regex pre-check (only
|
|
8
|
+
* ASCII digits, at least one) rejects that case, plus other loose inputs a bare `Number()`
|
|
9
|
+
* coercion would let through (`""` → `0`, `"1e3"` → `1000`, `" 5 "` → `5`, `"0x10"` → `16`) or
|
|
10
|
+
* that don't make sense for a concurrency/retry count (negative, fractional).
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseIntOption(value: string): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict Commander option parser for a non-negative integer CLI flag (`-j/--concurrency`,
|
|
3
|
+
* `--retry`, …). Shared by `batchCommand.ts` and `evalCommand.ts`.
|
|
4
|
+
*
|
|
5
|
+
* Unlike a bare `parseInt(value, 10)`, this rejects trailing-garbage input such as `"10abc"` —
|
|
6
|
+
* `parseInt` stops at the first non-digit and returns `10`, and `Number.isFinite` on that result
|
|
7
|
+
* is still `true`, so the garbage silently passed through undetected. A regex pre-check (only
|
|
8
|
+
* ASCII digits, at least one) rejects that case, plus other loose inputs a bare `Number()`
|
|
9
|
+
* coercion would let through (`""` → `0`, `"1e3"` → `1000`, `" 5 "` → `5`, `"0x10"` → `16`) or
|
|
10
|
+
* that don't make sense for a concurrency/retry count (negative, fractional).
|
|
11
|
+
*/
|
|
12
|
+
export function parseIntOption(value) {
|
|
13
|
+
if (!/^\d+$/.test(value)) {
|
|
14
|
+
throw new Error(`Expected an integer, got "${value}"`);
|
|
15
|
+
}
|
|
16
|
+
return parseInt(value, 10);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=cliOptionParsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliOptionParsers.js","sourceRoot":"","sources":["../../src/commands/cliOptionParsers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,GAAG,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7B,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,CAA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ACjB,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
|
|
6
|
-
readonly 'jira-legacy':
|
|
7
|
-
readonly jira:
|
|
8
|
-
readonly github:
|
|
9
|
-
readonly text:
|
|
10
|
-
readonly file:
|
|
5
|
+
export declare const REQUIREMENTS_SOURCES: {
|
|
6
|
+
readonly 'jira-legacy': '@gaunt-sloth/review/sources/jiraIssueLegacySource.js';
|
|
7
|
+
readonly jira: '@gaunt-sloth/review/sources/jiraIssueSource.js';
|
|
8
|
+
readonly github: '@gaunt-sloth/review/sources/ghIssueSource.js';
|
|
9
|
+
readonly text: '@gaunt-sloth/review/sources/textSource.js';
|
|
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
|
|
17
|
-
readonly github:
|
|
18
|
-
readonly text:
|
|
19
|
-
readonly file:
|
|
16
|
+
export declare const CONTENT_SOURCES: {
|
|
17
|
+
readonly github: '@gaunt-sloth/review/sources/ghPrDiffSource.js';
|
|
18
|
+
readonly text: '@gaunt-sloth/review/sources/textSource.js';
|
|
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>;
|