@gaunt-sloth/core 2.0.0-alpha.3 → 2.0.0-alpha.30

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 (271) hide show
  1. package/README.md +52 -20
  2. package/dist/config/colour.d.ts +38 -0
  3. package/dist/config/colour.js +36 -0
  4. package/dist/config/colour.js.map +1 -0
  5. package/dist/config/defaults.d.ts +84 -0
  6. package/dist/config/defaults.js +99 -0
  7. package/dist/config/defaults.js.map +1 -0
  8. package/dist/config/filesystem-tools.d.ts +41 -0
  9. package/dist/config/filesystem-tools.js +56 -0
  10. package/dist/config/filesystem-tools.js.map +1 -0
  11. package/dist/config/jsonc.d.ts +12 -0
  12. package/dist/config/jsonc.js +41 -0
  13. package/dist/config/jsonc.js.map +1 -0
  14. package/dist/config/loader.d.ts +246 -0
  15. package/dist/config/loader.js +1321 -0
  16. package/dist/config/loader.js.map +1 -0
  17. package/dist/config/mouse.d.ts +50 -0
  18. package/dist/config/mouse.js +44 -0
  19. package/dist/config/mouse.js.map +1 -0
  20. package/dist/config/profiles.d.ts +68 -0
  21. package/dist/config/profiles.js +93 -0
  22. package/dist/config/profiles.js.map +1 -0
  23. package/dist/config/providerKeys.d.ts +69 -0
  24. package/dist/config/providerKeys.js +69 -0
  25. package/dist/config/providerKeys.js.map +1 -0
  26. package/dist/config/schema.d.ts +2999 -0
  27. package/dist/config/schema.js +1519 -0
  28. package/dist/config/schema.js.map +1 -0
  29. package/dist/config/shell-policy.d.ts +896 -0
  30. package/dist/config/shell-policy.js +750 -0
  31. package/dist/config/shell-policy.js.map +1 -0
  32. package/dist/config/tool-descriptions.d.ts +211 -0
  33. package/dist/config/tool-descriptions.js +272 -0
  34. package/dist/config/tool-descriptions.js.map +1 -0
  35. package/dist/config/types.d.ts +760 -0
  36. package/dist/config/types.js +13 -0
  37. package/dist/config/types.js.map +1 -0
  38. package/dist/config.d.ts +34 -827
  39. package/dist/config.js +25 -657
  40. package/dist/config.js.map +1 -1
  41. package/dist/constants.d.ts +46 -0
  42. package/dist/constants.js +46 -0
  43. package/dist/constants.js.map +1 -1
  44. package/dist/core/GthAbstractAgent.d.ts +135 -2
  45. package/dist/core/GthAbstractAgent.js +496 -30
  46. package/dist/core/GthAbstractAgent.js.map +1 -1
  47. package/dist/core/GthAgentRunner.d.ts +568 -54
  48. package/dist/core/GthAgentRunner.js +1537 -136
  49. package/dist/core/GthAgentRunner.js.map +1 -1
  50. package/dist/core/GthLangChainAgent.d.ts +115 -0
  51. package/dist/core/GthLangChainAgent.js +644 -17
  52. package/dist/core/GthLangChainAgent.js.map +1 -1
  53. package/dist/core/approvals/annotations.d.ts +122 -0
  54. package/dist/core/approvals/annotations.js +137 -0
  55. package/dist/core/approvals/annotations.js.map +1 -0
  56. package/dist/core/approvals/grants.d.ts +216 -0
  57. package/dist/core/approvals/grants.js +469 -0
  58. package/dist/core/approvals/grants.js.map +1 -0
  59. package/dist/core/approvals/matcher.d.ts +202 -0
  60. package/dist/core/approvals/matcher.js +267 -0
  61. package/dist/core/approvals/matcher.js.map +1 -0
  62. package/dist/core/approvals/mcpSubjects.d.ts +40 -0
  63. package/dist/core/approvals/mcpSubjects.js +99 -0
  64. package/dist/core/approvals/mcpSubjects.js.map +1 -0
  65. package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
  66. package/dist/core/approvals/toolAnnotationSources.js +277 -0
  67. package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
  68. package/dist/core/approvals/toolHost.d.ts +46 -0
  69. package/dist/core/approvals/toolHost.js +108 -0
  70. package/dist/core/approvals/toolHost.js.map +1 -0
  71. package/dist/core/debugCapture.d.ts +75 -0
  72. package/dist/core/debugCapture.js +101 -0
  73. package/dist/core/debugCapture.js.map +1 -0
  74. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  75. package/dist/core/gthLeanAgentFactory.js +10 -0
  76. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  77. package/dist/core/launchBanner.d.ts +120 -0
  78. package/dist/core/launchBanner.js +418 -0
  79. package/dist/core/launchBanner.js.map +1 -0
  80. package/dist/core/plainToolIndication.d.ts +15 -0
  81. package/dist/core/plainToolIndication.js +174 -0
  82. package/dist/core/plainToolIndication.js.map +1 -0
  83. package/dist/core/reasoningBlocks.d.ts +60 -0
  84. package/dist/core/reasoningBlocks.js +98 -0
  85. package/dist/core/reasoningBlocks.js.map +1 -0
  86. package/dist/core/refusal.d.ts +53 -0
  87. package/dist/core/refusal.js +133 -0
  88. package/dist/core/refusal.js.map +1 -0
  89. package/dist/core/runStats.d.ts +52 -0
  90. package/dist/core/runStats.js +118 -0
  91. package/dist/core/runStats.js.map +1 -0
  92. package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
  93. package/dist/core/shell/ShellCommandFailedError.js +68 -0
  94. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  95. package/dist/core/shell/abstention.d.ts +88 -0
  96. package/dist/core/shell/abstention.js +184 -0
  97. package/dist/core/shell/abstention.js.map +1 -0
  98. package/dist/core/shell/approvalCapture.d.ts +271 -0
  99. package/dist/core/shell/approvalCapture.js +108 -0
  100. package/dist/core/shell/approvalCapture.js.map +1 -0
  101. package/dist/core/shell/approvalStop.d.ts +84 -0
  102. package/dist/core/shell/approvalStop.js +119 -0
  103. package/dist/core/shell/approvalStop.js.map +1 -0
  104. package/dist/core/shell/arity.d.ts +6 -0
  105. package/dist/core/shell/arity.js +20 -6
  106. package/dist/core/shell/arity.js.map +1 -1
  107. package/dist/core/shell/denylist.d.ts +11 -0
  108. package/dist/core/shell/denylist.js +37 -0
  109. package/dist/core/shell/denylist.js.map +1 -0
  110. package/dist/core/shell/escalationSeverity.d.ts +141 -0
  111. package/dist/core/shell/escalationSeverity.js +89 -0
  112. package/dist/core/shell/escalationSeverity.js.map +1 -0
  113. package/dist/core/shell/framing.d.ts +190 -0
  114. package/dist/core/shell/framing.js +633 -0
  115. package/dist/core/shell/framing.js.map +1 -0
  116. package/dist/core/shell/hardline.d.ts +81 -0
  117. package/dist/core/shell/hardline.js +607 -0
  118. package/dist/core/shell/hardline.js.map +1 -0
  119. package/dist/core/shell/negotiation.d.ts +249 -0
  120. package/dist/core/shell/negotiation.js +355 -0
  121. package/dist/core/shell/negotiation.js.map +1 -0
  122. package/dist/core/shell/normalize.d.ts +44 -4
  123. package/dist/core/shell/normalize.js +61 -7
  124. package/dist/core/shell/normalize.js.map +1 -1
  125. package/dist/core/shell/openWorld.d.ts +263 -0
  126. package/dist/core/shell/openWorld.js +1188 -0
  127. package/dist/core/shell/openWorld.js.map +1 -0
  128. package/dist/core/shell/rater.d.ts +935 -0
  129. package/dist/core/shell/rater.js +1473 -0
  130. package/dist/core/shell/rater.js.map +1 -0
  131. package/dist/core/shell/raterModel.d.ts +41 -0
  132. package/dist/core/shell/raterModel.js +51 -0
  133. package/dist/core/shell/raterModel.js.map +1 -0
  134. package/dist/core/shell/rejection.d.ts +69 -0
  135. package/dist/core/shell/rejection.js +38 -0
  136. package/dist/core/shell/rejection.js.map +1 -0
  137. package/dist/core/toolCallRepair/grammar.d.ts +41 -0
  138. package/dist/core/toolCallRepair/grammar.js +116 -0
  139. package/dist/core/toolCallRepair/grammar.js.map +1 -0
  140. package/dist/core/toolCallRepair/index.d.ts +2 -0
  141. package/dist/core/toolCallRepair/index.js +7 -0
  142. package/dist/core/toolCallRepair/index.js.map +1 -0
  143. package/dist/core/toolCallRepair/payload.d.ts +36 -0
  144. package/dist/core/toolCallRepair/payload.js +341 -0
  145. package/dist/core/toolCallRepair/payload.js.map +1 -0
  146. package/dist/core/toolCallRepair/promote.d.ts +45 -0
  147. package/dist/core/toolCallRepair/promote.js +90 -0
  148. package/dist/core/toolCallRepair/promote.js.map +1 -0
  149. package/dist/core/toolDisplay.d.ts +123 -0
  150. package/dist/core/toolDisplay.js +451 -0
  151. package/dist/core/toolDisplay.js.map +1 -0
  152. package/dist/core/toolOutputChannel.d.ts +95 -0
  153. package/dist/core/toolOutputChannel.js +165 -0
  154. package/dist/core/toolOutputChannel.js.map +1 -0
  155. package/dist/core/types.d.ts +294 -12
  156. package/dist/core/types.js.map +1 -1
  157. package/dist/history/historyFormat.d.ts +28 -0
  158. package/dist/history/historyFormat.js +127 -0
  159. package/dist/history/historyFormat.js.map +1 -0
  160. package/dist/history/historyStore.d.ts +198 -0
  161. package/dist/history/historyStore.js +482 -0
  162. package/dist/history/historyStore.js.map +1 -0
  163. package/dist/history/recordSession.d.ts +37 -0
  164. package/dist/history/recordSession.js +56 -0
  165. package/dist/history/recordSession.js.map +1 -0
  166. package/dist/index.d.ts +4 -0
  167. package/dist/index.js +4 -0
  168. package/dist/index.js.map +1 -1
  169. package/dist/providers/anthropic.d.ts +1 -1
  170. package/dist/providers/anthropic.js +5 -10
  171. package/dist/providers/anthropic.js.map +1 -1
  172. package/dist/providers/deepseek.d.ts +1 -1
  173. package/dist/providers/deepseek.js +5 -10
  174. package/dist/providers/deepseek.js.map +1 -1
  175. package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
  176. package/dist/providers/geminiSchemaSanitizer.js +347 -0
  177. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  178. package/dist/providers/geminiThinking.d.ts +52 -0
  179. package/dist/providers/geminiThinking.js +72 -0
  180. package/dist/providers/geminiThinking.js.map +1 -0
  181. package/dist/providers/google-genai.d.ts +1 -1
  182. package/dist/providers/google-genai.js +12 -11
  183. package/dist/providers/google-genai.js.map +1 -1
  184. package/dist/providers/groq.d.ts +1 -1
  185. package/dist/providers/groq.js +5 -10
  186. package/dist/providers/groq.js.map +1 -1
  187. package/dist/providers/huggingface.d.ts +25 -0
  188. package/dist/providers/huggingface.js +69 -0
  189. package/dist/providers/huggingface.js.map +1 -0
  190. package/dist/providers/modelCatalog.d.ts +109 -0
  191. package/dist/providers/modelCatalog.js +245 -0
  192. package/dist/providers/modelCatalog.js.map +1 -0
  193. package/dist/providers/modelDiscovery.d.ts +153 -6
  194. package/dist/providers/modelDiscovery.js +295 -41
  195. package/dist/providers/modelDiscovery.js.map +1 -1
  196. package/dist/providers/ollama.d.ts +19 -5
  197. package/dist/providers/ollama.js +60 -52
  198. package/dist/providers/ollama.js.map +1 -1
  199. package/dist/providers/openai.d.ts +1 -1
  200. package/dist/providers/openai.js +39 -10
  201. package/dist/providers/openai.js.map +1 -1
  202. package/dist/providers/openrouter.d.ts +4 -5
  203. package/dist/providers/openrouter.js +20 -35
  204. package/dist/providers/openrouter.js.map +1 -1
  205. package/dist/providers/vertexai.d.ts +1 -1
  206. package/dist/providers/vertexai.js +12 -11
  207. package/dist/providers/vertexai.js.map +1 -1
  208. package/dist/providers/xai.d.ts +1 -1
  209. package/dist/providers/xai.js +5 -10
  210. package/dist/providers/xai.js.map +1 -1
  211. package/dist/runtime/askStructured.d.ts +105 -0
  212. package/dist/runtime/askStructured.js +120 -0
  213. package/dist/runtime/askStructured.js.map +1 -0
  214. package/dist/runtime/conversation.d.ts +60 -0
  215. package/dist/runtime/conversation.js +151 -0
  216. package/dist/runtime/conversation.js.map +1 -0
  217. package/dist/runtime/singleShot.d.ts +25 -5
  218. package/dist/runtime/singleShot.js +95 -36
  219. package/dist/runtime/singleShot.js.map +1 -1
  220. package/dist/runtime/structuredOutput.d.ts +104 -0
  221. package/dist/runtime/structuredOutput.js +393 -0
  222. package/dist/runtime/structuredOutput.js.map +1 -0
  223. package/dist/utils/ProgressIndicator.d.ts +21 -0
  224. package/dist/utils/ProgressIndicator.js +30 -3
  225. package/dist/utils/ProgressIndicator.js.map +1 -1
  226. package/dist/utils/aiignoreUtils.js.map +1 -1
  227. package/dist/utils/binaryOutputUtils.js.map +1 -1
  228. package/dist/utils/consoleUtils.d.ts +52 -0
  229. package/dist/utils/consoleUtils.js +72 -2
  230. package/dist/utils/consoleUtils.js.map +1 -1
  231. package/dist/utils/crashHandler.d.ts +87 -0
  232. package/dist/utils/crashHandler.js +128 -0
  233. package/dist/utils/crashHandler.js.map +1 -0
  234. package/dist/utils/debugDump.d.ts +134 -0
  235. package/dist/utils/debugDump.js +381 -0
  236. package/dist/utils/debugDump.js.map +1 -0
  237. package/dist/utils/debugUtils.d.ts +13 -4
  238. package/dist/utils/debugUtils.js +36 -13
  239. package/dist/utils/debugUtils.js.map +1 -1
  240. package/dist/utils/displayWidth.d.ts +53 -0
  241. package/dist/utils/displayWidth.js +195 -0
  242. package/dist/utils/displayWidth.js.map +1 -0
  243. package/dist/utils/fileUtils.d.ts +24 -2
  244. package/dist/utils/fileUtils.js +54 -12
  245. package/dist/utils/fileUtils.js.map +1 -1
  246. package/dist/utils/llmUtils.d.ts +39 -8
  247. package/dist/utils/llmUtils.js +76 -8
  248. package/dist/utils/llmUtils.js.map +1 -1
  249. package/dist/utils/redactSecrets.d.ts +63 -0
  250. package/dist/utils/redactSecrets.js +286 -0
  251. package/dist/utils/redactSecrets.js.map +1 -0
  252. package/dist/utils/systemPromptNotes.d.ts +225 -0
  253. package/dist/utils/systemPromptNotes.js +340 -0
  254. package/dist/utils/systemPromptNotes.js.map +1 -0
  255. package/dist/utils/systemUtils.d.ts +49 -1
  256. package/dist/utils/systemUtils.js +67 -3
  257. package/dist/utils/systemUtils.js.map +1 -1
  258. package/dist/utils/toolMatching.d.ts +30 -0
  259. package/dist/utils/toolMatching.js +44 -0
  260. package/dist/utils/toolMatching.js.map +1 -0
  261. package/dist/utils/untrustedText.d.ts +66 -0
  262. package/dist/utils/untrustedText.js +80 -0
  263. package/dist/utils/untrustedText.js.map +1 -0
  264. package/package.json +22 -6
  265. package/schema/gsloth-config.schema.json +3134 -0
  266. package/dist/core/shell/allowlist.d.ts +0 -75
  267. package/dist/core/shell/allowlist.js +0 -187
  268. package/dist/core/shell/allowlist.js.map +0 -1
  269. package/dist/core/shell/judge.d.ts +0 -161
  270. package/dist/core/shell/judge.js +0 -261
  271. package/dist/core/shell/judge.js.map +0 -1
package/README.md CHANGED
@@ -1,34 +1,66 @@
1
1
  # @gaunt-sloth/core
2
2
 
3
- Core utilities and types for Gaunt Sloth.
3
+ The foundation layer of Gaunt Sloth: the configuration system (`GthConfig`, config discovery and
4
+ loading, the JSON schema), the LLM provider factory (anthropic, deepseek, google-genai, groq,
5
+ huggingface, ollama, openai, openrouter, vertexai, xai, fake), the lean LangChain agent runtime
6
+ (`GthAgentRunner`), session history, and the shared utility modules (`consoleUtils`,
7
+ `systemUtils`, `fileUtils`, `llmUtils`, …).
4
8
 
5
- ## Contents
9
+ **When to depend on this package** — you are embedding a piece of Gaunt Sloth (or building your
10
+ own front-end on its infrastructure) and need its config resolution and provider wiring without
11
+ the CLI. Every other `@gaunt-sloth/*` package builds on it. If you just want to use Gaunt Sloth
12
+ from the terminal, install the [`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth) app
13
+ instead.
6
14
 
7
- - Configuration system (`GthConfig`, `RawGthConfig`, config loading and post-processing)
8
- - Agent infrastructure: `GthLangChainAgent`, `GthAgentRunner`
9
- - LLM provider wrappers: anthropic, deepseek, google-genai, groq, openai, openrouter, vertexai, xai, fake
10
- - Utility modules: `consoleUtils`, `debugUtils`, `fileUtils`, `llmUtils`, `systemUtils`, `stringUtils`, `aiignoreUtils`, `binaryOutputUtils`, `vertexaiUtils`, `globalConfigUtils`, `ProgressIndicator`
11
- - State and artifact storage: `artifactStore`
12
- - Shared constants and types
15
+ ## Installation
13
16
 
14
- AI vendor packages are not direct dependencies. Each vendor package is an optional peer dependency, resolved at runtime by whichever consumer (e.g. `gaunt-sloth`) pulls them in.
17
+ AI vendor packages are optional peer dependencies install the provider(s) your configuration
18
+ uses alongside core:
15
19
 
16
- ## Dependencies
17
-
18
- No other `@gaunt-sloth/*` packages.
20
+ ```bash
21
+ npm install @gaunt-sloth/core @langchain/anthropic
22
+ ```
19
23
 
20
- ## Exports
24
+ ## Embedding: resolve config into a live model
21
25
 
22
- All modules are exported via the `./` export map pattern (`./*.js`), e.g.:
26
+ I want my script to honour the user's `.gsloth.config.*` (provider, model, API keys) instead of
27
+ hard-coding a vendor SDK. With a `.gsloth.config.json` such as
28
+ `{ "llm": { "type": "anthropic", "model": "claude-sonnet-4-5" } }` in the working directory:
23
29
 
24
30
  ```js
25
- import { GthAgentRunner } from '@gaunt-sloth/core/agentRunner.js';
26
- import { display } from '@gaunt-sloth/core/utils/consoleUtils.js';
31
+ import { initConfig } from '@gaunt-sloth/core';
32
+
33
+ const config = await initConfig({}); // discovers .gsloth.config.* up-tree from cwd
34
+ // config.llm is a live LangChain chat model built from that config
35
+ const response = await config.llm.invoke('Say hello');
36
+ console.log(response.text);
27
37
  ```
28
38
 
39
+ When the configured provider has no API key anywhere — not in `llm.apiKey`, not in
40
+ `llm.apiKeyEnvironmentVariable`, not in any variable that provider accepts — `initConfig` rejects
41
+ with a `MissingProviderKeyError` carrying `provider` and `envVars`, so a caller running several
42
+ configs can report which one lacked a secret and carry on with the rest. Use
43
+ `isMissingProviderKeyError(error)` to recognise it.
44
+
45
+ All config keys (providers, prompts, tools, per-command settings) are documented in
46
+ [the configuration guide](https://github.com/pukeko-robotics/gaunt-sloth/blob/main/docs/configuration/index.md).
47
+
48
+ ## Exports
49
+
50
+ - `@gaunt-sloth/core` (the root export) is the public API: config
51
+ (`initConfig`, `GthConfig`, defaults), constants, core types, the lean agent factory, model
52
+ discovery, and session history.
53
+ - `@gaunt-sloth/core/<path>.js` deep paths (e.g. `@gaunt-sloth/core/config.js`,
54
+ `@gaunt-sloth/core/utils/consoleUtils.js`) mirror the internal `dist/` layout 1:1 and are a
55
+ deliberate part of the contract — the other `@gaunt-sloth/*` packages and downstream consumers
56
+ import them directly. They are supported at your own risk: internal files can move between
57
+ alpha/minor versions without a deprecation cycle. Prefer the root export where it suffices.
58
+
59
+ This package ships no binaries.
60
+
29
61
  ## Related packages
30
62
 
31
- - [`@gaunt-sloth/core`](../core) — Core utilities, config, and agent infrastructure (this package)
32
- - [`@gaunt-sloth/agent`](../agent) — Agent runtime: built-in tools, filesystem toolkit, middleware registry, API server, AG-UI, MCP, and A2A integration
33
- - [`@gaunt-sloth/review`](../review) — Review and Q&A modules with standalone CLI
34
- - [`gaunt-sloth`](../app) — Main CLI application
63
+ - [`@gaunt-sloth/agent`](https://www.npmjs.com/package/@gaunt-sloth/agent) — Agent runtime: built-in tools, filesystem toolkit, middleware registry, API server, AG-UI, MCP, and A2A integration ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/agent))
64
+ - [`@gaunt-sloth/review`](https://www.npmjs.com/package/@gaunt-sloth/review) — Review engine with content/requirement sources (GitHub, Jira, file, text) and standalone CLI ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/review))
65
+ - [`@gaunt-sloth/batch`](https://www.npmjs.com/package/@gaunt-sloth/batch) — Batch / eval / workflow runtime ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/batch))
66
+ - [`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth) — Main CLI application ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/app))
@@ -0,0 +1,38 @@
1
+ /**
2
+ * CFG-30 — the single place that decides whether Gaunt Sloth emits ANSI colour.
3
+ *
4
+ * Everything this decision depends on arrives as an argument: no `process.env`, no `stdout`, no
5
+ * config merge. That keeps the ladder unit-testable rung by rung without touching process globals,
6
+ * and keeps the one mutation site ({@link setUseColour}, called from `mergeConfig`) unchanged.
7
+ */
8
+ /** Everything the colour decision depends on. See {@link resolveUseColour}. */
9
+ export interface UseColourInput {
10
+ /**
11
+ * Raw `FORCE_COLOR` environment value; `undefined` when the variable is not set at all.
12
+ * The empty string is a SET value (`FORCE_COLOR=` on the command line) and means colour on.
13
+ */
14
+ forceColor?: string;
15
+ /** Raw `NO_COLOR` environment value; `undefined` when the variable is not set at all. */
16
+ noColor?: string;
17
+ /**
18
+ * `useColour` as the user actually wrote it — read from the RAW config, BEFORE `DEFAULT_CONFIG`
19
+ * is merged in. `undefined` means the user set nothing, which is what rung 3 tests for; after the
20
+ * default merge an explicit `true` is indistinguishable from the default `true`, so this value
21
+ * must be captured pre-merge or the rung collapses.
22
+ */
23
+ explicitUseColour?: boolean;
24
+ /** Whether stdout is a terminal. Rung 4's auto-detection; stdout, not stdin. */
25
+ stdoutIsTTY: boolean;
26
+ }
27
+ /**
28
+ * Resolve the effective colour setting from the four-rung precedence ladder, highest wins:
29
+ *
30
+ * 1. `FORCE_COLOR` is set — `"0"` or `"false"` turn colour OFF, ANY other value (including the
31
+ * empty string) turns it ON. This rung outranks everything below it, `NO_COLOR` included.
32
+ * 2. `NO_COLOR` is set and non-empty — colour OFF (the no-color.org convention: the variable's
33
+ * presence is the signal, its value is not, but an empty value does not count as set).
34
+ * 3. `useColour` was set explicitly in config — use it verbatim.
35
+ * 4. Otherwise auto-detect — colour ON when stdout is a terminal, OFF when it is piped or
36
+ * redirected, so captured output stays clean without any configuration.
37
+ */
38
+ export declare function resolveUseColour(input: UseColourInput): boolean;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * CFG-30 — the single place that decides whether Gaunt Sloth emits ANSI colour.
3
+ *
4
+ * Everything this decision depends on arrives as an argument: no `process.env`, no `stdout`, no
5
+ * config merge. That keeps the ladder unit-testable rung by rung without touching process globals,
6
+ * and keeps the one mutation site ({@link setUseColour}, called from `mergeConfig`) unchanged.
7
+ */
8
+ /**
9
+ * Resolve the effective colour setting from the four-rung precedence ladder, highest wins:
10
+ *
11
+ * 1. `FORCE_COLOR` is set — `"0"` or `"false"` turn colour OFF, ANY other value (including the
12
+ * empty string) turns it ON. This rung outranks everything below it, `NO_COLOR` included.
13
+ * 2. `NO_COLOR` is set and non-empty — colour OFF (the no-color.org convention: the variable's
14
+ * presence is the signal, its value is not, but an empty value does not count as set).
15
+ * 3. `useColour` was set explicitly in config — use it verbatim.
16
+ * 4. Otherwise auto-detect — colour ON when stdout is a terminal, OFF when it is piped or
17
+ * redirected, so captured output stays clean without any configuration.
18
+ */
19
+ export function resolveUseColour(input) {
20
+ // Rung 1 — FORCE_COLOR, the deliberate "I know what I am doing" override. Checked first so a
21
+ // user can force colour through a NO_COLOR inherited from their shell profile or a CI image.
22
+ if (input.forceColor !== undefined) {
23
+ return !(input.forceColor === '0' || input.forceColor === 'false');
24
+ }
25
+ // Rung 2 — NO_COLOR (no-color.org), honoured by chalk, ripgrep, fd and delta.
26
+ if (input.noColor !== undefined && input.noColor !== '') {
27
+ return false;
28
+ }
29
+ // Rung 3 — the user's own config. Only reachable with an explicit value, never the default.
30
+ if (input.explicitUseColour !== undefined) {
31
+ return input.explicitUseColour;
32
+ }
33
+ // Rung 4 — auto-detect.
34
+ return input.stdoutIsTTY;
35
+ }
36
+ //# sourceMappingURL=colour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colour.js","sourceRoot":"","sources":["../../src/config/colour.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,6FAA6F;IAC7F,6FAA6F;IAC7F,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,8EAA8E;IAC9E,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,4FAA4F;IAC5F,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC,iBAAiB,CAAC;IACjC,CAAC;IAED,wBAAwB;IACxB,OAAO,KAAK,CAAC,WAAW,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Default Gaunt Sloth configuration ({@link DEFAULT_CONFIG}). Extracted verbatim from
4
+ * the former `config.ts` god-file; values are unchanged.
5
+ */
6
+ import { StatusLevel } from '#src/core/types.js';
7
+ /**
8
+ * Default config
9
+ */
10
+ export declare const DEFAULT_CONFIG: {
11
+ readonly contentSource: 'file';
12
+ readonly requirementSource: 'file';
13
+ /**
14
+ * Whether to include the current date in the project review instructions or not.
15
+ */
16
+ readonly includeCurrentDateAfterGuidelines: false;
17
+ readonly filesystem: 'none';
18
+ readonly builtInTools: string[];
19
+ readonly debugLog: false;
20
+ readonly consoleLevel: StatusLevel.INFO;
21
+ /**
22
+ * Default source for both requirements and content is GitHub.
23
+ * It needs GitHub CLI (gh).
24
+ *
25
+ * `github` content source uses `gh pr diff NN` internally. {@link src/sources/ghPrDiffSource.ts!}
26
+ *
27
+ *
28
+ * `github` requirement source uses `gh issue view NN` internally
29
+ */
30
+ readonly commands: {
31
+ readonly pr: {
32
+ readonly contentSource: 'github';
33
+ readonly requirementSource: 'github';
34
+ readonly rating: {
35
+ readonly enabled: true;
36
+ readonly passThreshold: 6;
37
+ readonly minRating: 0;
38
+ readonly maxRating: 10;
39
+ readonly errorOnReviewFail: true;
40
+ };
41
+ };
42
+ readonly review: {
43
+ readonly rating: {
44
+ readonly enabled: true;
45
+ readonly passThreshold: 6;
46
+ readonly minRating: 0;
47
+ readonly maxRating: 10;
48
+ readonly errorOnReviewFail: true;
49
+ };
50
+ };
51
+ readonly ask: {
52
+ readonly filesystem: 'read';
53
+ };
54
+ readonly chat: {
55
+ readonly filesystem: 'read';
56
+ };
57
+ readonly code: {
58
+ readonly filesystem: 'all';
59
+ };
60
+ readonly exec: {
61
+ readonly filesystem: 'all';
62
+ };
63
+ readonly api: {
64
+ readonly filesystem: 'read';
65
+ readonly port: 3000;
66
+ readonly cors: {
67
+ readonly allowOrigin: 'http://localhost:3000';
68
+ readonly allowMethods: 'POST, GET, OPTIONS';
69
+ readonly allowHeaders: 'Content-Type, Accept';
70
+ };
71
+ };
72
+ };
73
+ readonly streamOutput: true;
74
+ readonly writeOutputToFile: false;
75
+ readonly writeBinaryOutputsToFile: true;
76
+ readonly useColour: true;
77
+ readonly useMouse: true;
78
+ readonly streamSessionInferenceLog: true;
79
+ readonly canInterruptInferenceWithEsc: true;
80
+ readonly aiignore: {
81
+ readonly enabled: true;
82
+ readonly patterns: undefined;
83
+ };
84
+ };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Default Gaunt Sloth configuration ({@link DEFAULT_CONFIG}). Extracted verbatim from
4
+ * the former `config.ts` god-file; values are unchanged.
5
+ */
6
+ import { StatusLevel } from '#src/core/types.js';
7
+ /**
8
+ * Default config
9
+ */
10
+ export const DEFAULT_CONFIG = {
11
+ contentSource: 'file',
12
+ requirementSource: 'file',
13
+ // GS2-43: prompt segments (backstory/guidelines/system/chat/code/exec/review) are configured
14
+ // via the optional `prompts` object and DEFAULTED AT THE READ SITE (`readPromptSegment` falls
15
+ // back to each segment's default-named file), so `prompts` is intentionally absent here.
16
+ /**
17
+ * Whether to include the current date in the project review instructions or not.
18
+ */
19
+ includeCurrentDateAfterGuidelines: false,
20
+ filesystem: 'none',
21
+ // Enabled built-in tools. `gth_checklist` (the lean agent's planning/todo tool) and `gth_grep`
22
+ // (the permission-light content-search tool, GS2-51) are on by default across commands; a user
23
+ // `builtInTools` setting replaces this set entirely. Both are named to coexist with the deep
24
+ // backend's own `write_todos`/`grep` built-ins. Cast keeps it a mutable `string[]` under the
25
+ // surrounding `as const`.
26
+ builtInTools: ['gth_checklist', 'gth_grep'],
27
+ debugLog: false,
28
+ consoleLevel: StatusLevel.INFO, // Default to INFO level, not debug
29
+ /**
30
+ * Default source for both requirements and content is GitHub.
31
+ * It needs GitHub CLI (gh).
32
+ *
33
+ * `github` content source uses `gh pr diff NN` internally. {@link src/sources/ghPrDiffSource.ts!}
34
+ *
35
+ *
36
+ * `github` requirement source uses `gh issue view NN` internally
37
+ */
38
+ commands: {
39
+ pr: {
40
+ contentSource: 'github',
41
+ requirementSource: 'github',
42
+ rating: {
43
+ enabled: true,
44
+ passThreshold: 6,
45
+ minRating: 0,
46
+ maxRating: 10,
47
+ errorOnReviewFail: true,
48
+ },
49
+ },
50
+ review: {
51
+ rating: {
52
+ enabled: true,
53
+ passThreshold: 6,
54
+ minRating: 0,
55
+ maxRating: 10,
56
+ errorOnReviewFail: true,
57
+ },
58
+ },
59
+ ask: {
60
+ filesystem: 'read',
61
+ },
62
+ chat: {
63
+ filesystem: 'read',
64
+ },
65
+ code: {
66
+ filesystem: 'all',
67
+ },
68
+ exec: {
69
+ filesystem: 'all',
70
+ },
71
+ api: {
72
+ filesystem: 'read',
73
+ port: 3000,
74
+ cors: {
75
+ allowOrigin: 'http://localhost:3000',
76
+ allowMethods: 'POST, GET, OPTIONS',
77
+ allowHeaders: 'Content-Type, Accept',
78
+ },
79
+ },
80
+ },
81
+ streamOutput: true,
82
+ writeOutputToFile: false,
83
+ writeBinaryOutputsToFile: true,
84
+ useColour: true,
85
+ useMouse: true,
86
+ streamSessionInferenceLog: true,
87
+ canInterruptInferenceWithEsc: true,
88
+ aiignore: {
89
+ enabled: true,
90
+ patterns: undefined,
91
+ },
92
+ };
93
+ /**
94
+ * Needed DEFAULT_CONFIG to be plain const to be picked up by typedoc,
95
+ * this cast here is just for typecheck.
96
+ */
97
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
98
+ DEFAULT_CONFIG;
99
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa,EAAE,MAAM;IACrB,iBAAiB,EAAE,MAAM;IACzB,6FAA6F;IAC7F,8FAA8F;IAC9F,yFAAyF;IACzF;;OAEG;IACH,iCAAiC,EAAE,KAAK;IACxC,UAAU,EAAE,MAAM;IAClB,+FAA+F;IAC/F,+FAA+F;IAC/F,6FAA6F;IAC7F,6FAA6F;IAC7F,0BAA0B;IAC1B,YAAY,EAAE,CAAC,eAAe,EAAE,UAAU,CAAa;IACvD,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,WAAW,CAAC,IAAI,EAAE,mCAAmC;IACnE;;;;;;;;OAQG;IACH,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,aAAa,EAAE,QAAQ;YACvB,iBAAiB,EAAE,QAAQ;YAC3B,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,CAAC;gBAChB,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,EAAE;gBACb,iBAAiB,EAAE,IAAI;aACxB;SACF;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,CAAC;gBAChB,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,EAAE;gBACb,iBAAiB,EAAE,IAAI;aACxB;SACF;QACD,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;SACnB;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,MAAM;SACnB;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,KAAK;SAClB;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,KAAK;SAClB;QACD,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,WAAW,EAAE,uBAAuB;gBACpC,YAAY,EAAE,oBAAoB;gBAClC,YAAY,EAAE,sBAAsB;aACrC;SACF;KACF;IACD,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,KAAK;IACxB,wBAAwB,EAAE,IAAI;IAC9B,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,yBAAyB,EAAE,IAAI;IAC/B,4BAA4B,EAAE,IAAI;IAClC,QAAQ,EAAE;QACR,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,SAAS;KACpB;CACO,CAAC;AAEX;;;GAGG;AACH,oEAAoE;AACpE,cAA2B,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * The single interpretation of the `filesystem` config value: **which filesystem tools it
4
+ * registers**.
5
+ *
6
+ * `filesystem` is a union — `'all'`, `'read'`, `'none'`, or a `string[]` of tool names — so any
7
+ * two-value check ("is it `read` or `none`?") is wrong by construction. The toolkit filter in
8
+ * `@gaunt-sloth/agent` (`filterFilesystemTools`) and the system-prompt notes in this package both
9
+ * need the answer, and they must never derive it separately: a prompt that names a tool the filter
10
+ * did not register tells the model to call something that does not exist. {@link
11
+ * isFilesystemToolRegistered} is that one derivation; both call it.
12
+ */
13
+ import { type BuiltInToolAccess } from '#src/config/tool-descriptions.js';
14
+ /** The `filesystem` config union: an allow-list of tool names, or one of the three modes. */
15
+ export type FilesystemToolsConfig = string[] | 'all' | 'read' | 'none';
16
+ /**
17
+ * The filesystem tool that creates a file from supplied content.
18
+ *
19
+ * Exported as a constant because prompt text names it literally: the note telling the model how to
20
+ * write a commit message interpolates this, so the name the model is told and the name the
21
+ * registration check asks about cannot drift apart.
22
+ */
23
+ export declare const WRITE_FILE_TOOL_NAME = "write_file";
24
+ /**
25
+ * Whether a filesystem tool is registered under the given `filesystem` config.
26
+ *
27
+ * `access` is the tool's own read/write class — the runtime `gthFileSystemType` the toolkit stamps
28
+ * on each tool, or {@link BUILT_IN_TOOL_ACCESS} for a caller that has only a name. A tool with no
29
+ * class is never covered by `'read'`; it can still be named explicitly in the array form.
30
+ *
31
+ * The array form is an allow-list of tool NAMES which may also carry the `'read'` and `'all'`
32
+ * keywords, so `['read', 'write_file']` means "every read tool, plus write_file". A value that is
33
+ * neither a known mode nor an array leaves the toolset unrestricted, matching the filter's own
34
+ * fallback, so an absent or malformed value never silently strips the model's tools.
35
+ */
36
+ export declare function isFilesystemToolRegistered(filesystemConfig: FilesystemToolsConfig | undefined, toolName: string | undefined, access: BuiltInToolAccess | undefined): boolean;
37
+ /**
38
+ * Whether {@link WRITE_FILE_TOOL_NAME} is registered under the given `filesystem` config — the
39
+ * question the commit-message guidance asks before it names the tool.
40
+ */
41
+ export declare function isWriteFileToolRegistered(filesystemConfig: FilesystemToolsConfig | undefined): boolean;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * The single interpretation of the `filesystem` config value: **which filesystem tools it
4
+ * registers**.
5
+ *
6
+ * `filesystem` is a union — `'all'`, `'read'`, `'none'`, or a `string[]` of tool names — so any
7
+ * two-value check ("is it `read` or `none`?") is wrong by construction. The toolkit filter in
8
+ * `@gaunt-sloth/agent` (`filterFilesystemTools`) and the system-prompt notes in this package both
9
+ * need the answer, and they must never derive it separately: a prompt that names a tool the filter
10
+ * did not register tells the model to call something that does not exist. {@link
11
+ * isFilesystemToolRegistered} is that one derivation; both call it.
12
+ */
13
+ import { BUILT_IN_TOOL_ACCESS } from '#src/config/tool-descriptions.js';
14
+ /**
15
+ * The filesystem tool that creates a file from supplied content.
16
+ *
17
+ * Exported as a constant because prompt text names it literally: the note telling the model how to
18
+ * write a commit message interpolates this, so the name the model is told and the name the
19
+ * registration check asks about cannot drift apart.
20
+ */
21
+ export const WRITE_FILE_TOOL_NAME = 'write_file';
22
+ /**
23
+ * Whether a filesystem tool is registered under the given `filesystem` config.
24
+ *
25
+ * `access` is the tool's own read/write class — the runtime `gthFileSystemType` the toolkit stamps
26
+ * on each tool, or {@link BUILT_IN_TOOL_ACCESS} for a caller that has only a name. A tool with no
27
+ * class is never covered by `'read'`; it can still be named explicitly in the array form.
28
+ *
29
+ * The array form is an allow-list of tool NAMES which may also carry the `'read'` and `'all'`
30
+ * keywords, so `['read', 'write_file']` means "every read tool, plus write_file". A value that is
31
+ * neither a known mode nor an array leaves the toolset unrestricted, matching the filter's own
32
+ * fallback, so an absent or malformed value never silently strips the model's tools.
33
+ */
34
+ export function isFilesystemToolRegistered(filesystemConfig, toolName, access) {
35
+ if (filesystemConfig === 'none')
36
+ return false;
37
+ if (filesystemConfig === 'all')
38
+ return true;
39
+ if (filesystemConfig === 'read')
40
+ return access === 'read';
41
+ if (!Array.isArray(filesystemConfig))
42
+ return true;
43
+ if (filesystemConfig.includes('all'))
44
+ return true;
45
+ if (filesystemConfig.includes('read') && access === 'read')
46
+ return true;
47
+ return filesystemConfig.some((name) => name !== 'read' && name !== 'all' && name === toolName && !!toolName);
48
+ }
49
+ /**
50
+ * Whether {@link WRITE_FILE_TOOL_NAME} is registered under the given `filesystem` config — the
51
+ * question the commit-message guidance asks before it names the tool.
52
+ */
53
+ export function isWriteFileToolRegistered(filesystemConfig) {
54
+ return isFilesystemToolRegistered(filesystemConfig, WRITE_FILE_TOOL_NAME, BUILT_IN_TOOL_ACCESS[WRITE_FILE_TOOL_NAME]);
55
+ }
56
+ //# sourceMappingURL=filesystem-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem-tools.js","sourceRoot":"","sources":["../../src/config/filesystem-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,oBAAoB,EAA0B,MAAM,kCAAkC,CAAC;AAKhG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B,CACxC,gBAAmD,EACnD,QAA4B,EAC5B,MAAqC;IAErC,IAAI,gBAAgB,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9C,IAAI,gBAAgB,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,gBAAgB,KAAK,MAAM;QAAE,OAAO,MAAM,KAAK,MAAM,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACxE,OAAO,gBAAgB,CAAC,IAAI,CAC1B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAC/E,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,gBAAmD;IAEnD,OAAO,0BAA0B,CAC/B,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,CAAC,oBAAoB,CAAC,CAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Parse a JSONC string (JSON + comments + trailing commas) into a value.
3
+ *
4
+ * On success returns the parsed value. On a structural error (anything `JSON.parse`
5
+ * would also reject, e.g. a missing brace or a dangling property) it throws a `SyntaxError`
6
+ * whose message names the first problem and its 0-based character offset, so the loader's
7
+ * existing "Failed to read config …" diagnostics stay actionable.
8
+ *
9
+ * @param text The file contents.
10
+ * @param sourceLabel Optional human-readable source name, included in the error message.
11
+ */
12
+ export declare function parseJsonc(text: string, sourceLabel?: string): unknown;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * JSONC (JSON-with-comments) parsing for on-disk `.gsloth.config.json` files.
4
+ *
5
+ * The loader historically `JSON.parse`d config files, which rejects the two things
6
+ * hand-edited config files most want: `//` / `/* … *​/` comments and trailing commas.
7
+ * This wraps Microsoft's zero-dependency `jsonc-parser` so a plain `.json` config may
8
+ * carry both, while a genuinely malformed file still fails with a clear, located error
9
+ * (rather than silently returning `undefined`).
10
+ *
11
+ * `jsonc-parser` is used over a hand-rolled comment-stripper because stripping comments
12
+ * with a regex mishandles `//` / `/*` sequences that appear *inside* string values and
13
+ * escaped quotes; the tokenizer here respects string boundaries correctly. It has no
14
+ * transitive dependencies and is the same parser VS Code uses for its settings files.
15
+ */
16
+ import { parse as parseJsoncTree, printParseErrorCode } from 'jsonc-parser';
17
+ /**
18
+ * Parse a JSONC string (JSON + comments + trailing commas) into a value.
19
+ *
20
+ * On success returns the parsed value. On a structural error (anything `JSON.parse`
21
+ * would also reject, e.g. a missing brace or a dangling property) it throws a `SyntaxError`
22
+ * whose message names the first problem and its 0-based character offset, so the loader's
23
+ * existing "Failed to read config …" diagnostics stay actionable.
24
+ *
25
+ * @param text The file contents.
26
+ * @param sourceLabel Optional human-readable source name, included in the error message.
27
+ */
28
+ export function parseJsonc(text, sourceLabel) {
29
+ const errors = [];
30
+ const value = parseJsoncTree(text, errors, {
31
+ allowTrailingComma: true,
32
+ disallowComments: false,
33
+ });
34
+ if (errors.length > 0) {
35
+ const first = errors[0];
36
+ const where = sourceLabel ? ` in ${sourceLabel}` : '';
37
+ throw new SyntaxError(`Invalid JSON/JSONC${where}: ${printParseErrorCode(first.error)} at offset ${first.offset}.`);
38
+ }
39
+ return value;
40
+ }
41
+ //# sourceMappingURL=jsonc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonc.js","sourceRoot":"","sources":["../../src/config/jsonc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,KAAK,IAAI,cAAc,EAAmB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE7F;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,WAAoB;IAC3D,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE;QACzC,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,WAAW,CACnB,qBAAqB,KAAK,KAAK,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,KAAK,CAAC,MAAM,GAAG,CAC7F,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}