@gaunt-sloth/core 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.
Files changed (158) hide show
  1. package/.gsloth.code.md +10 -0
  2. package/README.md +6 -6
  3. package/dist/config/defaults.d.ts +85 -0
  4. package/dist/config/defaults.js +103 -0
  5. package/dist/config/defaults.js.map +1 -0
  6. package/dist/config/jsonc.d.ts +12 -0
  7. package/dist/config/jsonc.js +41 -0
  8. package/dist/config/jsonc.js.map +1 -0
  9. package/dist/config/loader.d.ts +169 -0
  10. package/dist/config/loader.js +872 -0
  11. package/dist/config/loader.js.map +1 -0
  12. package/dist/config/schema.d.ts +673 -0
  13. package/dist/config/schema.js +524 -0
  14. package/dist/config/schema.js.map +1 -0
  15. package/dist/config/shell-policy.d.ts +331 -0
  16. package/dist/config/shell-policy.js +238 -0
  17. package/dist/config/shell-policy.js.map +1 -0
  18. package/dist/config/types.d.ts +596 -0
  19. package/dist/config/types.js +13 -0
  20. package/dist/config/types.js.map +1 -0
  21. package/dist/config.d.ts +18 -647
  22. package/dist/config.js +15 -516
  23. package/dist/config.js.map +1 -1
  24. package/dist/constants.d.ts +42 -0
  25. package/dist/constants.js +42 -0
  26. package/dist/constants.js.map +1 -1
  27. package/dist/core/GthAbstractAgent.d.ts +85 -2
  28. package/dist/core/GthAbstractAgent.js +398 -28
  29. package/dist/core/GthAbstractAgent.js.map +1 -1
  30. package/dist/core/GthAgentRunner.d.ts +158 -1
  31. package/dist/core/GthAgentRunner.js +367 -4
  32. package/dist/core/GthAgentRunner.js.map +1 -1
  33. package/dist/core/GthLangChainAgent.js +193 -16
  34. package/dist/core/GthLangChainAgent.js.map +1 -1
  35. package/dist/core/debugCapture.d.ts +59 -0
  36. package/dist/core/debugCapture.js +101 -0
  37. package/dist/core/debugCapture.js.map +1 -0
  38. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  39. package/dist/core/gthLeanAgentFactory.js +10 -0
  40. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  41. package/dist/core/plainToolIndication.d.ts +15 -0
  42. package/dist/core/plainToolIndication.js +148 -0
  43. package/dist/core/plainToolIndication.js.map +1 -0
  44. package/dist/core/runStats.d.ts +41 -0
  45. package/dist/core/runStats.js +73 -0
  46. package/dist/core/runStats.js.map +1 -0
  47. package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
  48. package/dist/core/shell/ShellCommandFailedError.js +68 -0
  49. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  50. package/dist/core/shell/allowlist.d.ts +75 -0
  51. package/dist/core/shell/allowlist.js +187 -0
  52. package/dist/core/shell/allowlist.js.map +1 -0
  53. package/dist/core/shell/arity.d.ts +75 -0
  54. package/dist/core/shell/arity.js +313 -0
  55. package/dist/core/shell/arity.js.map +1 -0
  56. package/dist/core/shell/judge.d.ts +161 -0
  57. package/dist/core/shell/judge.js +261 -0
  58. package/dist/core/shell/judge.js.map +1 -0
  59. package/dist/core/shell/normalize.d.ts +27 -0
  60. package/dist/core/shell/normalize.js +53 -0
  61. package/dist/core/shell/normalize.js.map +1 -0
  62. package/dist/core/toolDisplay.d.ts +101 -0
  63. package/dist/core/toolDisplay.js +374 -0
  64. package/dist/core/toolDisplay.js.map +1 -0
  65. package/dist/core/toolOutputChannel.d.ts +68 -0
  66. package/dist/core/toolOutputChannel.js +112 -0
  67. package/dist/core/toolOutputChannel.js.map +1 -0
  68. package/dist/core/types.d.ts +173 -0
  69. package/dist/core/types.js.map +1 -1
  70. package/dist/history/historyFormat.d.ts +28 -0
  71. package/dist/history/historyFormat.js +127 -0
  72. package/dist/history/historyFormat.js.map +1 -0
  73. package/dist/history/historyStore.d.ts +198 -0
  74. package/dist/history/historyStore.js +482 -0
  75. package/dist/history/historyStore.js.map +1 -0
  76. package/dist/history/recordSession.d.ts +37 -0
  77. package/dist/history/recordSession.js +56 -0
  78. package/dist/history/recordSession.js.map +1 -0
  79. package/dist/index.d.ts +4 -0
  80. package/dist/index.js +4 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/providers/anthropic.d.ts +1 -1
  83. package/dist/providers/anthropic.js +5 -10
  84. package/dist/providers/anthropic.js.map +1 -1
  85. package/dist/providers/deepseek.d.ts +1 -1
  86. package/dist/providers/deepseek.js +5 -10
  87. package/dist/providers/deepseek.js.map +1 -1
  88. package/dist/providers/geminiSchemaSanitizer.d.ts +52 -0
  89. package/dist/providers/geminiSchemaSanitizer.js +201 -0
  90. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  91. package/dist/providers/google-genai.d.ts +1 -1
  92. package/dist/providers/google-genai.js +9 -11
  93. package/dist/providers/google-genai.js.map +1 -1
  94. package/dist/providers/groq.d.ts +1 -1
  95. package/dist/providers/groq.js +5 -10
  96. package/dist/providers/groq.js.map +1 -1
  97. package/dist/providers/huggingface.d.ts +25 -0
  98. package/dist/providers/huggingface.js +69 -0
  99. package/dist/providers/huggingface.js.map +1 -0
  100. package/dist/providers/modelCatalog.d.ts +109 -0
  101. package/dist/providers/modelCatalog.js +245 -0
  102. package/dist/providers/modelCatalog.js.map +1 -0
  103. package/dist/providers/modelDiscovery.d.ts +111 -3
  104. package/dist/providers/modelDiscovery.js +183 -27
  105. package/dist/providers/modelDiscovery.js.map +1 -1
  106. package/dist/providers/ollama.d.ts +19 -5
  107. package/dist/providers/ollama.js +60 -52
  108. package/dist/providers/ollama.js.map +1 -1
  109. package/dist/providers/openai.d.ts +1 -1
  110. package/dist/providers/openai.js +5 -10
  111. package/dist/providers/openai.js.map +1 -1
  112. package/dist/providers/openrouter.d.ts +1 -1
  113. package/dist/providers/openrouter.js +12 -12
  114. package/dist/providers/openrouter.js.map +1 -1
  115. package/dist/providers/vertexai.d.ts +1 -1
  116. package/dist/providers/vertexai.js +9 -11
  117. package/dist/providers/vertexai.js.map +1 -1
  118. package/dist/providers/xai.d.ts +1 -1
  119. package/dist/providers/xai.js +5 -10
  120. package/dist/providers/xai.js.map +1 -1
  121. package/dist/runtime/askStructured.d.ts +62 -0
  122. package/dist/runtime/askStructured.js +76 -0
  123. package/dist/runtime/askStructured.js.map +1 -0
  124. package/dist/runtime/conversation.d.ts +59 -0
  125. package/dist/runtime/conversation.js +137 -0
  126. package/dist/runtime/conversation.js.map +1 -0
  127. package/dist/runtime/singleShot.d.ts +24 -5
  128. package/dist/runtime/singleShot.js +56 -9
  129. package/dist/runtime/singleShot.js.map +1 -1
  130. package/dist/utils/aiignoreUtils.js.map +1 -1
  131. package/dist/utils/binaryOutputUtils.js.map +1 -1
  132. package/dist/utils/consoleUtils.d.ts +22 -0
  133. package/dist/utils/consoleUtils.js +45 -0
  134. package/dist/utils/consoleUtils.js.map +1 -1
  135. package/dist/utils/debugDump.d.ts +57 -0
  136. package/dist/utils/debugDump.js +236 -0
  137. package/dist/utils/debugDump.js.map +1 -0
  138. package/dist/utils/debugUtils.d.ts +13 -4
  139. package/dist/utils/debugUtils.js +36 -13
  140. package/dist/utils/debugUtils.js.map +1 -1
  141. package/dist/utils/fileUtils.d.ts +24 -2
  142. package/dist/utils/fileUtils.js +54 -12
  143. package/dist/utils/fileUtils.js.map +1 -1
  144. package/dist/utils/llmUtils.js.map +1 -1
  145. package/dist/utils/redactSecrets.d.ts +63 -0
  146. package/dist/utils/redactSecrets.js +238 -0
  147. package/dist/utils/redactSecrets.js.map +1 -0
  148. package/dist/utils/systemPromptNotes.d.ts +181 -0
  149. package/dist/utils/systemPromptNotes.js +298 -0
  150. package/dist/utils/systemPromptNotes.js.map +1 -0
  151. package/dist/utils/systemUtils.d.ts +32 -1
  152. package/dist/utils/systemUtils.js +50 -3
  153. package/dist/utils/systemUtils.js.map +1 -1
  154. package/dist/utils/toolMatching.d.ts +30 -0
  155. package/dist/utils/toolMatching.js +44 -0
  156. package/dist/utils/toolMatching.js.map +1 -0
  157. package/package.json +17 -8
  158. package/schema/gsloth-config.schema.json +2111 -0
package/dist/config.d.ts CHANGED
@@ -1,654 +1,25 @@
1
- import { StatusLevel } from '#src/core/types.js';
2
- import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
3
- import type { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
4
1
  /**
5
- * This is a processed Gaunt Sloth config ready to be passed down into components.
2
+ * @packageDocumentation
3
+ * Gaunt Sloth Configuration.
6
4
  *
7
- * Default values can be found in {@link DEFAULT_CONFIG}
8
- */
9
- export interface GthConfig {
10
- llm: BaseChatModel;
11
- /**
12
- * Binary format support configuration.
13
- * Disabled by default unless explicitly configured.
14
- */
15
- binaryFormats?: false | BinaryFormatConfig[];
16
- /**
17
- * Content Provider. Provider used to fetch content (usually diff) for `review` or `pr` command.
18
- *
19
- * {@link DEFAULT_CONFIG#contentProvider}
20
- */
21
- /**
22
- * Content source type. Preferred name for contentProvider.
23
- */
24
- contentSource: string;
25
- /**
26
- * Requirement source type. Preferred name for requirementsProvider.
27
- */
28
- requirementSource: string;
29
- /**
30
- * @deprecated Use contentSource instead
31
- */
32
- contentProvider: string;
33
- /**
34
- * @deprecated Use requirementSource instead
35
- */
36
- requirementsProvider: string;
37
- /**
38
- * Path to project-specific guidelines.
39
- * The default is `.gsloth.guidelines.md`; this config may be used to point Gaunt Sloth to a different file,
40
- * for example, to AGENTS.md
41
- */
42
- projectGuidelines: string;
43
- /**
44
- * Separate identity profile.
45
- * May include separate identity, guidelines and command protocol,
46
- * making gsloth behave as an agent different from default profile behaviour.
47
- * for example, `devops` profile to detect changes such as properties and environment variables.
48
- * Custom config can still win over this one.
49
- * This setting requires .gsloth/.gsloth-settings directory to exist.
50
- */
51
- identityProfile?: string;
52
- /**
53
- * Whether to include the current date in the project review instructions or not.
54
- */
55
- includeCurrentDateAfterGuidelines: boolean;
56
- /**
57
- * Organisation name, locale and timezone.
58
- * Only used with {@link includeCurrentDateAfterGuidelines}.
59
- * timeZone and locale should be in format supported by Intl.DateTimeFormat
60
- */
61
- organization?: {
62
- name?: string;
63
- locale?: string;
64
- timezone?: string;
65
- };
66
- projectReviewInstructions: string;
67
- /**
68
- * If true, only use user-provided system prompts. Do not fall back to the
69
- * bundled `.gsloth.*.md` prompt files shipped with the installation.
70
- * This applies to all `.gsloth.*.md` files (backstory, system, chat, code, guidelines, review).
71
- */
72
- noDefaultPrompts?: boolean;
73
- filesystem: string[] | 'all' | 'read' | 'none';
74
- builtInTools?: string[];
75
- tools?: StructuredToolInterface[] | BaseToolkit[] | ServerTool[];
76
- /**
77
- * Restrict the agent to this allow-list of tool names, applied after every tool source
78
- * (filesystem, built-in, custom, MCP, A2A, and `tools`) is resolved. This is the only knob
79
- * that can gate MCP and A2A tools, which have no per-source override of their own.
80
- *
81
- * - omitted/undefined: no filtering, all resolved tools remain available.
82
- * - non-empty array: keep only tools whose name is in the list.
83
- * - empty array `[]`: disable every tool. MCP servers are not even contacted (no OAuth),
84
- * which is useful for agents that only need to reason over the prompt (e.g. the review
85
- * agent).
86
- *
87
- * Can be overridden per command via `commands.<command>.allowedTools`.
88
- */
89
- allowedTools?: string[];
90
- /**
91
- * Middleware configuration for LangChain v1.
92
- * Middleware provides hooks to intercept and control agent execution at critical points.
93
- *
94
- * Middleware can be:
95
- * - Predefined middleware (string or config object) - works in both JSON and JS configs
96
- * - Custom middleware objects - only available in JS configs
97
- *
98
- * Example (JSON config):
99
- * ```json
100
- * {
101
- * "middleware": [
102
- * "summarization",
103
- * { "name": "anthropic-prompt-caching", "ttl": "5m" }
104
- * ]
105
- * }
106
- * ```
107
- *
108
- * Example (JS config):
109
- * ```js
110
- * {
111
- * middleware: [
112
- * "summarization",
113
- * { beforeModel: (state) => { /* custom logic *\/ return state; } }
114
- * ]
115
- * }
116
- * ```
117
- *
118
- * Available predefined middleware:
119
- * - `anthropic-prompt-caching`: Reduces API costs by caching prompts (Anthropic only)
120
- * - `summarization`: Condenses conversation history when approaching token limits
121
- */
122
- middleware?: unknown[];
123
- /**
124
- * Stream output. Some models do not support streaming. Set value to `false` for them.
125
- *
126
- * {@link DEFAULT_CONFIG#streamOutput}
127
- */
128
- streamOutput: boolean;
129
- /**
130
- * Should the output be written to md file.
131
- * (e.g. gth_2025-07-26_22-59-06_REVIEW.md).
132
- * Can be set to false with `-wn` or `-w0`
133
- * Can be set to a specific filename or path by passing a string:
134
- * - Bare filenames (e.g. `"review.md"`) are placed in `.gsloth/` when it exists, otherwise project root
135
- * - Paths with separators (e.g. `"./review.md"` or `"reviews/last.md"`) are always relative to project root
136
- * Please note the string does not accept absolute path, but allows to exit project with `..` if necessary.
137
- */
138
- writeOutputToFile: boolean | string;
139
- /**
140
- * Whether binary model outputs should be written to files instead of printed inline.
141
- * When enabled, supported binary content blocks are materialized as `gth_*.<ext>` files.
142
- */
143
- writeBinaryOutputsToFile: boolean;
144
- /**
145
- * Use colour in output
146
- */
147
- useColour: boolean;
148
- /**
149
- * Stream session log instead of writing it when inference streaming is complete.
150
- * (only works when {@link streamOutput} is true)
151
- */
152
- streamSessionInferenceLog: boolean;
153
- /**
154
- * Allow inference to be interrupted with esc. Only has an effect in TTY mode.
155
- */
156
- canInterruptInferenceWithEsc: boolean;
157
- /**
158
- * Log messages and events to gaunt-sloth.log,
159
- * use llm.verbose or `gth --verbose` as more intrusive option, setting verbose to LangChain / LangGraph
160
- */
161
- debugLog?: boolean;
162
- /**
163
- * LangGraph recursion limit for an agent run — the maximum number of
164
- * super-steps (model ↔ tool round-trips) before the graph throws. Defaults to
165
- * 1000, which suits long coding chains; embodied / tight-loop consumers can
166
- * lower it so a stuck run fails fast and visibly instead of grinding.
167
- */
168
- recursionLimit?: number;
169
- /**
170
- * Console logging level. Only messages at or above this level will be displayed.
171
- * Valid values: 'debug', 'info', 'display', 'success', 'warning', 'error', 'stream'
172
- * Default: 'info' (not debug)
173
- */
174
- consoleLevel?: StatusLevel;
175
- customTools?: CustomToolsConfig;
176
- requirementSourceConfig?: Record<string, unknown>;
177
- contentSourceConfig?: Record<string, unknown>;
178
- /** @deprecated Use requirementSourceConfig instead */
179
- requirementsProviderConfig?: Record<string, unknown>;
180
- /** @deprecated Use contentSourceConfig instead */
181
- contentProviderConfig?: Record<string, unknown>;
182
- /**
183
- * MCP (Model Context Protocol) server connections.
184
- * Allows connecting to external MCP servers including those requiring OAuth.
185
- * @see {@link https://modelcontextprotocol.io/}
186
- */
187
- mcpServers?: Record<string, unknown>;
188
- /**
189
- * A2A (Agent-to-Agent) protocol agents configuration.
190
- * Enables delegation of tasks to external AI agents.
191
- * Each agent becomes available as a tool named `a2a_agent_<agentId>`.
192
- * @experimental This feature is experimental and may change.
193
- * @see {@link https://a2a-protocol.org/}
194
- */
195
- a2aAgents?: Record<string, unknown>;
196
- builtInToolsConfig?: BuiltInToolsConfig;
197
- aiignore?: {
198
- enabled?: boolean;
199
- patterns?: string[];
200
- };
201
- commands?: {
202
- pr?: PrCommandConfig;
203
- review?: {
204
- contentSource?: string;
205
- requirementSource?: string;
206
- /** @deprecated Use requirementSource instead */
207
- requirementsProvider?: string;
208
- /** @deprecated Use contentSource instead */
209
- contentProvider?: string;
210
- filesystem?: string[] | 'all' | 'read' | 'none';
211
- builtInTools?: string[];
212
- customTools?: CustomToolsConfig | false;
213
- /** See {@link GthConfig.allowedTools}. Empty array disables all tools for the review agent. */
214
- allowedTools?: string[];
215
- rating?: RatingConfig;
216
- binaryFormats?: false | BinaryFormatConfig[];
217
- };
218
- ask?: {
219
- filesystem?: string[] | 'all' | 'read' | 'none';
220
- builtInTools?: string[];
221
- customTools?: CustomToolsConfig | false;
222
- /** See {@link GthConfig.allowedTools}. */
223
- allowedTools?: string[];
224
- /**
225
- * Dev tools (run commands etc.) for `ask --write` runs. Normally inherited from
226
- * `commands.exec` / `commands.code` by the `--write` flag rather than set directly.
227
- */
228
- devTools?: GthDevToolsConfig;
229
- binaryFormats?: false | BinaryFormatConfig[];
230
- };
231
- chat?: {
232
- filesystem?: string[] | 'all' | 'read' | 'none';
233
- builtInTools?: string[];
234
- customTools?: CustomToolsConfig | false;
235
- /** See {@link GthConfig.allowedTools}. */
236
- allowedTools?: string[];
237
- binaryFormats?: false | BinaryFormatConfig[];
238
- };
239
- code?: {
240
- filesystem?: string[] | 'all' | 'read' | 'none';
241
- builtInTools?: string[];
242
- customTools?: CustomToolsConfig | false;
243
- /** See {@link GthConfig.allowedTools}. */
244
- allowedTools?: string[];
245
- devTools?: GthDevToolsConfig;
246
- binaryFormats?: false | BinaryFormatConfig[];
247
- };
248
- /**
249
- * `gth exec` — prompt-as-script runtime. Like `code`, an exec run may need to actually
250
- * do the job (read/write files, run commands), so it carries the same tool/filesystem knobs.
251
- */
252
- exec?: {
253
- filesystem?: string[] | 'all' | 'read' | 'none';
254
- builtInTools?: string[];
255
- customTools?: CustomToolsConfig | false;
256
- /** See {@link GthConfig.allowedTools}. */
257
- allowedTools?: string[];
258
- devTools?: GthDevToolsConfig;
259
- binaryFormats?: false | BinaryFormatConfig[];
260
- };
261
- api?: {
262
- filesystem?: string[] | 'all' | 'read' | 'none';
263
- builtInTools?: string[];
264
- port?: number;
265
- cors?: {
266
- allowOrigin?: string;
267
- allowMethods?: string;
268
- allowHeaders?: string;
269
- };
270
- };
271
- };
272
- modelDisplayName?: string;
273
- /**
274
- * Transient (runtime-only) extra filesystem roots the agent is allowed to read/write for
275
- * THIS run, in addition to the cwd sandbox. Populated by `gth exec --allow-dir <path>`
276
- * (repeatable); never persisted to a config file. When set, the deep agent's
277
- * {@link FilesystemBackend} drops `virtualMode` (so absolute paths and `..` resolve on the
278
- * real filesystem) and access is constrained to cwd + these dirs via permission allow-rules.
279
- * Removing the cwd-only sandbox is a guardrail removal, so callers announce it loudly.
280
- */
281
- allowDirs?: string[];
282
- /**
283
- * Transient (runtime-only) flag set by `gth ask --write`: opt `ask` into the same
284
- * "do-the-job" filesystem + dev tools that `exec`/`code` get, so a question can act
285
- * (read/write files, run commands) rather than only chat. Never persisted to a config file.
286
- */
287
- askWriteMode?: boolean;
288
- }
289
- /**
290
- * `gth pr` command configuration.
5
+ * Refer to {@link GthConfig} to find all possible configuration properties.
291
6
  *
292
- * Declared as a named interface (rather than inline in {@link GthConfig}) so that downstream
293
- * packages can extend it with their own command features via TypeScript module augmentation
294
- * (`declare module '@gaunt-sloth/core/config.js'`), keeping those features' types out of core.
295
- * For example, the assistant package merges its PR discovery config (`discovery`) into this
296
- * interface.
297
- */
298
- export interface PrCommandConfig {
299
- contentSource?: string;
300
- requirementSource?: string;
301
- /** @deprecated Use contentSource instead */
302
- contentProvider?: string;
303
- /** @deprecated Use requirementSource instead */
304
- requirementsProvider?: string;
305
- filesystem?: string[] | 'all' | 'read' | 'none';
306
- builtInTools?: string[];
307
- customTools?: CustomToolsConfig | false;
308
- /** See {@link GthConfig.allowedTools}. Empty array disables all tools for `gth pr`'s review agent. */
309
- allowedTools?: string[];
310
- logWorkForReviewInSeconds?: number;
311
- rating?: RatingConfig;
312
- binaryFormats?: false | BinaryFormatConfig[];
313
- }
314
- /**
315
- * Server tools such as Anthropic Web Search.
316
- * These tools are meant to be magic objects like
317
- * `{"type": "web_search_20250305", "name": "web_search", "max_uses": 10}`,
318
- * AI Provider does the rest of the magic on their side.
319
- */
320
- export interface ServerTool extends Record<string, unknown> {
321
- type: string;
322
- name?: string;
323
- }
324
- /**
325
- * Raw, unprocessed Gaunt Sloth config.
326
- */
327
- export type ConsoleLevelInput = StatusLevel | keyof typeof StatusLevel | Lowercase<keyof typeof StatusLevel>;
328
- export interface RawGthConfig extends Omit<GthConfig, 'llm' | 'consoleLevel'> {
329
- llm: LLMConfig;
330
- consoleLevel?: ConsoleLevelInput;
331
- }
332
- export type BinaryFormatType = 'image' | 'file' | 'audio' | 'video' | 'binary';
333
- export interface BinaryFormatConfig {
334
- /**
335
- * The type/category of binary format.
336
- */
337
- type: BinaryFormatType;
338
- /**
339
- * List of allowed extensions for this type (without leading dot).
340
- */
341
- extensions: string[];
342
- /**
343
- * Maximum file size in bytes. Defaults to 10MB when omitted.
344
- */
345
- maxSize?: number;
346
- /**
347
- * Optional MIME type overrides for extensions not in the default mapping.
348
- */
349
- mimeTypes?: Record<string, string>;
350
- }
351
- export type CustomToolsConfig = Record<string, CustomCommandConfig>;
352
- export type BuiltInToolsConfig = Record<string, unknown>;
353
- /**
354
- * Configuration for review rating feature.
355
- * Allows configuring automated review scoring with pass/fail thresholds.
356
- */
357
- export interface RatingConfig {
358
- /**
359
- * Enable or disable review rating.
360
- * @default true
361
- */
362
- enabled?: boolean;
363
- /**
364
- * Minimum score (0-10) required to pass the review.
365
- * @default 6
366
- */
367
- passThreshold?: number;
368
- /**
369
- * Highest allowed value on the rating scale.
370
- * @default 10
371
- */
372
- maxRating?: number;
373
- /**
374
- * Lowest allowed value on the rating scale.
375
- * @default 0
376
- */
377
- minRating?: number;
378
- /**
379
- * Exit with error code 1 when review fails (below threshold).
380
- * When false, exits normally (code 0) regardless of rating.
381
- * @default true
382
- */
383
- errorOnReviewFail?: boolean;
384
- }
385
- /**
386
- * Validation checks that can be skipped for custom command parameters.
387
- * Use with the `allow` property to bypass specific security checks.
7
+ * Refer to {@link DEFAULT_CONFIG} for default configuration.
388
8
  *
389
- * - `absolute-paths`: Allow absolute paths (e.g. `/dev/ttyUSB0`)
390
- * - `directory-traversal`: Allow `..` in paths
391
- * - `shell-injection`: Allow shell metacharacters (`|`, `&`, `;`, etc.)
392
- * - `null-bytes`: Allow null bytes in values
393
- */
394
- export type ValidationCheck = 'absolute-paths' | 'directory-traversal' | 'shell-injection' | 'null-bytes';
395
- /**
396
- * Configuration for a custom command parameter.
397
- * Parameters allow the model to provide dynamic values to commands.
398
- */
399
- export interface CustomCommandParameter {
400
- /**
401
- * Description of the parameter shown to the model.
402
- */
403
- description: string;
404
- /**
405
- * Optional list of validation checks to skip for this parameter's value.
406
- * Use when this parameter legitimately requires values that would normally be blocked.
407
- * For example, `["absolute-paths"]` allows values like `/dev/ttyUSB0` for this parameter.
408
- *
409
- * Available checks: `absolute-paths`, `directory-traversal`, `shell-injection`, `null-bytes`
410
- */
411
- allow?: ValidationCheck[];
412
- }
413
- /**
414
- * Configuration for a custom command.
415
- * Custom commands can be executed with or without parameters.
416
- */
417
- export interface CustomCommandConfig {
418
- /**
419
- * The shell command to execute.
420
- * Can include placeholders like ${paramName} that will be replaced with parameter values.
421
- * If no placeholder is present and parameters are provided, they are appended to the command.
422
- */
423
- command: string;
424
- /**
425
- * Description of what this command does, shown to the model.
426
- */
427
- description: string;
428
- /**
429
- * Optional parameters that the model can provide when calling this command.
430
- * Each parameter has a name (the key) and a description.
431
- * Parameters are validated for security (no shell injection, directory traversal, etc.).
432
- */
433
- parameters?: Record<string, CustomCommandParameter>;
434
- /**
435
- * Optional timeout in seconds.
436
- * When set, the command will be killed if it exceeds this duration.
437
- * When omitted, no timeout is applied.
438
- */
439
- timeout?: number;
440
- }
441
- /**
442
- * Config for {@link GthDevToolkit}.
443
- * Tools are not applied when config is not provided.
444
- * Only available in `code` mode.
445
- */
446
- export interface GthDevToolsConfig {
447
- /**
448
- * Optional shell command to run tests.
449
- * Not applied when config is not provided.
450
- */
451
- run_tests?: string;
452
- /**
453
- * Optional shell command to run static analysis (lint).
454
- * Not applied when config is not provided.
455
- */
456
- run_lint?: string;
457
- /**
458
- * Optional shell command to run the build.
459
- * Not applied when config is not provided.
460
- */
461
- run_build?: string;
462
- /**
463
- * Optional shell command to run a single test file.
464
- * Supports command interpolation with the `${testPath}` placeholder.
465
- * Example: "npm test -- ${testPath}" or "jest ${testPath}"
466
- * Example: "npm test" - the test will simply be appended
467
- * Not applied when config is not provided.
468
- */
469
- run_single_test?: string;
470
- }
471
- export interface LLMConfig extends Record<string, unknown> {
472
- type: string;
473
- model: string;
474
- configuration: Record<string, unknown>;
475
- apiKeyEnvironmentVariable?: string;
476
- }
477
- export declare const availableDefaultConfigs: readonly ["vertexai", "anthropic", "groq", "deepseek", "openai", "google-genai", "xai", "openrouter", "ollama"];
478
- export type ConfigType = (typeof availableDefaultConfigs)[number];
479
- export interface CommandLineConfigOverrides {
480
- /**
481
- * Custom config path
482
- */
483
- customConfigPath?: string;
484
- /**
485
- * Set LangChain/LangGraph to verbose mode,
486
- * causing LangChain/LangGraph to log many details to the console.
487
- * debugLog from config.ts may be a less intrusive option.
488
- */
489
- verbose?: boolean;
490
- /**
491
- * Should the output be written to md file.
492
- * (e.g. gth_2025-07-26_22-59-06_REVIEW.md).
493
- * Can be set to false with `-wn` or `-w0`
494
- * Can be set to a specific filename or path by passing a string:
495
- * - Bare filenames (e.g. `"review.md"`) are placed in `.gsloth/` when it exists, otherwise project root
496
- * - Paths with separators (e.g. `"./review.md"` or `"reviews/last.md"`) are always relative to project root
497
- * Please note the string does not accept absolute path, but allows to exit project with `..` if necessary.
498
- */
499
- writeOutputToFile?: boolean | string;
500
- /**
501
- * Separate identity profile.
502
- * May include separate identity, guidelines and command protocol,
503
- * making gsloth behave as an agent different from default profile behaviour.
504
- * for example, `devops` profile to detect changes such as properties and environment variables.
505
- * Custom config can still win over this one.
506
- * This setting requires .gsloth/.gsloth-settings directory to exist.
507
- * Important to note that the profile directory substitutes the entire config directory,
508
- * in the case if some prompt files are missing - a file from the installation directory will be used.
509
- */
510
- identityProfile?: string;
511
- /**
512
- * Interactive TUI activation override for chat/code sessions.
513
- * - `true` (`--tui`): force the Ink TUI on where the terminal supports it (also overrides
514
- * the CI auto-off heuristic).
515
- * - `false` (`--no-tui`): force the plain readline session.
516
- * - `undefined` (default): auto-detect from the terminal.
517
- * The decision itself lives in `gaunt-sloth`'s `shouldUseTui`; this only carries the flag.
518
- */
519
- tui?: boolean;
520
- }
521
- /**
522
- * Default config
523
- */
524
- export declare const DEFAULT_CONFIG: {
525
- readonly contentSource: "file";
526
- readonly requirementSource: "file";
527
- readonly contentProvider: "file";
528
- readonly requirementsProvider: "file";
529
- /**
530
- * Path to project-specific guidelines.
531
- * The default is `.gsloth.guidelines.md`; this config may be used to point Gaunt Sloth to a different file,
532
- * for example, to AGENTS.md
533
- */
534
- readonly projectGuidelines: ".gsloth.guidelines.md";
535
- /**
536
- * Whether to include the current date in the project review instructions or not.
537
- */
538
- readonly includeCurrentDateAfterGuidelines: false;
539
- readonly projectReviewInstructions: ".gsloth.review.md";
540
- readonly filesystem: "none";
541
- readonly debugLog: false;
542
- readonly consoleLevel: StatusLevel.INFO;
543
- /**
544
- * Default provider for both requirements and content is GitHub.
545
- * It needs GitHub CLI (gh).
546
- *
547
- * `github` content provider uses `gh pr diff NN` internally. {@link src/providers/ghPrDiffProvider.ts!}
548
- *
549
- *
550
- * `github` requirements provider `gh issue view NN` internally
551
- */
552
- readonly commands: {
553
- readonly pr: {
554
- readonly contentSource: "github";
555
- readonly requirementSource: "github";
556
- readonly contentProvider: "github";
557
- readonly requirementsProvider: "github";
558
- readonly rating: {
559
- readonly enabled: true;
560
- readonly passThreshold: 6;
561
- readonly minRating: 0;
562
- readonly maxRating: 10;
563
- readonly errorOnReviewFail: true;
564
- };
565
- };
566
- readonly review: {
567
- readonly rating: {
568
- readonly enabled: true;
569
- readonly passThreshold: 6;
570
- readonly minRating: 0;
571
- readonly maxRating: 10;
572
- readonly errorOnReviewFail: true;
573
- };
574
- };
575
- readonly ask: {
576
- readonly filesystem: "read";
577
- };
578
- readonly chat: {
579
- readonly filesystem: "read";
580
- };
581
- readonly code: {
582
- readonly filesystem: "all";
583
- };
584
- readonly exec: {
585
- readonly filesystem: "all";
586
- };
587
- readonly api: {
588
- readonly filesystem: "read";
589
- readonly port: 3000;
590
- readonly cors: {
591
- readonly allowOrigin: "http://localhost:3000";
592
- readonly allowMethods: "POST, GET, OPTIONS";
593
- readonly allowHeaders: "Content-Type, Accept";
594
- };
595
- };
596
- };
597
- readonly streamOutput: true;
598
- readonly writeOutputToFile: true;
599
- readonly writeBinaryOutputsToFile: true;
600
- readonly useColour: true;
601
- readonly streamSessionInferenceLog: true;
602
- readonly canInterruptInferenceWithEsc: true;
603
- readonly aiignore: {
604
- readonly enabled: true;
605
- readonly patterns: undefined;
606
- };
607
- };
608
- /**
609
- * Loads the global gsloth config (if present) from the global `~/.gsloth` folder.
610
- *
611
- * Precedence support: the returned raw config is intended to act as the BASE that the
612
- * project config (and CLI overrides) merge on top of, so any value here is the lowest
613
- * user-controlled layer (still above {@link DEFAULT_CONFIG}).
614
- *
615
- * Lookup order within the global folder, first match wins:
616
- * `.gsloth.config.json` -> `.gsloth.config.js` -> `.gsloth.config.mjs`
617
- *
618
- * Absence of every variant is a no-op: returns `undefined` so behaviour is unchanged.
619
- *
620
- * NOTE: secrets (API keys) may live in this file; this function must never log its
621
- * contents. Only non-sensitive diagnostics (the resolved path / parse failure) are emitted.
622
- *
623
- * @returns The raw global config object, or `undefined` when no global config exists.
624
- */
625
- export declare function loadGlobalRawConfig(): Promise<Partial<RawGthConfig> | undefined>;
626
- /**
627
- * Returns true when a project-level config file (json/js/mjs) exists for the given
628
- * overrides. Honours `customConfigPath` and the active identity profile so the check
629
- * matches exactly what {@link initConfig} would attempt to load.
9
+ * Some config params can be overriden from command line, see {@link CommandLineConfigOverrides}
630
10
  *
631
- * This is the project half of CFG-10's "is any config present?" detection; the global
632
- * half is {@link loadGlobalRawConfig} (used by {@link hasAnyConfig}).
633
- */
634
- export declare function hasProjectConfig(commandLineConfigOverrides: CommandLineConfigOverrides): boolean;
635
- /**
636
- * CFG-10true when ANY usable configuration is present, either a project config file
637
- * (json/js/mjs) or a standalone global config (`~/.gsloth/.gsloth.config.*`). When this
638
- * returns false the caller should run the first-run dialog instead of erroring.
11
+ * This module is the **public barrel** for the configuration system. The implementation
12
+ * is split into focused modules under `config/`:
13
+ * - `config/types.ts` — the configuration type surface.
14
+ * - `config/shell-policy.ts` {@link GthDevToolsConfig} + the shell/dev-tools resolvers.
15
+ * - `config/defaults.ts` — {@link DEFAULT_CONFIG}.
16
+ * - `config/loader.ts` discovery + the layered load/merge pipeline.
17
+ * - `config/schema.ts` the Zod schema (single source of truth) + JSON-Schema generator.
639
18
  *
640
- * Reuses CFG-8's project + global detection so the two paths can never disagree.
641
- */
642
- export declare function hasAnyConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<boolean>;
643
- /**
644
- * Initialize configuration by loading from available config files
645
- * @returns The loaded GthConfig
646
- */
647
- export declare function initConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
648
- /**
649
- * Process JSON LLM config by creating the appropriate LLM instance
650
- * @param jsonConfig - The parsed JSON config
651
- * @param commandLineConfigOverrides - command line config overrides
652
- * @returns Promise<GthConfig>
19
+ * Every name that was previously exported from `config.ts` is re-exported here, so the
20
+ * public import path `@gaunt-sloth/core/config.js` (and `#src/config.js`) is unchanged.
653
21
  */
654
- export declare function tryJsonConfig(jsonConfig: RawGthConfig, commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
22
+ export * from '#src/config/types.js';
23
+ export * from '#src/config/shell-policy.js';
24
+ export * from '#src/config/defaults.js';
25
+ export * from '#src/config/loader.js';