@gatanot/orrery 0.1.0

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 (1044) hide show
  1. package/CHANGELOG.md +5621 -0
  2. package/README.md +718 -0
  3. package/dist/bun/cli.d.ts +3 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +11 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/register-bedrock.d.ts +2 -0
  8. package/dist/bun/register-bedrock.d.ts.map +1 -0
  9. package/dist/bun/register-bedrock.js +4 -0
  10. package/dist/bun/register-bedrock.js.map +1 -0
  11. package/dist/bun/restore-sandbox-env.d.ts +17 -0
  12. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  13. package/dist/bun/restore-sandbox-env.js +36 -0
  14. package/dist/bun/restore-sandbox-env.js.map +1 -0
  15. package/dist/bundle/chunks/anthropic-messages-JWX2WP65.js +45 -0
  16. package/dist/bundle/chunks/anthropic.js +75 -0
  17. package/dist/bundle/chunks/azure-openai-responses-5ENVCQ7U.js +2 -0
  18. package/dist/bundle/chunks/bedrock-converse-stream.js +74 -0
  19. package/dist/bundle/chunks/chunk-2KVJKXS2.js +50 -0
  20. package/dist/bundle/chunks/chunk-4L3WN2XY.js +2 -0
  21. package/dist/bundle/chunks/chunk-6CYCI3EJ.js +12 -0
  22. package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
  23. package/dist/bundle/chunks/chunk-AXIIZGTV.js +2 -0
  24. package/dist/bundle/chunks/chunk-DRQDKNXA.js +2 -0
  25. package/dist/bundle/chunks/chunk-EWUFRFA2.js +1549 -0
  26. package/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
  27. package/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
  28. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  29. package/dist/bundle/chunks/chunk-MNAIPA3J.js +2 -0
  30. package/dist/bundle/chunks/chunk-NBBFIJUL.js +11 -0
  31. package/dist/bundle/chunks/chunk-NUHFSC37.js +25 -0
  32. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  33. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  34. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  35. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
  36. package/dist/bundle/chunks/chunk-TRDNDS6A.js +4 -0
  37. package/dist/bundle/chunks/chunk-UAQELI3K.js +2 -0
  38. package/dist/bundle/chunks/chunk-XDUWOHPL.js +6 -0
  39. package/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
  40. package/dist/bundle/chunks/github-copilot.js +2 -0
  41. package/dist/bundle/chunks/google-generative-ai-YMUPJBKR.js +2 -0
  42. package/dist/bundle/chunks/google-vertex-MPWMV4OF.js +2 -0
  43. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +13 -0
  44. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  45. package/dist/bundle/chunks/kimi-coding.js +2 -0
  46. package/dist/bundle/chunks/lib-HGQMNYVT.js +9 -0
  47. package/dist/bundle/chunks/mistral-conversations-Q3AWZJAZ.js +5 -0
  48. package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +3 -0
  49. package/dist/bundle/chunks/openai-codex-responses-GJVBJXLB.js +8 -0
  50. package/dist/bundle/chunks/openai-codex.js +75 -0
  51. package/dist/bundle/chunks/openai-completions-ERMU2SS7.js +7 -0
  52. package/dist/bundle/chunks/openai-responses-BSOJMSEV.js +2 -0
  53. package/dist/bundle/chunks/openrouter-images-N4XVVFSD.js +2 -0
  54. package/dist/bundle/chunks/openrouter.js +75 -0
  55. package/dist/bundle/chunks/pi-messages-TPFH44NP.js +8 -0
  56. package/dist/bundle/chunks/radius.js +75 -0
  57. package/dist/bundle/chunks/src-UK77SYZE.js +4 -0
  58. package/dist/bundle/chunks/xai.js +2 -0
  59. package/dist/bundle/cli.js +3 -0
  60. package/dist/bundle/client.js +2 -0
  61. package/dist/bundle/index.js +2 -0
  62. package/dist/bundle/rpc-entry.js +3 -0
  63. package/dist/cli/args.d.ts +61 -0
  64. package/dist/cli/args.d.ts.map +1 -0
  65. package/dist/cli/args.js +439 -0
  66. package/dist/cli/args.js.map +1 -0
  67. package/dist/cli/auth-check.d.ts +19 -0
  68. package/dist/cli/auth-check.d.ts.map +1 -0
  69. package/dist/cli/auth-check.js +50 -0
  70. package/dist/cli/auth-check.js.map +1 -0
  71. package/dist/cli/auth-command.d.ts +24 -0
  72. package/dist/cli/auth-command.d.ts.map +1 -0
  73. package/dist/cli/auth-command.js +103 -0
  74. package/dist/cli/auth-command.js.map +1 -0
  75. package/dist/cli/config-selector.d.ts +16 -0
  76. package/dist/cli/config-selector.d.ts.map +1 -0
  77. package/dist/cli/config-selector.js +31 -0
  78. package/dist/cli/config-selector.js.map +1 -0
  79. package/dist/cli/credential-print.d.ts +13 -0
  80. package/dist/cli/credential-print.d.ts.map +1 -0
  81. package/dist/cli/credential-print.js +76 -0
  82. package/dist/cli/credential-print.js.map +1 -0
  83. package/dist/cli/experimental/auth.d.ts +16 -0
  84. package/dist/cli/experimental/auth.d.ts.map +1 -0
  85. package/dist/cli/experimental/auth.js +13 -0
  86. package/dist/cli/experimental/auth.js.map +1 -0
  87. package/dist/cli/experimental/cli.d.ts +6 -0
  88. package/dist/cli/experimental/cli.d.ts.map +1 -0
  89. package/dist/cli/experimental/cli.js +5 -0
  90. package/dist/cli/experimental/cli.js.map +1 -0
  91. package/dist/cli/experimental/command-options.d.ts +17 -0
  92. package/dist/cli/experimental/command-options.d.ts.map +1 -0
  93. package/dist/cli/experimental/command-options.js +35 -0
  94. package/dist/cli/experimental/command-options.js.map +1 -0
  95. package/dist/cli/experimental/command.d.ts +63 -0
  96. package/dist/cli/experimental/command.d.ts.map +1 -0
  97. package/dist/cli/experimental/command.js +130 -0
  98. package/dist/cli/experimental/command.js.map +1 -0
  99. package/dist/cli/experimental/commands/client.d.ts +13 -0
  100. package/dist/cli/experimental/commands/client.d.ts.map +1 -0
  101. package/dist/cli/experimental/commands/client.js +25 -0
  102. package/dist/cli/experimental/commands/client.js.map +1 -0
  103. package/dist/cli/experimental/commands/pi.d.ts +15 -0
  104. package/dist/cli/experimental/commands/pi.d.ts.map +1 -0
  105. package/dist/cli/experimental/commands/pi.js +28 -0
  106. package/dist/cli/experimental/commands/pi.js.map +1 -0
  107. package/dist/cli/experimental/commands/server.d.ts +13 -0
  108. package/dist/cli/experimental/commands/server.d.ts.map +1 -0
  109. package/dist/cli/experimental/commands/server.js +25 -0
  110. package/dist/cli/experimental/commands/server.js.map +1 -0
  111. package/dist/cli/experimental/transport-address.d.ts +10 -0
  112. package/dist/cli/experimental/transport-address.d.ts.map +1 -0
  113. package/dist/cli/experimental/transport-address.js +38 -0
  114. package/dist/cli/experimental/transport-address.js.map +1 -0
  115. package/dist/cli/file-processor.d.ts +15 -0
  116. package/dist/cli/file-processor.d.ts.map +1 -0
  117. package/dist/cli/file-processor.js +71 -0
  118. package/dist/cli/file-processor.js.map +1 -0
  119. package/dist/cli/initial-message.d.ts +18 -0
  120. package/dist/cli/initial-message.d.ts.map +1 -0
  121. package/dist/cli/initial-message.js +22 -0
  122. package/dist/cli/initial-message.js.map +1 -0
  123. package/dist/cli/list-models.d.ts +9 -0
  124. package/dist/cli/list-models.d.ts.map +1 -0
  125. package/dist/cli/list-models.js +98 -0
  126. package/dist/cli/list-models.js.map +1 -0
  127. package/dist/cli/project-trust.d.ts +10 -0
  128. package/dist/cli/project-trust.d.ts.map +1 -0
  129. package/dist/cli/project-trust.js +48 -0
  130. package/dist/cli/project-trust.js.map +1 -0
  131. package/dist/cli/session-picker.d.ts +10 -0
  132. package/dist/cli/session-picker.d.ts.map +1 -0
  133. package/dist/cli/session-picker.js +36 -0
  134. package/dist/cli/session-picker.js.map +1 -0
  135. package/dist/cli/startup-ui.d.ts +20 -0
  136. package/dist/cli/startup-ui.d.ts.map +1 -0
  137. package/dist/cli/startup-ui.js +185 -0
  138. package/dist/cli/startup-ui.js.map +1 -0
  139. package/dist/cli.d.ts +3 -0
  140. package/dist/cli.d.ts.map +1 -0
  141. package/dist/cli.js +19 -0
  142. package/dist/cli.js.map +1 -0
  143. package/dist/client/index.d.ts +3 -0
  144. package/dist/client/index.d.ts.map +1 -0
  145. package/dist/client/index.js +3 -0
  146. package/dist/client/index.js.map +1 -0
  147. package/dist/client/remote-session.d.ts +53 -0
  148. package/dist/client/remote-session.d.ts.map +1 -0
  149. package/dist/client/remote-session.js +340 -0
  150. package/dist/client/remote-session.js.map +1 -0
  151. package/dist/client/transcript.d.ts +12 -0
  152. package/dist/client/transcript.d.ts.map +1 -0
  153. package/dist/client/transcript.js +98 -0
  154. package/dist/client/transcript.js.map +1 -0
  155. package/dist/config.d.ts +97 -0
  156. package/dist/config.d.ts.map +1 -0
  157. package/dist/config.js +463 -0
  158. package/dist/config.js.map +1 -0
  159. package/dist/core/agent-session-runtime.d.ts +119 -0
  160. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  161. package/dist/core/agent-session-runtime.js +309 -0
  162. package/dist/core/agent-session-runtime.js.map +1 -0
  163. package/dist/core/agent-session-services.d.ts +86 -0
  164. package/dist/core/agent-session-services.d.ts.map +1 -0
  165. package/dist/core/agent-session-services.js +134 -0
  166. package/dist/core/agent-session-services.js.map +1 -0
  167. package/dist/core/agent-session.d.ts +679 -0
  168. package/dist/core/agent-session.d.ts.map +1 -0
  169. package/dist/core/agent-session.js +2823 -0
  170. package/dist/core/agent-session.js.map +1 -0
  171. package/dist/core/auth-guidance.d.ts +5 -0
  172. package/dist/core/auth-guidance.d.ts.map +1 -0
  173. package/dist/core/auth-guidance.js +21 -0
  174. package/dist/core/auth-guidance.js.map +1 -0
  175. package/dist/core/auth-storage.d.ts +72 -0
  176. package/dist/core/auth-storage.d.ts.map +1 -0
  177. package/dist/core/auth-storage.js +426 -0
  178. package/dist/core/auth-storage.js.map +1 -0
  179. package/dist/core/bash-executor.d.ts +32 -0
  180. package/dist/core/bash-executor.d.ts.map +1 -0
  181. package/dist/core/bash-executor.js +111 -0
  182. package/dist/core/bash-executor.js.map +1 -0
  183. package/dist/core/cache-stats.d.ts +49 -0
  184. package/dist/core/cache-stats.d.ts.map +1 -0
  185. package/dist/core/cache-stats.js +101 -0
  186. package/dist/core/cache-stats.js.map +1 -0
  187. package/dist/core/compaction/branch-summarization.d.ts +98 -0
  188. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  189. package/dist/core/compaction/branch-summarization.js +250 -0
  190. package/dist/core/compaction/branch-summarization.js.map +1 -0
  191. package/dist/core/compaction/compaction.d.ts +143 -0
  192. package/dist/core/compaction/compaction.d.ts.map +1 -0
  193. package/dist/core/compaction/compaction.js +668 -0
  194. package/dist/core/compaction/compaction.js.map +1 -0
  195. package/dist/core/compaction/index.d.ts +7 -0
  196. package/dist/core/compaction/index.d.ts.map +1 -0
  197. package/dist/core/compaction/index.js +7 -0
  198. package/dist/core/compaction/index.js.map +1 -0
  199. package/dist/core/compaction/utils.d.ts +38 -0
  200. package/dist/core/compaction/utils.d.ts.map +1 -0
  201. package/dist/core/compaction/utils.js +142 -0
  202. package/dist/core/compaction/utils.js.map +1 -0
  203. package/dist/core/defaults.d.ts +4 -0
  204. package/dist/core/defaults.d.ts.map +1 -0
  205. package/dist/core/defaults.js +11 -0
  206. package/dist/core/defaults.js.map +1 -0
  207. package/dist/core/diagnostics.d.ts +15 -0
  208. package/dist/core/diagnostics.d.ts.map +1 -0
  209. package/dist/core/diagnostics.js +2 -0
  210. package/dist/core/diagnostics.js.map +1 -0
  211. package/dist/core/event-bus.d.ts +9 -0
  212. package/dist/core/event-bus.d.ts.map +1 -0
  213. package/dist/core/event-bus.js +25 -0
  214. package/dist/core/event-bus.js.map +1 -0
  215. package/dist/core/exec.d.ts +29 -0
  216. package/dist/core/exec.d.ts.map +1 -0
  217. package/dist/core/exec.js +75 -0
  218. package/dist/core/exec.js.map +1 -0
  219. package/dist/core/experimental.d.ts +6 -0
  220. package/dist/core/experimental.d.ts.map +1 -0
  221. package/dist/core/experimental.js +8 -0
  222. package/dist/core/experimental.js.map +1 -0
  223. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  224. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  225. package/dist/core/export-html/ansi-to-html.js +249 -0
  226. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  227. package/dist/core/export-html/index.d.ts +37 -0
  228. package/dist/core/export-html/index.d.ts.map +1 -0
  229. package/dist/core/export-html/index.js +226 -0
  230. package/dist/core/export-html/index.js.map +1 -0
  231. package/dist/core/export-html/template.css +1066 -0
  232. package/dist/core/export-html/template.html +55 -0
  233. package/dist/core/export-html/template.js +1864 -0
  234. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  235. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  236. package/dist/core/export-html/tool-renderer.js +108 -0
  237. package/dist/core/export-html/tool-renderer.js.map +1 -0
  238. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  239. package/dist/core/export-html/vendor/marked.min.js +78 -0
  240. package/dist/core/extensions/index.d.ts +12 -0
  241. package/dist/core/extensions/index.d.ts.map +1 -0
  242. package/dist/core/extensions/index.js +9 -0
  243. package/dist/core/extensions/index.js.map +1 -0
  244. package/dist/core/extensions/loader.d.ts +23 -0
  245. package/dist/core/extensions/loader.d.ts.map +1 -0
  246. package/dist/core/extensions/loader.js +648 -0
  247. package/dist/core/extensions/loader.js.map +1 -0
  248. package/dist/core/extensions/runner.d.ts +178 -0
  249. package/dist/core/extensions/runner.d.ts.map +1 -0
  250. package/dist/core/extensions/runner.js +1011 -0
  251. package/dist/core/extensions/runner.js.map +1 -0
  252. package/dist/core/extensions/types.d.ts +1345 -0
  253. package/dist/core/extensions/types.d.ts.map +1 -0
  254. package/dist/core/extensions/types.js +48 -0
  255. package/dist/core/extensions/types.js.map +1 -0
  256. package/dist/core/extensions/wrapper.d.ts +20 -0
  257. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  258. package/dist/core/extensions/wrapper.js +41 -0
  259. package/dist/core/extensions/wrapper.js.map +1 -0
  260. package/dist/core/footer-data-provider.d.ts +64 -0
  261. package/dist/core/footer-data-provider.d.ts.map +1 -0
  262. package/dist/core/footer-data-provider.js +338 -0
  263. package/dist/core/footer-data-provider.js.map +1 -0
  264. package/dist/core/http-dispatcher.d.ts +22 -0
  265. package/dist/core/http-dispatcher.d.ts.map +1 -0
  266. package/dist/core/http-dispatcher.js +96 -0
  267. package/dist/core/http-dispatcher.js.map +1 -0
  268. package/dist/core/index.d.ts +13 -0
  269. package/dist/core/index.d.ts.map +1 -0
  270. package/dist/core/index.js +13 -0
  271. package/dist/core/index.js.map +1 -0
  272. package/dist/core/keybindings.d.ts +423 -0
  273. package/dist/core/keybindings.d.ts.map +1 -0
  274. package/dist/core/keybindings.js +317 -0
  275. package/dist/core/keybindings.js.map +1 -0
  276. package/dist/core/messages.d.ts +77 -0
  277. package/dist/core/messages.d.ts.map +1 -0
  278. package/dist/core/messages.js +123 -0
  279. package/dist/core/messages.js.map +1 -0
  280. package/dist/core/model-config.d.ts +576 -0
  281. package/dist/core/model-config.d.ts.map +1 -0
  282. package/dist/core/model-config.js +256 -0
  283. package/dist/core/model-config.js.map +1 -0
  284. package/dist/core/model-registry.d.ts +45 -0
  285. package/dist/core/model-registry.d.ts.map +1 -0
  286. package/dist/core/model-registry.js +107 -0
  287. package/dist/core/model-registry.js.map +1 -0
  288. package/dist/core/model-resolver.d.ts +124 -0
  289. package/dist/core/model-resolver.d.ts.map +1 -0
  290. package/dist/core/model-resolver.js +589 -0
  291. package/dist/core/model-resolver.js.map +1 -0
  292. package/dist/core/model-runtime.d.ts +100 -0
  293. package/dist/core/model-runtime.d.ts.map +1 -0
  294. package/dist/core/model-runtime.js +599 -0
  295. package/dist/core/model-runtime.js.map +1 -0
  296. package/dist/core/models-store.d.ts +22 -0
  297. package/dist/core/models-store.d.ts.map +1 -0
  298. package/dist/core/models-store.js +115 -0
  299. package/dist/core/models-store.js.map +1 -0
  300. package/dist/core/output-guard.d.ts +7 -0
  301. package/dist/core/output-guard.d.ts.map +1 -0
  302. package/dist/core/output-guard.js +89 -0
  303. package/dist/core/output-guard.js.map +1 -0
  304. package/dist/core/package-manager.d.ts +213 -0
  305. package/dist/core/package-manager.d.ts.map +1 -0
  306. package/dist/core/package-manager.js +2177 -0
  307. package/dist/core/package-manager.js.map +1 -0
  308. package/dist/core/pi-manifest.d.ts +8 -0
  309. package/dist/core/pi-manifest.d.ts.map +1 -0
  310. package/dist/core/pi-manifest.js +26 -0
  311. package/dist/core/pi-manifest.js.map +1 -0
  312. package/dist/core/project-trust.d.ts +15 -0
  313. package/dist/core/project-trust.d.ts.map +1 -0
  314. package/dist/core/project-trust.js +59 -0
  315. package/dist/core/project-trust.js.map +1 -0
  316. package/dist/core/prompt-templates.d.ts +54 -0
  317. package/dist/core/prompt-templates.d.ts.map +1 -0
  318. package/dist/core/prompt-templates.js +236 -0
  319. package/dist/core/prompt-templates.js.map +1 -0
  320. package/dist/core/provider-attribution.d.ts +4 -0
  321. package/dist/core/provider-attribution.d.ts.map +1 -0
  322. package/dist/core/provider-attribution.js +72 -0
  323. package/dist/core/provider-attribution.js.map +1 -0
  324. package/dist/core/provider-composer.d.ts +58 -0
  325. package/dist/core/provider-composer.d.ts.map +1 -0
  326. package/dist/core/provider-composer.js +396 -0
  327. package/dist/core/provider-composer.js.map +1 -0
  328. package/dist/core/radius.d.ts +2 -0
  329. package/dist/core/radius.d.ts.map +1 -0
  330. package/dist/core/radius.js +2 -0
  331. package/dist/core/radius.js.map +1 -0
  332. package/dist/core/remote-catalog-provider.d.ts +5 -0
  333. package/dist/core/remote-catalog-provider.d.ts.map +1 -0
  334. package/dist/core/remote-catalog-provider.js +122 -0
  335. package/dist/core/remote-catalog-provider.js.map +1 -0
  336. package/dist/core/resolve-config-value.d.ts +30 -0
  337. package/dist/core/resolve-config-value.d.ts.map +1 -0
  338. package/dist/core/resolve-config-value.js +247 -0
  339. package/dist/core/resolve-config-value.js.map +1 -0
  340. package/dist/core/resource-loader.d.ts +221 -0
  341. package/dist/core/resource-loader.d.ts.map +1 -0
  342. package/dist/core/resource-loader.js +875 -0
  343. package/dist/core/resource-loader.js.map +1 -0
  344. package/dist/core/runtime-credentials.d.ts +15 -0
  345. package/dist/core/runtime-credentials.d.ts.map +1 -0
  346. package/dist/core/runtime-credentials.js +39 -0
  347. package/dist/core/runtime-credentials.js.map +1 -0
  348. package/dist/core/sdk.d.ts +108 -0
  349. package/dist/core/sdk.d.ts.map +1 -0
  350. package/dist/core/sdk.js +275 -0
  351. package/dist/core/sdk.js.map +1 -0
  352. package/dist/core/session-cwd.d.ts +19 -0
  353. package/dist/core/session-cwd.d.ts.map +1 -0
  354. package/dist/core/session-cwd.js +38 -0
  355. package/dist/core/session-cwd.js.map +1 -0
  356. package/dist/core/session-export.d.ts +4 -0
  357. package/dist/core/session-export.d.ts.map +1 -0
  358. package/dist/core/session-export.js +32 -0
  359. package/dist/core/session-export.js.map +1 -0
  360. package/dist/core/session-manager.d.ts +356 -0
  361. package/dist/core/session-manager.d.ts.map +1 -0
  362. package/dist/core/session-manager.js +1343 -0
  363. package/dist/core/session-manager.js.map +1 -0
  364. package/dist/core/settings-diagnostics.d.ts +9 -0
  365. package/dist/core/settings-diagnostics.d.ts.map +1 -0
  366. package/dist/core/settings-diagnostics.js +21 -0
  367. package/dist/core/settings-diagnostics.js.map +1 -0
  368. package/dist/core/settings-manager.d.ts +331 -0
  369. package/dist/core/settings-manager.d.ts.map +1 -0
  370. package/dist/core/settings-manager.js +997 -0
  371. package/dist/core/settings-manager.js.map +1 -0
  372. package/dist/core/skills.d.ts +60 -0
  373. package/dist/core/skills.d.ts.map +1 -0
  374. package/dist/core/skills.js +405 -0
  375. package/dist/core/skills.js.map +1 -0
  376. package/dist/core/slash-commands.d.ts +15 -0
  377. package/dist/core/slash-commands.d.ts.map +1 -0
  378. package/dist/core/slash-commands.js +27 -0
  379. package/dist/core/slash-commands.js.map +1 -0
  380. package/dist/core/source-info.d.ts +18 -0
  381. package/dist/core/source-info.d.ts.map +1 -0
  382. package/dist/core/source-info.js +19 -0
  383. package/dist/core/source-info.js.map +1 -0
  384. package/dist/core/system-prompt.d.ts +28 -0
  385. package/dist/core/system-prompt.d.ts.map +1 -0
  386. package/dist/core/system-prompt.js +119 -0
  387. package/dist/core/system-prompt.js.map +1 -0
  388. package/dist/core/telemetry.d.ts +3 -0
  389. package/dist/core/telemetry.d.ts.map +1 -0
  390. package/dist/core/telemetry.js +9 -0
  391. package/dist/core/telemetry.js.map +1 -0
  392. package/dist/core/timings.d.ts +10 -0
  393. package/dist/core/timings.d.ts.map +1 -0
  394. package/dist/core/timings.js +41 -0
  395. package/dist/core/timings.js.map +1 -0
  396. package/dist/core/tools/bash.d.ts +87 -0
  397. package/dist/core/tools/bash.d.ts.map +1 -0
  398. package/dist/core/tools/bash.js +410 -0
  399. package/dist/core/tools/bash.js.map +1 -0
  400. package/dist/core/tools/edit-diff.d.ts +101 -0
  401. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  402. package/dist/core/tools/edit-diff.js +421 -0
  403. package/dist/core/tools/edit-diff.js.map +1 -0
  404. package/dist/core/tools/edit.d.ts +55 -0
  405. package/dist/core/tools/edit.d.ts.map +1 -0
  406. package/dist/core/tools/edit.js +306 -0
  407. package/dist/core/tools/edit.js.map +1 -0
  408. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  409. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  410. package/dist/core/tools/file-mutation-queue.js +52 -0
  411. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  412. package/dist/core/tools/find.d.ts +42 -0
  413. package/dist/core/tools/find.d.ts.map +1 -0
  414. package/dist/core/tools/find.js +302 -0
  415. package/dist/core/tools/find.js.map +1 -0
  416. package/dist/core/tools/grep.d.ts +41 -0
  417. package/dist/core/tools/grep.d.ts.map +1 -0
  418. package/dist/core/tools/grep.js +308 -0
  419. package/dist/core/tools/grep.js.map +1 -0
  420. package/dist/core/tools/index.d.ts +43 -0
  421. package/dist/core/tools/index.d.ts.map +1 -0
  422. package/dist/core/tools/index.js +129 -0
  423. package/dist/core/tools/index.js.map +1 -0
  424. package/dist/core/tools/ls.d.ts +41 -0
  425. package/dist/core/tools/ls.d.ts.map +1 -0
  426. package/dist/core/tools/ls.js +171 -0
  427. package/dist/core/tools/ls.js.map +1 -0
  428. package/dist/core/tools/output-accumulator.d.ts +52 -0
  429. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  430. package/dist/core/tools/output-accumulator.js +184 -0
  431. package/dist/core/tools/output-accumulator.js.map +1 -0
  432. package/dist/core/tools/path-utils.d.ts +10 -0
  433. package/dist/core/tools/path-utils.d.ts.map +1 -0
  434. package/dist/core/tools/path-utils.js +99 -0
  435. package/dist/core/tools/path-utils.js.map +1 -0
  436. package/dist/core/tools/powershell.d.ts +16 -0
  437. package/dist/core/tools/powershell.d.ts.map +1 -0
  438. package/dist/core/tools/powershell.js +39 -0
  439. package/dist/core/tools/powershell.js.map +1 -0
  440. package/dist/core/tools/read.d.ts +39 -0
  441. package/dist/core/tools/read.d.ts.map +1 -0
  442. package/dist/core/tools/read.js +282 -0
  443. package/dist/core/tools/read.js.map +1 -0
  444. package/dist/core/tools/render-utils.d.ts +24 -0
  445. package/dist/core/tools/render-utils.d.ts.map +1 -0
  446. package/dist/core/tools/render-utils.js +65 -0
  447. package/dist/core/tools/render-utils.js.map +1 -0
  448. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  449. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  450. package/dist/core/tools/tool-definition-wrapper.js +36 -0
  451. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  452. package/dist/core/tools/truncate.d.ts +70 -0
  453. package/dist/core/tools/truncate.d.ts.map +1 -0
  454. package/dist/core/tools/truncate.js +215 -0
  455. package/dist/core/tools/truncate.js.map +1 -0
  456. package/dist/core/tools/write.d.ts +30 -0
  457. package/dist/core/tools/write.d.ts.map +1 -0
  458. package/dist/core/tools/write.js +203 -0
  459. package/dist/core/tools/write.js.map +1 -0
  460. package/dist/core/trust-manager.d.ts +36 -0
  461. package/dist/core/trust-manager.d.ts.map +1 -0
  462. package/dist/core/trust-manager.js +203 -0
  463. package/dist/core/trust-manager.js.map +1 -0
  464. package/dist/core/usage-totals.d.ts +19 -0
  465. package/dist/core/usage-totals.d.ts.map +1 -0
  466. package/dist/core/usage-totals.js +52 -0
  467. package/dist/core/usage-totals.js.map +1 -0
  468. package/dist/extensions/index.d.ts +3 -0
  469. package/dist/extensions/index.d.ts.map +1 -0
  470. package/dist/extensions/index.js +3 -0
  471. package/dist/extensions/index.js.map +1 -0
  472. package/dist/extensions/llama/client.d.ts +67 -0
  473. package/dist/extensions/llama/client.d.ts.map +1 -0
  474. package/dist/extensions/llama/client.js +309 -0
  475. package/dist/extensions/llama/client.js.map +1 -0
  476. package/dist/extensions/llama/huggingface.d.ts +23 -0
  477. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  478. package/dist/extensions/llama/huggingface.js +141 -0
  479. package/dist/extensions/llama/huggingface.js.map +1 -0
  480. package/dist/extensions/llama/index.d.ts +3 -0
  481. package/dist/extensions/llama/index.d.ts.map +1 -0
  482. package/dist/extensions/llama/index.js +219 -0
  483. package/dist/extensions/llama/index.js.map +1 -0
  484. package/dist/extensions/llama/provider.d.ts +12 -0
  485. package/dist/extensions/llama/provider.d.ts.map +1 -0
  486. package/dist/extensions/llama/provider.js +146 -0
  487. package/dist/extensions/llama/provider.js.map +1 -0
  488. package/dist/extensions/llama/ui.d.ts +42 -0
  489. package/dist/extensions/llama/ui.d.ts.map +1 -0
  490. package/dist/extensions/llama/ui.js +416 -0
  491. package/dist/extensions/llama/ui.js.map +1 -0
  492. package/dist/index.d.ts +36 -0
  493. package/dist/index.d.ts.map +1 -0
  494. package/dist/index.js +48 -0
  495. package/dist/index.js.map +1 -0
  496. package/dist/main.d.ts +16 -0
  497. package/dist/main.d.ts.map +1 -0
  498. package/dist/main.js +801 -0
  499. package/dist/main.js.map +1 -0
  500. package/dist/migrations.d.ts +33 -0
  501. package/dist/migrations.d.ts.map +1 -0
  502. package/dist/migrations.js +282 -0
  503. package/dist/migrations.js.map +1 -0
  504. package/dist/modes/index.d.ts +10 -0
  505. package/dist/modes/index.d.ts.map +1 -0
  506. package/dist/modes/index.js +8 -0
  507. package/dist/modes/index.js.map +1 -0
  508. package/dist/modes/interactive/assets/clankolas.png +0 -0
  509. package/dist/modes/interactive/components/armin.d.ts +34 -0
  510. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  511. package/dist/modes/interactive/components/armin.js +333 -0
  512. package/dist/modes/interactive/components/armin.js.map +1 -0
  513. package/dist/modes/interactive/components/assistant-message.d.ts +25 -0
  514. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  515. package/dist/modes/interactive/components/assistant-message.js +150 -0
  516. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  517. package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
  518. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  519. package/dist/modes/interactive/components/bash-execution.js +175 -0
  520. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  521. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  522. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  523. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  524. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  525. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  526. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  527. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  528. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  529. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  530. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  531. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  532. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  533. package/dist/modes/interactive/components/config-selector.d.ts +102 -0
  534. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  535. package/dist/modes/interactive/components/config-selector.js +761 -0
  536. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  537. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  538. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  539. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  540. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  541. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  542. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  543. package/dist/modes/interactive/components/custom-editor.js +77 -0
  544. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  545. package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
  546. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  547. package/dist/modes/interactive/components/custom-entry.js +52 -0
  548. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  549. package/dist/modes/interactive/components/custom-message.d.ts +22 -0
  550. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  551. package/dist/modes/interactive/components/custom-message.js +87 -0
  552. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  553. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  554. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  555. package/dist/modes/interactive/components/daxnuts.js +140 -0
  556. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  557. package/dist/modes/interactive/components/diff.d.ts +12 -0
  558. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  559. package/dist/modes/interactive/components/diff.js +133 -0
  560. package/dist/modes/interactive/components/diff.js.map +1 -0
  561. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  562. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  563. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  564. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  565. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  566. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  567. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  568. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  569. package/dist/modes/interactive/components/extension-editor.d.ts +21 -0
  570. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  571. package/dist/modes/interactive/components/extension-editor.js +98 -0
  572. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  573. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  574. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  575. package/dist/modes/interactive/components/extension-input.js +61 -0
  576. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  577. package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
  578. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  579. package/dist/modes/interactive/components/extension-selector.js +83 -0
  580. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  581. package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
  582. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
  583. package/dist/modes/interactive/components/first-time-setup.js +103 -0
  584. package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
  585. package/dist/modes/interactive/components/footer.d.ts +32 -0
  586. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  587. package/dist/modes/interactive/components/footer.js +222 -0
  588. package/dist/modes/interactive/components/footer.js.map +1 -0
  589. package/dist/modes/interactive/components/index.d.ts +34 -0
  590. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  591. package/dist/modes/interactive/components/index.js +35 -0
  592. package/dist/modes/interactive/components/index.js.map +1 -0
  593. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  594. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  595. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  596. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  597. package/dist/modes/interactive/components/login-dialog.d.ts +52 -0
  598. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  599. package/dist/modes/interactive/components/login-dialog.js +188 -0
  600. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  601. package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
  602. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  603. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  604. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  605. package/dist/modes/interactive/components/mermaid.d.ts +11 -0
  606. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
  607. package/dist/modes/interactive/components/mermaid.js +75 -0
  608. package/dist/modes/interactive/components/mermaid.js.map +1 -0
  609. package/dist/modes/interactive/components/model-selector.d.ts +60 -0
  610. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  611. package/dist/modes/interactive/components/model-selector.js +370 -0
  612. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  613. package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
  614. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  615. package/dist/modes/interactive/components/oauth-selector.js +163 -0
  616. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  617. package/dist/modes/interactive/components/scoped-models-selector.d.ts +46 -0
  618. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  619. package/dist/modes/interactive/components/scoped-models-selector.js +328 -0
  620. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  621. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  622. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  623. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  624. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  625. package/dist/modes/interactive/components/session-selector.d.ts +95 -0
  626. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  627. package/dist/modes/interactive/components/session-selector.js +867 -0
  628. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  629. package/dist/modes/interactive/components/settings-selector.d.ts +92 -0
  630. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  631. package/dist/modes/interactive/components/settings-selector.js +705 -0
  632. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  633. package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
  634. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
  635. package/dist/modes/interactive/components/settings-submenu.js +165 -0
  636. package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
  637. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  638. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  639. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  640. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  641. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  642. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  643. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  644. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  645. package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
  646. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
  647. package/dist/modes/interactive/components/status-indicator.js +60 -0
  648. package/dist/modes/interactive/components/status-indicator.js.map +1 -0
  649. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  650. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  651. package/dist/modes/interactive/components/theme-selector.js +50 -0
  652. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  653. package/dist/modes/interactive/components/thinking-selector.d.ts +23 -0
  654. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  655. package/dist/modes/interactive/components/thinking-selector.js +109 -0
  656. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  657. package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
  658. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  659. package/dist/modes/interactive/components/tool-execution.js +326 -0
  660. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  661. package/dist/modes/interactive/components/tree-selector.d.ts +94 -0
  662. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  663. package/dist/modes/interactive/components/tree-selector.js +1245 -0
  664. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  665. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  666. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  667. package/dist/modes/interactive/components/trust-selector.js +91 -0
  668. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  669. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  670. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  671. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  672. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  673. package/dist/modes/interactive/components/user-message.d.ts +16 -0
  674. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  675. package/dist/modes/interactive/components/user-message.js +49 -0
  676. package/dist/modes/interactive/components/user-message.js.map +1 -0
  677. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  678. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  679. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  680. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  681. package/dist/modes/interactive/external-editor.d.ts +12 -0
  682. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  683. package/dist/modes/interactive/external-editor.js +38 -0
  684. package/dist/modes/interactive/external-editor.js.map +1 -0
  685. package/dist/modes/interactive/interactive-mode.d.ts +450 -0
  686. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  687. package/dist/modes/interactive/interactive-mode.js +5544 -0
  688. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  689. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  690. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  691. package/dist/modes/interactive/model-catalog-refresh.js +34 -0
  692. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  693. package/dist/modes/interactive/model-search.d.ts +12 -0
  694. package/dist/modes/interactive/model-search.d.ts.map +1 -0
  695. package/dist/modes/interactive/model-search.js +15 -0
  696. package/dist/modes/interactive/model-search.js.map +1 -0
  697. package/dist/modes/interactive/session-share.d.ts +16 -0
  698. package/dist/modes/interactive/session-share.d.ts.map +1 -0
  699. package/dist/modes/interactive/session-share.js +188 -0
  700. package/dist/modes/interactive/session-share.js.map +1 -0
  701. package/dist/modes/interactive/theme/dark.json +90 -0
  702. package/dist/modes/interactive/theme/light.json +89 -0
  703. package/dist/modes/interactive/theme/theme-controller.d.ts +40 -0
  704. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  705. package/dist/modes/interactive/theme/theme-controller.js +125 -0
  706. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  707. package/dist/modes/interactive/theme/theme-schema.json +352 -0
  708. package/dist/modes/interactive/theme/theme.d.ts +122 -0
  709. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  710. package/dist/modes/interactive/theme/theme.js +1092 -0
  711. package/dist/modes/interactive/theme/theme.js.map +1 -0
  712. package/dist/modes/json-event.d.ts +34 -0
  713. package/dist/modes/json-event.d.ts.map +1 -0
  714. package/dist/modes/json-event.js +29 -0
  715. package/dist/modes/json-event.js.map +1 -0
  716. package/dist/modes/print-mode.d.ts +28 -0
  717. package/dist/modes/print-mode.d.ts.map +1 -0
  718. package/dist/modes/print-mode.js +142 -0
  719. package/dist/modes/print-mode.js.map +1 -0
  720. package/dist/modes/rpc/jsonl.d.ts +17 -0
  721. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  722. package/dist/modes/rpc/jsonl.js +49 -0
  723. package/dist/modes/rpc/jsonl.js.map +1 -0
  724. package/dist/modes/rpc/rpc-client.d.ts +254 -0
  725. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  726. package/dist/modes/rpc/rpc-client.js +495 -0
  727. package/dist/modes/rpc/rpc-client.js.map +1 -0
  728. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  729. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  730. package/dist/modes/rpc/rpc-mode.js +657 -0
  731. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  732. package/dist/modes/rpc/rpc-types.d.ts +469 -0
  733. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  734. package/dist/modes/rpc/rpc-types.js +8 -0
  735. package/dist/modes/rpc/rpc-types.js.map +1 -0
  736. package/dist/package-manager-cli.d.ts +9 -0
  737. package/dist/package-manager-cli.d.ts.map +1 -0
  738. package/dist/package-manager-cli.js +961 -0
  739. package/dist/package-manager-cli.js.map +1 -0
  740. package/dist/rpc-entry.d.ts +3 -0
  741. package/dist/rpc-entry.d.ts.map +1 -0
  742. package/dist/rpc-entry.js +11 -0
  743. package/dist/rpc-entry.js.map +1 -0
  744. package/dist/server/create-harness.d.ts +26 -0
  745. package/dist/server/create-harness.d.ts.map +1 -0
  746. package/dist/server/create-harness.js +106 -0
  747. package/dist/server/create-harness.js.map +1 -0
  748. package/dist/utils/abort.d.ts +5 -0
  749. package/dist/utils/abort.d.ts.map +1 -0
  750. package/dist/utils/abort.js +48 -0
  751. package/dist/utils/abort.js.map +1 -0
  752. package/dist/utils/ansi.d.ts +2 -0
  753. package/dist/utils/ansi.d.ts.map +1 -0
  754. package/dist/utils/ansi.js +52 -0
  755. package/dist/utils/ansi.js.map +1 -0
  756. package/dist/utils/changelog.d.ts +22 -0
  757. package/dist/utils/changelog.d.ts.map +1 -0
  758. package/dist/utils/changelog.js +165 -0
  759. package/dist/utils/changelog.js.map +1 -0
  760. package/dist/utils/child-process.d.ts +18 -0
  761. package/dist/utils/child-process.d.ts.map +1 -0
  762. package/dist/utils/child-process.js +106 -0
  763. package/dist/utils/child-process.js.map +1 -0
  764. package/dist/utils/clipboard-image.d.ts +11 -0
  765. package/dist/utils/clipboard-image.d.ts.map +1 -0
  766. package/dist/utils/clipboard-image.js +245 -0
  767. package/dist/utils/clipboard-image.js.map +1 -0
  768. package/dist/utils/clipboard-native.d.ts +11 -0
  769. package/dist/utils/clipboard-native.d.ts.map +1 -0
  770. package/dist/utils/clipboard-native.js +20 -0
  771. package/dist/utils/clipboard-native.js.map +1 -0
  772. package/dist/utils/clipboard.d.ts +4 -0
  773. package/dist/utils/clipboard.d.ts.map +1 -0
  774. package/dist/utils/clipboard.js +161 -0
  775. package/dist/utils/clipboard.js.map +1 -0
  776. package/dist/utils/deprecation.d.ts +4 -0
  777. package/dist/utils/deprecation.d.ts.map +1 -0
  778. package/dist/utils/deprecation.js +13 -0
  779. package/dist/utils/deprecation.js.map +1 -0
  780. package/dist/utils/exif-orientation.d.ts +5 -0
  781. package/dist/utils/exif-orientation.d.ts.map +1 -0
  782. package/dist/utils/exif-orientation.js +158 -0
  783. package/dist/utils/exif-orientation.js.map +1 -0
  784. package/dist/utils/frontmatter.d.ts +8 -0
  785. package/dist/utils/frontmatter.d.ts.map +1 -0
  786. package/dist/utils/frontmatter.js +27 -0
  787. package/dist/utils/frontmatter.js.map +1 -0
  788. package/dist/utils/fs-watch.d.ts +5 -0
  789. package/dist/utils/fs-watch.d.ts.map +1 -0
  790. package/dist/utils/fs-watch.js +25 -0
  791. package/dist/utils/fs-watch.js.map +1 -0
  792. package/dist/utils/git.d.ts +26 -0
  793. package/dist/utils/git.d.ts.map +1 -0
  794. package/dist/utils/git.js +195 -0
  795. package/dist/utils/git.js.map +1 -0
  796. package/dist/utils/html.d.ts +7 -0
  797. package/dist/utils/html.d.ts.map +1 -0
  798. package/dist/utils/html.js +40 -0
  799. package/dist/utils/html.js.map +1 -0
  800. package/dist/utils/image-convert.d.ts +10 -0
  801. package/dist/utils/image-convert.d.ts.map +1 -0
  802. package/dist/utils/image-convert.js +45 -0
  803. package/dist/utils/image-convert.js.map +1 -0
  804. package/dist/utils/image-process.d.ts +18 -0
  805. package/dist/utils/image-process.d.ts.map +1 -0
  806. package/dist/utils/image-process.js +83 -0
  807. package/dist/utils/image-process.js.map +1 -0
  808. package/dist/utils/image-resize-core.d.ts +30 -0
  809. package/dist/utils/image-resize-core.d.ts.map +1 -0
  810. package/dist/utils/image-resize-core.js +124 -0
  811. package/dist/utils/image-resize-core.js.map +1 -0
  812. package/dist/utils/image-resize-worker.d.ts +2 -0
  813. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  814. package/dist/utils/image-resize-worker.js +31 -0
  815. package/dist/utils/image-resize-worker.js.map +1 -0
  816. package/dist/utils/image-resize.d.ts +16 -0
  817. package/dist/utils/image-resize.d.ts.map +1 -0
  818. package/dist/utils/image-resize.js +97 -0
  819. package/dist/utils/image-resize.js.map +1 -0
  820. package/dist/utils/json.d.ts +3 -0
  821. package/dist/utils/json.d.ts.map +1 -0
  822. package/dist/utils/json.js +7 -0
  823. package/dist/utils/json.js.map +1 -0
  824. package/dist/utils/management-http.d.ts +25 -0
  825. package/dist/utils/management-http.d.ts.map +1 -0
  826. package/dist/utils/management-http.js +54 -0
  827. package/dist/utils/management-http.js.map +1 -0
  828. package/dist/utils/mime.d.ts +3 -0
  829. package/dist/utils/mime.d.ts.map +1 -0
  830. package/dist/utils/mime.js +110 -0
  831. package/dist/utils/mime.js.map +1 -0
  832. package/dist/utils/open-browser.d.ts +9 -0
  833. package/dist/utils/open-browser.d.ts.map +1 -0
  834. package/dist/utils/open-browser.js +22 -0
  835. package/dist/utils/open-browser.js.map +1 -0
  836. package/dist/utils/paths.d.ts +34 -0
  837. package/dist/utils/paths.d.ts.map +1 -0
  838. package/dist/utils/paths.js +114 -0
  839. package/dist/utils/paths.js.map +1 -0
  840. package/dist/utils/photon.d.ts +21 -0
  841. package/dist/utils/photon.d.ts.map +1 -0
  842. package/dist/utils/photon.js +121 -0
  843. package/dist/utils/photon.js.map +1 -0
  844. package/dist/utils/pi-user-agent.d.ts +2 -0
  845. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  846. package/dist/utils/pi-user-agent.js +5 -0
  847. package/dist/utils/pi-user-agent.js.map +1 -0
  848. package/dist/utils/shell.d.ts +34 -0
  849. package/dist/utils/shell.d.ts.map +1 -0
  850. package/dist/utils/shell.js +216 -0
  851. package/dist/utils/shell.js.map +1 -0
  852. package/dist/utils/sleep.d.ts +5 -0
  853. package/dist/utils/sleep.d.ts.map +1 -0
  854. package/dist/utils/sleep.js +17 -0
  855. package/dist/utils/sleep.js.map +1 -0
  856. package/dist/utils/syntax-highlight.d.ts +13 -0
  857. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  858. package/dist/utils/syntax-highlight.js +177 -0
  859. package/dist/utils/syntax-highlight.js.map +1 -0
  860. package/dist/utils/text.d.ts +8 -0
  861. package/dist/utils/text.d.ts.map +1 -0
  862. package/dist/utils/text.js +9 -0
  863. package/dist/utils/text.js.map +1 -0
  864. package/dist/utils/tool-result-images.d.ts +19 -0
  865. package/dist/utils/tool-result-images.d.ts.map +1 -0
  866. package/dist/utils/tool-result-images.js +45 -0
  867. package/dist/utils/tool-result-images.js.map +1 -0
  868. package/dist/utils/tools-manager.d.ts +12 -0
  869. package/dist/utils/tools-manager.d.ts.map +1 -0
  870. package/dist/utils/tools-manager.js +321 -0
  871. package/dist/utils/tools-manager.js.map +1 -0
  872. package/dist/utils/version-check.d.ts +19 -0
  873. package/dist/utils/version-check.d.ts.map +1 -0
  874. package/dist/utils/version-check.js +79 -0
  875. package/dist/utils/version-check.js.map +1 -0
  876. package/dist/utils/windows-self-update.d.ts +3 -0
  877. package/dist/utils/windows-self-update.d.ts.map +1 -0
  878. package/dist/utils/windows-self-update.js +77 -0
  879. package/dist/utils/windows-self-update.js.map +1 -0
  880. package/docs/compaction.md +418 -0
  881. package/docs/containerization.md +111 -0
  882. package/docs/custom-provider.md +777 -0
  883. package/docs/development.md +71 -0
  884. package/docs/docs.json +156 -0
  885. package/docs/environment-variables.md +97 -0
  886. package/docs/extensions.md +3020 -0
  887. package/docs/images/doom-extension.png +0 -0
  888. package/docs/images/exy.png +0 -0
  889. package/docs/images/interactive-mode.png +0 -0
  890. package/docs/images/tree-view.png +0 -0
  891. package/docs/index.md +84 -0
  892. package/docs/json.md +98 -0
  893. package/docs/keybindings.md +236 -0
  894. package/docs/llama-cpp.md +101 -0
  895. package/docs/models.md +571 -0
  896. package/docs/packages.md +228 -0
  897. package/docs/prompt-templates.md +96 -0
  898. package/docs/providers.md +317 -0
  899. package/docs/quickstart.md +167 -0
  900. package/docs/rpc.md +1618 -0
  901. package/docs/sdk.md +1219 -0
  902. package/docs/security.md +59 -0
  903. package/docs/session-format.md +438 -0
  904. package/docs/sessions.md +145 -0
  905. package/docs/settings.md +369 -0
  906. package/docs/shell-aliases.md +13 -0
  907. package/docs/skills.md +232 -0
  908. package/docs/terminal-setup.md +177 -0
  909. package/docs/termux.md +127 -0
  910. package/docs/themes.md +320 -0
  911. package/docs/tmux.md +63 -0
  912. package/docs/tui.md +942 -0
  913. package/docs/usage.md +311 -0
  914. package/docs/windows.md +39 -0
  915. package/examples/README.md +25 -0
  916. package/examples/extensions/README.md +213 -0
  917. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  918. package/examples/extensions/bash-spawn-hook.ts +30 -0
  919. package/examples/extensions/bookmark.ts +50 -0
  920. package/examples/extensions/border-status-editor.ts +150 -0
  921. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  922. package/examples/extensions/claude-rules.ts +86 -0
  923. package/examples/extensions/commands.ts +72 -0
  924. package/examples/extensions/confirm-destructive.ts +59 -0
  925. package/examples/extensions/custom-compaction.ts +117 -0
  926. package/examples/extensions/custom-footer.ts +64 -0
  927. package/examples/extensions/custom-header.ts +73 -0
  928. package/examples/extensions/custom-provider-anthropic/index.ts +611 -0
  929. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  930. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  931. package/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  932. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  933. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  934. package/examples/extensions/dirty-repo-guard.ts +56 -0
  935. package/examples/extensions/doom-overlay/README.md +46 -0
  936. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  937. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  938. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  939. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  940. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  941. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  942. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  943. package/examples/extensions/doom-overlay/index.ts +74 -0
  944. package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  945. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  946. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  947. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  948. package/examples/extensions/dynamic-resources/index.ts +15 -0
  949. package/examples/extensions/dynamic-tools.ts +74 -0
  950. package/examples/extensions/entry-renderer.ts +41 -0
  951. package/examples/extensions/event-bus.ts +43 -0
  952. package/examples/extensions/file-trigger.ts +41 -0
  953. package/examples/extensions/git-checkpoint.ts +53 -0
  954. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  955. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  956. package/examples/extensions/gondolin/index.ts +531 -0
  957. package/examples/extensions/gondolin/package-lock.json +185 -0
  958. package/examples/extensions/gondolin/package.json +19 -0
  959. package/examples/extensions/handoff.ts +190 -0
  960. package/examples/extensions/hello.ts +26 -0
  961. package/examples/extensions/hidden-thinking-label.ts +53 -0
  962. package/examples/extensions/inline-bash.ts +94 -0
  963. package/examples/extensions/input-transform-streaming.ts +39 -0
  964. package/examples/extensions/input-transform.ts +43 -0
  965. package/examples/extensions/interactive-shell.ts +196 -0
  966. package/examples/extensions/kimi-deferred-tools.ts +61 -0
  967. package/examples/extensions/mac-system-theme.ts +47 -0
  968. package/examples/extensions/message-renderer.ts +59 -0
  969. package/examples/extensions/minimal-mode.ts +426 -0
  970. package/examples/extensions/modal-editor.ts +85 -0
  971. package/examples/extensions/model-status.ts +31 -0
  972. package/examples/extensions/notify.ts +57 -0
  973. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  974. package/examples/extensions/overlay-test.ts +153 -0
  975. package/examples/extensions/permission-gate.ts +34 -0
  976. package/examples/extensions/pirate.ts +47 -0
  977. package/examples/extensions/plan-mode/README.md +66 -0
  978. package/examples/extensions/plan-mode/index.ts +390 -0
  979. package/examples/extensions/plan-mode/utils.ts +168 -0
  980. package/examples/extensions/preset.ts +436 -0
  981. package/examples/extensions/project-trust.ts +64 -0
  982. package/examples/extensions/prompt-customizer.ts +97 -0
  983. package/examples/extensions/protected-paths.ts +30 -0
  984. package/examples/extensions/provider-payload.ts +18 -0
  985. package/examples/extensions/qna.ts +118 -0
  986. package/examples/extensions/question.ts +286 -0
  987. package/examples/extensions/questionnaire.ts +448 -0
  988. package/examples/extensions/rainbow-editor.ts +88 -0
  989. package/examples/extensions/reload-runtime.ts +37 -0
  990. package/examples/extensions/rpc-demo.ts +118 -0
  991. package/examples/extensions/sandbox/index.ts +321 -0
  992. package/examples/extensions/sandbox/package-lock.json +92 -0
  993. package/examples/extensions/sandbox/package.json +19 -0
  994. package/examples/extensions/send-user-message.ts +97 -0
  995. package/examples/extensions/session-name.ts +27 -0
  996. package/examples/extensions/shutdown-command.ts +63 -0
  997. package/examples/extensions/snake.ts +343 -0
  998. package/examples/extensions/space-invaders.ts +560 -0
  999. package/examples/extensions/ssh.ts +220 -0
  1000. package/examples/extensions/status-line.ts +32 -0
  1001. package/examples/extensions/structured-output.ts +65 -0
  1002. package/examples/extensions/subagent/README.md +177 -0
  1003. package/examples/extensions/subagent/agents/planner.md +37 -0
  1004. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  1005. package/examples/extensions/subagent/agents/scout.md +50 -0
  1006. package/examples/extensions/subagent/agents/worker.md +24 -0
  1007. package/examples/extensions/subagent/agents.ts +157 -0
  1008. package/examples/extensions/subagent/index.ts +1038 -0
  1009. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  1010. package/examples/extensions/subagent/prompts/implement.md +10 -0
  1011. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  1012. package/examples/extensions/summarize.ts +199 -0
  1013. package/examples/extensions/system-prompt-header.ts +17 -0
  1014. package/examples/extensions/tic-tac-toe.ts +1008 -0
  1015. package/examples/extensions/timed-confirm.ts +70 -0
  1016. package/examples/extensions/titlebar-spinner.ts +58 -0
  1017. package/examples/extensions/todo.ts +297 -0
  1018. package/examples/extensions/tool-override.ts +144 -0
  1019. package/examples/extensions/tools.ts +146 -0
  1020. package/examples/extensions/trigger-compact.ts +50 -0
  1021. package/examples/extensions/truncated-tool.ts +195 -0
  1022. package/examples/extensions/widget-placement.ts +9 -0
  1023. package/examples/extensions/with-deps/index.ts +32 -0
  1024. package/examples/extensions/with-deps/package-lock.json +31 -0
  1025. package/examples/extensions/with-deps/package.json +22 -0
  1026. package/examples/extensions/working-indicator.ts +123 -0
  1027. package/examples/extensions/working-message-test.ts +25 -0
  1028. package/examples/rpc-extension-ui.ts +641 -0
  1029. package/examples/sdk/01-minimal.ts +26 -0
  1030. package/examples/sdk/02-custom-model.ts +49 -0
  1031. package/examples/sdk/03-custom-prompt.ts +70 -0
  1032. package/examples/sdk/04-skills.ts +55 -0
  1033. package/examples/sdk/05-tools.ts +48 -0
  1034. package/examples/sdk/06-extensions.ts +94 -0
  1035. package/examples/sdk/07-context-files.ts +42 -0
  1036. package/examples/sdk/08-prompt-templates.ts +51 -0
  1037. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  1038. package/examples/sdk/10-settings.ts +53 -0
  1039. package/examples/sdk/11-sessions.ts +52 -0
  1040. package/examples/sdk/12-full-control.ts +74 -0
  1041. package/examples/sdk/13-session-runtime.ts +67 -0
  1042. package/examples/sdk/README.md +140 -0
  1043. package/npm-shrinkwrap.json +477 -0
  1044. package/package.json +109 -0
@@ -0,0 +1,1092 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { getCapabilities, } from "@earendil-works/pi-tui";
4
+ import chalk from "chalk";
5
+ import { Type } from "typebox";
6
+ import { Compile } from "typebox/compile";
7
+ import { getCustomThemesDir, getThemesDir } from "../../../config.js";
8
+ import { closeWatcher, watchWithErrorHandler } from "../../../utils/fs-watch.js";
9
+ import { highlight, supportsLanguage } from "../../../utils/syntax-highlight.js";
10
+ import { stripBom } from "../../../utils/text.js";
11
+ // ============================================================================
12
+ // Types & Schema
13
+ // ============================================================================
14
+ const ColorValueSchema = Type.Union([
15
+ Type.String(), // hex "#ff0000", var ref "primary", or empty ""
16
+ Type.Integer({ minimum: 0, maximum: 255 }), // 256-color index
17
+ ]);
18
+ const ThemeJsonSchema = Type.Object({
19
+ $schema: Type.Optional(Type.String()),
20
+ name: Type.String(),
21
+ vars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),
22
+ colors: Type.Object({
23
+ // Core UI (10 colors)
24
+ accent: ColorValueSchema,
25
+ border: ColorValueSchema,
26
+ borderAccent: ColorValueSchema,
27
+ borderMuted: ColorValueSchema,
28
+ success: ColorValueSchema,
29
+ error: ColorValueSchema,
30
+ warning: ColorValueSchema,
31
+ muted: ColorValueSchema,
32
+ dim: ColorValueSchema,
33
+ text: ColorValueSchema,
34
+ thinkingText: ColorValueSchema,
35
+ // Backgrounds & Content Text (11 required, 3 optional)
36
+ selectedBg: ColorValueSchema,
37
+ scrollbarThumb: Type.Optional(ColorValueSchema),
38
+ searchMatchBg: Type.Optional(ColorValueSchema),
39
+ searchMatchText: Type.Optional(ColorValueSchema),
40
+ userMessageBg: ColorValueSchema,
41
+ userMessageText: ColorValueSchema,
42
+ customMessageBg: ColorValueSchema,
43
+ customMessageText: ColorValueSchema,
44
+ customMessageLabel: ColorValueSchema,
45
+ toolPendingBg: ColorValueSchema,
46
+ toolSuccessBg: ColorValueSchema,
47
+ toolErrorBg: ColorValueSchema,
48
+ toolTitle: ColorValueSchema,
49
+ toolOutput: ColorValueSchema,
50
+ // Markdown (10 colors)
51
+ mdHeading: ColorValueSchema,
52
+ mdLink: ColorValueSchema,
53
+ mdLinkUrl: ColorValueSchema,
54
+ mdCode: ColorValueSchema,
55
+ mdCodeBlock: ColorValueSchema,
56
+ mdCodeBlockBorder: ColorValueSchema,
57
+ mdQuote: ColorValueSchema,
58
+ mdQuoteBorder: ColorValueSchema,
59
+ mdHr: ColorValueSchema,
60
+ mdListBullet: ColorValueSchema,
61
+ // Tool Diffs (3 colors)
62
+ toolDiffAdded: ColorValueSchema,
63
+ toolDiffRemoved: ColorValueSchema,
64
+ toolDiffContext: ColorValueSchema,
65
+ // Syntax Highlighting (9 colors)
66
+ syntaxComment: ColorValueSchema,
67
+ syntaxKeyword: ColorValueSchema,
68
+ syntaxFunction: ColorValueSchema,
69
+ syntaxVariable: ColorValueSchema,
70
+ syntaxString: ColorValueSchema,
71
+ syntaxNumber: ColorValueSchema,
72
+ syntaxType: ColorValueSchema,
73
+ syntaxOperator: ColorValueSchema,
74
+ syntaxPunctuation: ColorValueSchema,
75
+ // Thinking Level Borders (6 colors)
76
+ thinkingOff: ColorValueSchema,
77
+ thinkingMinimal: ColorValueSchema,
78
+ thinkingLow: ColorValueSchema,
79
+ thinkingMedium: ColorValueSchema,
80
+ thinkingHigh: ColorValueSchema,
81
+ thinkingXhigh: ColorValueSchema,
82
+ thinkingMax: Type.Optional(ColorValueSchema),
83
+ // Bash Mode (1 color)
84
+ bashMode: ColorValueSchema,
85
+ }),
86
+ export: Type.Optional(Type.Object({
87
+ pageBg: Type.Optional(ColorValueSchema),
88
+ cardBg: Type.Optional(ColorValueSchema),
89
+ infoBg: Type.Optional(ColorValueSchema),
90
+ })),
91
+ });
92
+ const validateThemeJson = Compile(ThemeJsonSchema);
93
+ // ============================================================================
94
+ // Color Utilities
95
+ // ============================================================================
96
+ function hexToRgb(hex) {
97
+ const cleaned = hex.replace("#", "");
98
+ if (cleaned.length !== 6) {
99
+ throw new Error(`Invalid hex color: ${hex}`);
100
+ }
101
+ const r = parseInt(cleaned.substring(0, 2), 16);
102
+ const g = parseInt(cleaned.substring(2, 4), 16);
103
+ const b = parseInt(cleaned.substring(4, 6), 16);
104
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
105
+ throw new Error(`Invalid hex color: ${hex}`);
106
+ }
107
+ return { r, g, b };
108
+ }
109
+ // The 6x6x6 color cube channel values (indices 0-5)
110
+ const CUBE_VALUES = [0, 95, 135, 175, 215, 255];
111
+ // Grayscale ramp values (indices 232-255, 24 grays from 8 to 238)
112
+ const GRAY_VALUES = Array.from({ length: 24 }, (_, i) => 8 + i * 10);
113
+ function findClosestCubeIndex(value) {
114
+ let minDist = Infinity;
115
+ let minIdx = 0;
116
+ for (let i = 0; i < CUBE_VALUES.length; i++) {
117
+ const dist = Math.abs(value - CUBE_VALUES[i]);
118
+ if (dist < minDist) {
119
+ minDist = dist;
120
+ minIdx = i;
121
+ }
122
+ }
123
+ return minIdx;
124
+ }
125
+ function findClosestGrayIndex(gray) {
126
+ let minDist = Infinity;
127
+ let minIdx = 0;
128
+ for (let i = 0; i < GRAY_VALUES.length; i++) {
129
+ const dist = Math.abs(gray - GRAY_VALUES[i]);
130
+ if (dist < minDist) {
131
+ minDist = dist;
132
+ minIdx = i;
133
+ }
134
+ }
135
+ return minIdx;
136
+ }
137
+ function colorDistance(r1, g1, b1, r2, g2, b2) {
138
+ // Weighted Euclidean distance (human eye is more sensitive to green)
139
+ const dr = r1 - r2;
140
+ const dg = g1 - g2;
141
+ const db = b1 - b2;
142
+ return dr * dr * 0.299 + dg * dg * 0.587 + db * db * 0.114;
143
+ }
144
+ function rgbTo256(r, g, b) {
145
+ // Find closest color in the 6x6x6 cube
146
+ const rIdx = findClosestCubeIndex(r);
147
+ const gIdx = findClosestCubeIndex(g);
148
+ const bIdx = findClosestCubeIndex(b);
149
+ const cubeR = CUBE_VALUES[rIdx];
150
+ const cubeG = CUBE_VALUES[gIdx];
151
+ const cubeB = CUBE_VALUES[bIdx];
152
+ const cubeIndex = 16 + 36 * rIdx + 6 * gIdx + bIdx;
153
+ const cubeDist = colorDistance(r, g, b, cubeR, cubeG, cubeB);
154
+ // Find closest grayscale
155
+ const gray = Math.round(0.299 * r + 0.587 * g + 0.114 * b);
156
+ const grayIdx = findClosestGrayIndex(gray);
157
+ const grayValue = GRAY_VALUES[grayIdx];
158
+ const grayIndex = 232 + grayIdx;
159
+ const grayDist = colorDistance(r, g, b, grayValue, grayValue, grayValue);
160
+ // Check if color has noticeable saturation (hue matters)
161
+ // If max-min spread is significant, prefer cube to preserve tint
162
+ const maxC = Math.max(r, g, b);
163
+ const minC = Math.min(r, g, b);
164
+ const spread = maxC - minC;
165
+ // Only consider grayscale if color is nearly neutral (spread < 10)
166
+ // AND grayscale is actually closer
167
+ if (spread < 10 && grayDist < cubeDist) {
168
+ return grayIndex;
169
+ }
170
+ return cubeIndex;
171
+ }
172
+ function hexTo256(hex) {
173
+ const { r, g, b } = hexToRgb(hex);
174
+ return rgbTo256(r, g, b);
175
+ }
176
+ function fgAnsi(color, mode) {
177
+ if (color === "")
178
+ return "\x1b[39m";
179
+ if (typeof color === "number")
180
+ return `\x1b[38;5;${color}m`;
181
+ if (color.startsWith("#")) {
182
+ if (mode === "truecolor") {
183
+ const { r, g, b } = hexToRgb(color);
184
+ return `\x1b[38;2;${r};${g};${b}m`;
185
+ }
186
+ else {
187
+ const index = hexTo256(color);
188
+ return `\x1b[38;5;${index}m`;
189
+ }
190
+ }
191
+ throw new Error(`Invalid color value: ${color}`);
192
+ }
193
+ function bgAnsi(color, mode) {
194
+ if (color === "")
195
+ return "\x1b[49m";
196
+ if (typeof color === "number")
197
+ return `\x1b[48;5;${color}m`;
198
+ if (color.startsWith("#")) {
199
+ if (mode === "truecolor") {
200
+ const { r, g, b } = hexToRgb(color);
201
+ return `\x1b[48;2;${r};${g};${b}m`;
202
+ }
203
+ else {
204
+ const index = hexTo256(color);
205
+ return `\x1b[48;5;${index}m`;
206
+ }
207
+ }
208
+ throw new Error(`Invalid color value: ${color}`);
209
+ }
210
+ function resolveVarRefs(value, vars, visited = new Set()) {
211
+ if (typeof value === "number" || value === "" || value.startsWith("#")) {
212
+ return value;
213
+ }
214
+ if (visited.has(value)) {
215
+ throw new Error(`Circular variable reference detected: ${value}`);
216
+ }
217
+ if (!(value in vars)) {
218
+ throw new Error(`Variable reference not found: ${value}`);
219
+ }
220
+ visited.add(value);
221
+ return resolveVarRefs(vars[value], vars, visited);
222
+ }
223
+ function resolveThemeColors(colors, vars = {}) {
224
+ const resolved = {};
225
+ for (const [key, value] of Object.entries(colors)) {
226
+ resolved[key] = resolveVarRefs(value, vars);
227
+ }
228
+ return resolved;
229
+ }
230
+ function withThemeColorFallbacks(colors) {
231
+ return {
232
+ ...colors,
233
+ thinkingMax: colors.thinkingMax ?? colors.thinkingXhigh,
234
+ scrollbarThumb: colors.scrollbarThumb ?? colors.selectedBg,
235
+ searchMatchBg: colors.searchMatchBg ?? colors.selectedBg,
236
+ searchMatchText: colors.searchMatchText ?? colors.text,
237
+ };
238
+ }
239
+ // ============================================================================
240
+ // Theme Class
241
+ // ============================================================================
242
+ export class Theme {
243
+ name;
244
+ sourcePath;
245
+ sourceInfo;
246
+ fgColors;
247
+ bgColors;
248
+ mode;
249
+ constructor(fgColors, bgColors, mode, options = {}) {
250
+ this.name = options.name;
251
+ this.sourcePath = options.sourcePath;
252
+ this.sourceInfo = options.sourceInfo;
253
+ this.mode = mode;
254
+ this.fgColors = new Map();
255
+ const colors = {
256
+ ...fgColors,
257
+ thinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh,
258
+ searchMatchText: fgColors.searchMatchText ?? fgColors.text,
259
+ };
260
+ for (const [key, value] of Object.entries(colors)) {
261
+ this.fgColors.set(key, fgAnsi(value, mode));
262
+ }
263
+ this.bgColors = new Map();
264
+ const backgrounds = {
265
+ ...bgColors,
266
+ scrollbarThumb: bgColors.scrollbarThumb ?? bgColors.selectedBg,
267
+ searchMatchBg: bgColors.searchMatchBg ?? bgColors.selectedBg,
268
+ };
269
+ for (const [key, value] of Object.entries(backgrounds)) {
270
+ this.bgColors.set(key, bgAnsi(value, mode));
271
+ }
272
+ }
273
+ fg(color, text) {
274
+ const ansi = this.fgColors.get(color);
275
+ if (!ansi)
276
+ throw new Error(`Unknown theme color: ${color}`);
277
+ return `${ansi}${text}\x1b[39m`; // Reset only foreground color
278
+ }
279
+ bg(color, text) {
280
+ const ansi = this.bgColors.get(color);
281
+ if (!ansi)
282
+ throw new Error(`Unknown theme background color: ${color}`);
283
+ return `${ansi}${text}\x1b[49m`; // Reset only background color
284
+ }
285
+ bold(text) {
286
+ return chalk.bold(text);
287
+ }
288
+ italic(text) {
289
+ return chalk.italic(text);
290
+ }
291
+ underline(text) {
292
+ return chalk.underline(text);
293
+ }
294
+ inverse(text) {
295
+ return chalk.inverse(text);
296
+ }
297
+ strikethrough(text) {
298
+ return chalk.strikethrough(text);
299
+ }
300
+ getFgAnsi(color) {
301
+ const ansi = this.fgColors.get(color);
302
+ if (!ansi)
303
+ throw new Error(`Unknown theme color: ${color}`);
304
+ return ansi;
305
+ }
306
+ getBgAnsi(color) {
307
+ const ansi = this.bgColors.get(color);
308
+ if (!ansi)
309
+ throw new Error(`Unknown theme background color: ${color}`);
310
+ return ansi;
311
+ }
312
+ getColorMode() {
313
+ return this.mode;
314
+ }
315
+ getThinkingBorderColor(level) {
316
+ // Map thinking levels to dedicated theme colors
317
+ switch (level) {
318
+ case "off":
319
+ return (str) => this.fg("thinkingOff", str);
320
+ case "minimal":
321
+ return (str) => this.fg("thinkingMinimal", str);
322
+ case "low":
323
+ return (str) => this.fg("thinkingLow", str);
324
+ case "medium":
325
+ return (str) => this.fg("thinkingMedium", str);
326
+ case "high":
327
+ return (str) => this.fg("thinkingHigh", str);
328
+ case "xhigh":
329
+ return (str) => this.fg("thinkingXhigh", str);
330
+ case "max":
331
+ return (str) => this.fg("thinkingMax", str);
332
+ default:
333
+ return (str) => this.fg("thinkingOff", str);
334
+ }
335
+ }
336
+ getBashModeBorderColor() {
337
+ return (str) => this.fg("bashMode", str);
338
+ }
339
+ }
340
+ // ============================================================================
341
+ // Theme Loading
342
+ // ============================================================================
343
+ let BUILTIN_THEMES;
344
+ function getBuiltinThemes() {
345
+ if (!BUILTIN_THEMES) {
346
+ const themesDir = getThemesDir();
347
+ const darkPath = path.join(themesDir, "dark.json");
348
+ const lightPath = path.join(themesDir, "light.json");
349
+ BUILTIN_THEMES = {
350
+ dark: JSON.parse(stripBom(fs.readFileSync(darkPath, "utf-8"))),
351
+ light: JSON.parse(stripBom(fs.readFileSync(lightPath, "utf-8"))),
352
+ };
353
+ }
354
+ return BUILTIN_THEMES;
355
+ }
356
+ export function getAvailableThemes() {
357
+ return getAvailableThemesWithPaths().map(({ name }) => name);
358
+ }
359
+ export function getAvailableThemesWithPaths() {
360
+ const themesDir = getThemesDir();
361
+ const result = [];
362
+ const seen = new Set();
363
+ const addTheme = (themeInfo) => {
364
+ if (seen.has(themeInfo.name)) {
365
+ return;
366
+ }
367
+ seen.add(themeInfo.name);
368
+ result.push(themeInfo);
369
+ };
370
+ // Built-in themes
371
+ for (const name of Object.keys(getBuiltinThemes())) {
372
+ addTheme({ name, path: path.join(themesDir, `${name}.json`) });
373
+ }
374
+ // Custom themes
375
+ for (const themeInfo of getCustomThemeInfos()) {
376
+ addTheme(themeInfo);
377
+ }
378
+ for (const [name, theme] of registeredThemes.entries()) {
379
+ addTheme({ name, path: theme.sourcePath });
380
+ }
381
+ return result.sort((a, b) => a.name.localeCompare(b.name));
382
+ }
383
+ function getCustomThemeInfos() {
384
+ const customThemesDir = getCustomThemesDir();
385
+ const result = [];
386
+ if (!fs.existsSync(customThemesDir)) {
387
+ return result;
388
+ }
389
+ for (const file of fs.readdirSync(customThemesDir)) {
390
+ if (!file.endsWith(".json")) {
391
+ continue;
392
+ }
393
+ const themePath = path.join(customThemesDir, file);
394
+ try {
395
+ const customTheme = loadThemeFromPath(themePath);
396
+ if (customTheme.name) {
397
+ result.push({ name: customTheme.name, path: themePath });
398
+ }
399
+ }
400
+ catch {
401
+ // Invalid themes are ignored here; the resource loader reports them
402
+ // during normal startup/reload.
403
+ }
404
+ }
405
+ return result;
406
+ }
407
+ function assertThemeNameIsValid(name) {
408
+ if (name.includes("/")) {
409
+ throw new Error(`Invalid theme name "${name}": theme names cannot contain "/" because it is reserved for automatic light/dark theme settings.`);
410
+ }
411
+ }
412
+ function parseThemeJson(label, json) {
413
+ if (!validateThemeJson.Check(json)) {
414
+ const errors = Array.from(validateThemeJson.Errors(json));
415
+ const missingColors = new Set();
416
+ const otherErrors = [];
417
+ for (const error of errors) {
418
+ if (error.keyword === "required" && error.instancePath === "/colors") {
419
+ const requiredProperties = error.params.requiredProperties;
420
+ for (const requiredProperty of requiredProperties ?? []) {
421
+ missingColors.add(requiredProperty);
422
+ }
423
+ continue;
424
+ }
425
+ const path = error.instancePath || "/";
426
+ otherErrors.push(` - ${path}: ${error.message}`);
427
+ }
428
+ let errorMessage = `Invalid theme "${label}":\n`;
429
+ if (missingColors.size > 0) {
430
+ errorMessage += "\nMissing required color tokens:\n";
431
+ errorMessage += Array.from(missingColors)
432
+ .sort()
433
+ .map((color) => ` - ${color}`)
434
+ .join("\n");
435
+ errorMessage += '\n\nPlease add these colors to your theme\'s "colors" object.';
436
+ errorMessage += "\nSee the built-in themes (dark.json, light.json) for reference values.";
437
+ }
438
+ if (otherErrors.length > 0) {
439
+ errorMessage += `\n\nOther errors:\n${otherErrors.join("\n")}`;
440
+ }
441
+ throw new Error(errorMessage);
442
+ }
443
+ const themeJson = json;
444
+ assertThemeNameIsValid(themeJson.name);
445
+ return themeJson;
446
+ }
447
+ function parseThemeJsonContent(label, content) {
448
+ let json;
449
+ try {
450
+ json = JSON.parse(stripBom(content));
451
+ }
452
+ catch (error) {
453
+ throw new Error(`Failed to parse theme ${label}: ${error}`);
454
+ }
455
+ return parseThemeJson(label, json);
456
+ }
457
+ function loadThemeJson(name) {
458
+ const builtinThemes = getBuiltinThemes();
459
+ if (name in builtinThemes) {
460
+ return builtinThemes[name];
461
+ }
462
+ const registeredTheme = registeredThemes.get(name);
463
+ if (registeredTheme?.sourcePath) {
464
+ const content = fs.readFileSync(registeredTheme.sourcePath, "utf-8");
465
+ return parseThemeJsonContent(registeredTheme.sourcePath, content);
466
+ }
467
+ if (registeredTheme) {
468
+ throw new Error(`Theme "${name}" does not have a source path for export`);
469
+ }
470
+ const customThemesDir = getCustomThemesDir();
471
+ const themePath = path.join(customThemesDir, `${name}.json`);
472
+ if (!fs.existsSync(themePath)) {
473
+ throw new Error(`Theme not found: ${name}`);
474
+ }
475
+ const content = fs.readFileSync(themePath, "utf-8");
476
+ return parseThemeJsonContent(name, content);
477
+ }
478
+ function createTheme(themeJson, mode, sourcePath) {
479
+ const colorMode = mode ?? (getCapabilities().trueColor ? "truecolor" : "256color");
480
+ const resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);
481
+ const fgColors = {};
482
+ const bgColors = {};
483
+ const bgColorKeys = new Set([
484
+ "selectedBg",
485
+ "scrollbarThumb",
486
+ "searchMatchBg",
487
+ "userMessageBg",
488
+ "customMessageBg",
489
+ "toolPendingBg",
490
+ "toolSuccessBg",
491
+ "toolErrorBg",
492
+ ]);
493
+ for (const [key, value] of Object.entries(resolvedColors)) {
494
+ if (bgColorKeys.has(key)) {
495
+ bgColors[key] = value;
496
+ }
497
+ else {
498
+ fgColors[key] = value;
499
+ }
500
+ }
501
+ return new Theme(fgColors, bgColors, colorMode, {
502
+ name: themeJson.name,
503
+ sourcePath,
504
+ });
505
+ }
506
+ export function loadThemeFromPath(themePath, mode) {
507
+ const content = fs.readFileSync(themePath, "utf-8");
508
+ const themeJson = parseThemeJsonContent(themePath, content);
509
+ return createTheme(themeJson, mode, themePath);
510
+ }
511
+ function loadTheme(name, mode) {
512
+ const registeredTheme = registeredThemes.get(name);
513
+ if (registeredTheme) {
514
+ return registeredTheme;
515
+ }
516
+ const themeJson = loadThemeJson(name);
517
+ return createTheme(themeJson, mode);
518
+ }
519
+ export function getThemeByName(name) {
520
+ try {
521
+ return loadTheme(name);
522
+ }
523
+ catch {
524
+ return undefined;
525
+ }
526
+ }
527
+ export function parseAutoThemeSetting(themeSetting) {
528
+ if (!themeSetting)
529
+ return undefined;
530
+ const slashIndex = themeSetting.indexOf("/");
531
+ if (slashIndex === -1 || themeSetting.indexOf("/", slashIndex + 1) !== -1) {
532
+ return undefined;
533
+ }
534
+ const lightTheme = themeSetting.slice(0, slashIndex).trim();
535
+ const darkTheme = themeSetting.slice(slashIndex + 1).trim();
536
+ if (!lightTheme || !darkTheme) {
537
+ return undefined;
538
+ }
539
+ return { lightTheme, darkTheme };
540
+ }
541
+ export function resolveThemeSetting(themeSetting, terminalTheme) {
542
+ const autoTheme = parseAutoThemeSetting(themeSetting);
543
+ if (autoTheme) {
544
+ return terminalTheme === "light" ? autoTheme.lightTheme : autoTheme.darkTheme;
545
+ }
546
+ if (themeSetting?.includes("/"))
547
+ return undefined;
548
+ if (typeof themeSetting === "string")
549
+ return themeSetting;
550
+ return undefined;
551
+ }
552
+ function getColorFgBgBackgroundIndex(colorfgbg) {
553
+ const parts = colorfgbg.split(";");
554
+ for (let i = parts.length - 1; i >= 0; i--) {
555
+ const bg = parseInt(parts[i].trim(), 10);
556
+ if (Number.isInteger(bg) && bg >= 0 && bg <= 255) {
557
+ return bg;
558
+ }
559
+ }
560
+ return undefined;
561
+ }
562
+ function getRgbColorLuminance({ r, g, b }) {
563
+ const toLinear = (channel) => {
564
+ const value = channel / 255;
565
+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
566
+ };
567
+ return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
568
+ }
569
+ function getAnsiColorLuminance(index) {
570
+ return getRgbColorLuminance(hexToRgb(ansi256ToHex(index)));
571
+ }
572
+ export function getThemeForRgbColor(rgb) {
573
+ return getRgbColorLuminance(rgb) >= 0.5 ? "light" : "dark";
574
+ }
575
+ export function detectTerminalBackgroundFromEnv(options = {}) {
576
+ const env = options.env ?? process.env;
577
+ const colorfgbg = env.COLORFGBG || "";
578
+ const bg = getColorFgBgBackgroundIndex(colorfgbg);
579
+ if (bg !== undefined) {
580
+ return {
581
+ theme: getAnsiColorLuminance(bg) >= 0.5 ? "light" : "dark",
582
+ source: "COLORFGBG",
583
+ detail: `background color index ${bg}`,
584
+ confidence: "high",
585
+ };
586
+ }
587
+ return {
588
+ theme: "dark",
589
+ source: "fallback",
590
+ detail: "no terminal background hint found",
591
+ confidence: "low",
592
+ };
593
+ }
594
+ export async function detectTerminalBackgroundTheme({ ui, timeoutMs, env, }) {
595
+ try {
596
+ const rgb = await ui.queryTerminalBackgroundColor({ timeoutMs });
597
+ if (rgb) {
598
+ return {
599
+ theme: getThemeForRgbColor(rgb),
600
+ source: "terminal background",
601
+ detail: `OSC 11 background rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,
602
+ confidence: "high",
603
+ };
604
+ }
605
+ }
606
+ catch {
607
+ // Fall back to environment-based detection when the terminal query fails.
608
+ }
609
+ return detectTerminalBackgroundFromEnv({ env });
610
+ }
611
+ export async function detectTerminalThemeForAuto({ ui, timeoutMs, env, }) {
612
+ let colorSchemePromise;
613
+ try {
614
+ colorSchemePromise = ui.queryTerminalColorScheme?.({ timeoutMs });
615
+ }
616
+ catch {
617
+ // Fall back to OSC 11 / COLORFGBG detection when starting the color-scheme query fails.
618
+ }
619
+ const backgroundThemePromise = detectTerminalBackgroundTheme({ ui, timeoutMs, env });
620
+ try {
621
+ const colorScheme = await colorSchemePromise;
622
+ if (colorScheme)
623
+ return colorScheme;
624
+ }
625
+ catch {
626
+ // Fall back to the concurrently queried OSC 11 / COLORFGBG detection.
627
+ }
628
+ return (await backgroundThemePromise).theme;
629
+ }
630
+ export function getDefaultTheme() {
631
+ return detectTerminalBackgroundFromEnv().theme;
632
+ }
633
+ // ============================================================================
634
+ // Global Theme Instance
635
+ // ============================================================================
636
+ // Use globalThis to share theme across module loaders (tsx + jiti in dev mode)
637
+ const THEME_KEY = Symbol.for("@earendil-works/pi-coding-agent:theme");
638
+ const THEME_KEY_OLD = Symbol.for("@mariozechner/pi-coding-agent:theme");
639
+ // Export theme as a getter that reads from globalThis
640
+ // This ensures all module instances (tsx, jiti) see the same theme
641
+ export const theme = new Proxy({}, {
642
+ get(_target, prop) {
643
+ const t = globalThis[THEME_KEY];
644
+ if (!t)
645
+ throw new Error("Theme not initialized. Call initTheme() first.");
646
+ return t[prop];
647
+ },
648
+ });
649
+ function setGlobalTheme(t) {
650
+ globalThis[THEME_KEY] = t;
651
+ globalThis[THEME_KEY_OLD] = t;
652
+ }
653
+ let currentThemeName;
654
+ let themeWatcher;
655
+ let themeReloadTimer;
656
+ let onThemeChangeCallback;
657
+ const registeredThemes = new Map();
658
+ export function setRegisteredThemes(themes) {
659
+ registeredThemes.clear();
660
+ for (const theme of themes) {
661
+ if (theme.name) {
662
+ assertThemeNameIsValid(theme.name);
663
+ registeredThemes.set(theme.name, theme);
664
+ }
665
+ }
666
+ }
667
+ export function initTheme(themeName, enableWatcher = false) {
668
+ const name = themeName ?? getDefaultTheme();
669
+ currentThemeName = name;
670
+ try {
671
+ setGlobalTheme(loadTheme(name));
672
+ if (enableWatcher) {
673
+ startThemeWatcher();
674
+ }
675
+ }
676
+ catch (_error) {
677
+ // Theme is invalid - fall back to dark theme silently
678
+ currentThemeName = "dark";
679
+ setGlobalTheme(loadTheme("dark"));
680
+ // Don't start watcher for fallback theme
681
+ }
682
+ }
683
+ export function setTheme(name, enableWatcher = false) {
684
+ currentThemeName = name;
685
+ try {
686
+ setGlobalTheme(loadTheme(name));
687
+ if (enableWatcher) {
688
+ startThemeWatcher();
689
+ }
690
+ if (onThemeChangeCallback) {
691
+ onThemeChangeCallback();
692
+ }
693
+ return { success: true };
694
+ }
695
+ catch (error) {
696
+ // Theme is invalid - fall back to dark theme
697
+ currentThemeName = "dark";
698
+ setGlobalTheme(loadTheme("dark"));
699
+ // Don't start watcher for fallback theme
700
+ return {
701
+ success: false,
702
+ error: error instanceof Error ? error.message : String(error),
703
+ };
704
+ }
705
+ }
706
+ export function setThemeInstance(themeInstance) {
707
+ setGlobalTheme(themeInstance);
708
+ currentThemeName = "<in-memory>";
709
+ stopThemeWatcher(); // Can't watch a direct instance
710
+ if (onThemeChangeCallback) {
711
+ onThemeChangeCallback();
712
+ }
713
+ }
714
+ export function onThemeChange(callback) {
715
+ onThemeChangeCallback = callback;
716
+ }
717
+ function startThemeWatcher() {
718
+ stopThemeWatcher();
719
+ // Only watch if it's a custom theme (not built-in)
720
+ if (!currentThemeName || currentThemeName === "dark" || currentThemeName === "light") {
721
+ return;
722
+ }
723
+ const customThemesDir = getCustomThemesDir();
724
+ const watchedThemeName = currentThemeName;
725
+ const watchedFileName = `${watchedThemeName}.json`;
726
+ const themeFile = path.join(customThemesDir, watchedFileName);
727
+ // Only watch if the file exists
728
+ if (!fs.existsSync(themeFile)) {
729
+ return;
730
+ }
731
+ const scheduleReload = () => {
732
+ if (themeReloadTimer) {
733
+ clearTimeout(themeReloadTimer);
734
+ }
735
+ themeReloadTimer = setTimeout(() => {
736
+ themeReloadTimer = undefined;
737
+ // Ignore stale timers after switching themes or stopping the watcher
738
+ if (currentThemeName !== watchedThemeName) {
739
+ return;
740
+ }
741
+ // Keep the last successfully loaded theme active if the file is temporarily missing
742
+ if (!fs.existsSync(themeFile)) {
743
+ return;
744
+ }
745
+ try {
746
+ // Reload the theme from disk and refresh the registry cache
747
+ const reloadedTheme = loadThemeFromPath(themeFile);
748
+ registeredThemes.set(watchedThemeName, reloadedTheme);
749
+ setGlobalTheme(reloadedTheme);
750
+ // Notify callback (to invalidate UI)
751
+ if (onThemeChangeCallback) {
752
+ onThemeChangeCallback();
753
+ }
754
+ }
755
+ catch (_error) {
756
+ // Ignore errors (file might be in invalid state while being edited)
757
+ }
758
+ }, 100);
759
+ };
760
+ themeWatcher =
761
+ watchWithErrorHandler(customThemesDir, (_eventType, filename) => {
762
+ if (currentThemeName !== watchedThemeName) {
763
+ return;
764
+ }
765
+ if (!filename) {
766
+ scheduleReload();
767
+ return;
768
+ }
769
+ if (filename !== watchedFileName) {
770
+ return;
771
+ }
772
+ scheduleReload();
773
+ }, () => {
774
+ closeWatcher(themeWatcher);
775
+ themeWatcher = undefined;
776
+ }) ?? undefined;
777
+ }
778
+ export function stopThemeWatcher() {
779
+ if (themeReloadTimer) {
780
+ clearTimeout(themeReloadTimer);
781
+ themeReloadTimer = undefined;
782
+ }
783
+ closeWatcher(themeWatcher);
784
+ themeWatcher = undefined;
785
+ }
786
+ // ============================================================================
787
+ // HTML Export Helpers
788
+ // ============================================================================
789
+ /**
790
+ * Convert a 256-color index to hex string.
791
+ * Indices 0-15: basic colors (approximate)
792
+ * Indices 16-231: 6x6x6 color cube
793
+ * Indices 232-255: grayscale ramp
794
+ */
795
+ function ansi256ToHex(index) {
796
+ // Basic colors (0-15) - approximate common terminal values
797
+ const basicColors = [
798
+ "#000000",
799
+ "#800000",
800
+ "#008000",
801
+ "#808000",
802
+ "#000080",
803
+ "#800080",
804
+ "#008080",
805
+ "#c0c0c0",
806
+ "#808080",
807
+ "#ff0000",
808
+ "#00ff00",
809
+ "#ffff00",
810
+ "#0000ff",
811
+ "#ff00ff",
812
+ "#00ffff",
813
+ "#ffffff",
814
+ ];
815
+ if (index < 16) {
816
+ return basicColors[index];
817
+ }
818
+ // Color cube (16-231): 6x6x6 = 216 colors
819
+ if (index < 232) {
820
+ const cubeIndex = index - 16;
821
+ const r = Math.floor(cubeIndex / 36);
822
+ const g = Math.floor((cubeIndex % 36) / 6);
823
+ const b = cubeIndex % 6;
824
+ const toHex = (n) => (n === 0 ? 0 : 55 + n * 40).toString(16).padStart(2, "0");
825
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
826
+ }
827
+ // Grayscale (232-255): 24 shades
828
+ const gray = 8 + (index - 232) * 10;
829
+ const grayHex = gray.toString(16).padStart(2, "0");
830
+ return `#${grayHex}${grayHex}${grayHex}`;
831
+ }
832
+ /**
833
+ * Get resolved theme colors as CSS-compatible hex strings.
834
+ * Used by HTML export to generate CSS custom properties.
835
+ */
836
+ export function getResolvedThemeColors(themeName) {
837
+ const name = themeName ?? currentThemeName ?? getDefaultTheme();
838
+ const isLight = name === "light";
839
+ const themeJson = loadThemeJson(name);
840
+ const resolved = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);
841
+ // Default text color for empty values (terminal uses default fg color)
842
+ const defaultText = isLight ? "#000000" : "#e5e5e7";
843
+ const cssColors = {};
844
+ for (const [key, value] of Object.entries(resolved)) {
845
+ if (typeof value === "number") {
846
+ cssColors[key] = ansi256ToHex(value);
847
+ }
848
+ else if (value === "") {
849
+ // Empty means default terminal color - use sensible fallback for HTML
850
+ cssColors[key] = defaultText;
851
+ }
852
+ else {
853
+ cssColors[key] = value;
854
+ }
855
+ }
856
+ return cssColors;
857
+ }
858
+ /**
859
+ * Check if a theme is a "light" theme (for CSS that needs light/dark variants).
860
+ */
861
+ export function isLightTheme(themeName) {
862
+ // Currently just check the name - could be extended to analyze colors
863
+ return themeName === "light";
864
+ }
865
+ /**
866
+ * Get explicit export colors from theme JSON, if specified.
867
+ * Returns undefined for each color that isn't explicitly set.
868
+ */
869
+ export function getThemeExportColors(themeName) {
870
+ const name = themeName ?? currentThemeName ?? getDefaultTheme();
871
+ try {
872
+ const themeJson = loadThemeJson(name);
873
+ const exportSection = themeJson.export;
874
+ if (!exportSection)
875
+ return {};
876
+ const vars = themeJson.vars ?? {};
877
+ const resolve = (value) => {
878
+ if (value === undefined)
879
+ return undefined;
880
+ const resolved = resolveVarRefs(value, vars);
881
+ if (typeof resolved === "number")
882
+ return ansi256ToHex(resolved);
883
+ if (resolved === "")
884
+ return undefined;
885
+ return resolved;
886
+ };
887
+ return {
888
+ pageBg: resolve(exportSection.pageBg),
889
+ cardBg: resolve(exportSection.cardBg),
890
+ infoBg: resolve(exportSection.infoBg),
891
+ };
892
+ }
893
+ catch {
894
+ return {};
895
+ }
896
+ }
897
+ let cachedHighlightThemeFor;
898
+ let cachedCliHighlightTheme;
899
+ function buildCliHighlightTheme(t) {
900
+ return {
901
+ keyword: (s) => t.fg("syntaxKeyword", s),
902
+ built_in: (s) => t.fg("syntaxType", s),
903
+ literal: (s) => t.fg("syntaxNumber", s),
904
+ number: (s) => t.fg("syntaxNumber", s),
905
+ regexp: (s) => t.fg("syntaxString", s),
906
+ string: (s) => t.fg("syntaxString", s),
907
+ comment: (s) => t.fg("syntaxComment", s),
908
+ doctag: (s) => t.fg("syntaxComment", s),
909
+ meta: (s) => t.fg("muted", s),
910
+ function: (s) => t.fg("syntaxFunction", s),
911
+ title: (s) => t.fg("syntaxFunction", s),
912
+ class: (s) => t.fg("syntaxType", s),
913
+ type: (s) => t.fg("syntaxType", s),
914
+ tag: (s) => t.fg("syntaxPunctuation", s),
915
+ name: (s) => t.fg("syntaxKeyword", s),
916
+ attr: (s) => t.fg("syntaxVariable", s),
917
+ variable: (s) => t.fg("syntaxVariable", s),
918
+ params: (s) => t.fg("syntaxVariable", s),
919
+ operator: (s) => t.fg("syntaxOperator", s),
920
+ punctuation: (s) => t.fg("syntaxPunctuation", s),
921
+ emphasis: (s) => t.italic(s),
922
+ strong: (s) => t.bold(s),
923
+ link: (s) => t.underline(s),
924
+ addition: (s) => t.fg("toolDiffAdded", s),
925
+ deletion: (s) => t.fg("toolDiffRemoved", s),
926
+ };
927
+ }
928
+ function getCliHighlightTheme(t) {
929
+ if (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {
930
+ cachedHighlightThemeFor = t;
931
+ cachedCliHighlightTheme = buildCliHighlightTheme(t);
932
+ }
933
+ return cachedCliHighlightTheme;
934
+ }
935
+ /**
936
+ * Highlight code with syntax coloring based on file extension or language.
937
+ * Returns array of highlighted lines.
938
+ */
939
+ export function highlightCode(code, lang) {
940
+ // Validate language before highlighting to avoid stderr spam from cli-highlight
941
+ const validLang = lang && supportsLanguage(lang) ? lang : undefined;
942
+ // Skip highlighting when no valid language is specified. cli-highlight's
943
+ // auto-detection is unreliable and can misidentify prose as AppleScript,
944
+ // LiveCodeServer, etc., coloring random English words as keywords.
945
+ if (!validLang) {
946
+ return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
947
+ }
948
+ const opts = {
949
+ language: validLang,
950
+ ignoreIllegals: true,
951
+ theme: getCliHighlightTheme(theme),
952
+ };
953
+ try {
954
+ return highlight(code, opts).split("\n");
955
+ }
956
+ catch {
957
+ return code.split("\n");
958
+ }
959
+ }
960
+ /**
961
+ * Get language identifier from file path extension.
962
+ */
963
+ export function getLanguageFromPath(filePath) {
964
+ const ext = filePath.split(".").pop()?.toLowerCase();
965
+ if (!ext)
966
+ return undefined;
967
+ const extToLang = {
968
+ ts: "typescript",
969
+ tsx: "typescript",
970
+ js: "javascript",
971
+ jsx: "javascript",
972
+ mjs: "javascript",
973
+ cjs: "javascript",
974
+ py: "python",
975
+ rb: "ruby",
976
+ rs: "rust",
977
+ go: "go",
978
+ java: "java",
979
+ kt: "kotlin",
980
+ swift: "swift",
981
+ c: "c",
982
+ h: "c",
983
+ cpp: "cpp",
984
+ cc: "cpp",
985
+ cxx: "cpp",
986
+ hpp: "cpp",
987
+ cs: "csharp",
988
+ php: "php",
989
+ sh: "bash",
990
+ bash: "bash",
991
+ zsh: "bash",
992
+ fish: "fish",
993
+ ps1: "powershell",
994
+ sql: "sql",
995
+ html: "html",
996
+ htm: "html",
997
+ css: "css",
998
+ scss: "scss",
999
+ sass: "sass",
1000
+ less: "less",
1001
+ json: "json",
1002
+ yaml: "yaml",
1003
+ yml: "yaml",
1004
+ toml: "toml",
1005
+ xml: "xml",
1006
+ md: "markdown",
1007
+ markdown: "markdown",
1008
+ dockerfile: "dockerfile",
1009
+ makefile: "makefile",
1010
+ cmake: "cmake",
1011
+ lua: "lua",
1012
+ perl: "perl",
1013
+ r: "r",
1014
+ scala: "scala",
1015
+ clj: "clojure",
1016
+ ex: "elixir",
1017
+ exs: "elixir",
1018
+ erl: "erlang",
1019
+ hs: "haskell",
1020
+ ml: "ocaml",
1021
+ vim: "vim",
1022
+ graphql: "graphql",
1023
+ proto: "protobuf",
1024
+ tf: "hcl",
1025
+ hcl: "hcl",
1026
+ };
1027
+ return extToLang[ext];
1028
+ }
1029
+ export function getMarkdownTheme() {
1030
+ return {
1031
+ heading: (text) => theme.fg("mdHeading", text),
1032
+ link: (text) => theme.fg("mdLink", text),
1033
+ linkUrl: (text) => theme.fg("mdLinkUrl", text),
1034
+ code: (text) => theme.fg("mdCode", text),
1035
+ codeBlock: (text) => theme.fg("mdCodeBlock", text),
1036
+ codeBlockBorder: (text) => theme.fg("mdCodeBlockBorder", text),
1037
+ quote: (text) => theme.fg("mdQuote", text),
1038
+ quoteBorder: (text) => theme.fg("mdQuoteBorder", text),
1039
+ hr: (text) => theme.fg("mdHr", text),
1040
+ listBullet: (text) => theme.fg("mdListBullet", text),
1041
+ bold: (text) => theme.bold(text),
1042
+ italic: (text) => theme.italic(text),
1043
+ underline: (text) => theme.underline(text),
1044
+ strikethrough: (text) => chalk.strikethrough(text),
1045
+ highlightCode: (code, lang) => {
1046
+ // Validate language before highlighting to avoid stderr spam from cli-highlight
1047
+ const validLang = lang && supportsLanguage(lang) ? lang : undefined;
1048
+ // Skip highlighting when no valid language is specified. cli-highlight's
1049
+ // auto-detection is unreliable and can misidentify prose as AppleScript,
1050
+ // LiveCodeServer, etc., coloring random English words as keywords.
1051
+ if (!validLang) {
1052
+ return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
1053
+ }
1054
+ const opts = {
1055
+ language: validLang,
1056
+ ignoreIllegals: true,
1057
+ theme: getCliHighlightTheme(theme),
1058
+ };
1059
+ try {
1060
+ return highlight(code, opts).split("\n");
1061
+ }
1062
+ catch {
1063
+ return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
1064
+ }
1065
+ },
1066
+ };
1067
+ }
1068
+ export function getSelectListTheme() {
1069
+ return {
1070
+ selectedPrefix: (text) => theme.fg("accent", text),
1071
+ selectedText: (text) => theme.fg("accent", text),
1072
+ description: (text) => theme.fg("muted", text),
1073
+ scrollInfo: (text) => theme.fg("muted", text),
1074
+ noMatch: (text) => theme.fg("muted", text),
1075
+ };
1076
+ }
1077
+ export function getEditorTheme() {
1078
+ return {
1079
+ borderColor: (text) => theme.fg("borderMuted", text),
1080
+ selectList: getSelectListTheme(),
1081
+ };
1082
+ }
1083
+ export function getSettingsListTheme() {
1084
+ return {
1085
+ label: (text, selected) => (selected ? theme.fg("accent", text) : text),
1086
+ value: (text, selected) => (selected ? theme.fg("accent", text) : theme.fg("muted", text)),
1087
+ description: (text) => theme.fg("dim", text),
1088
+ cursor: theme.fg("accent", "→ "),
1089
+ hint: (text) => theme.fg("dim", text),
1090
+ };
1091
+ }
1092
+ //# sourceMappingURL=theme.js.map