@greppleai/grip 0.0.0-stage → 0.1.3

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 (1119) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +731 -2
  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 +13 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/embedded-assets.d.ts +3 -0
  8. package/dist/bun/embedded-assets.d.ts.map +1 -0
  9. package/dist/bun/embedded-assets.js +52 -0
  10. package/dist/bun/embedded-assets.js.map +1 -0
  11. package/dist/bun/register-bedrock.d.ts +2 -0
  12. package/dist/bun/register-bedrock.d.ts.map +1 -0
  13. package/dist/bun/register-bedrock.js +4 -0
  14. package/dist/bun/register-bedrock.js.map +1 -0
  15. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  16. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  17. package/dist/bun/restore-sandbox-env.js +32 -0
  18. package/dist/bun/restore-sandbox-env.js.map +1 -0
  19. package/dist/cli/args.d.ts +70 -0
  20. package/dist/cli/args.d.ts.map +1 -0
  21. package/dist/cli/args.js +442 -0
  22. package/dist/cli/args.js.map +1 -0
  23. package/dist/cli/config-selector.d.ts +14 -0
  24. package/dist/cli/config-selector.d.ts.map +1 -0
  25. package/dist/cli/config-selector.js +31 -0
  26. package/dist/cli/config-selector.js.map +1 -0
  27. package/dist/cli/file-processor.d.ts +15 -0
  28. package/dist/cli/file-processor.d.ts.map +1 -0
  29. package/dist/cli/file-processor.js +60 -0
  30. package/dist/cli/file-processor.js.map +1 -0
  31. package/dist/cli/initial-message.d.ts +18 -0
  32. package/dist/cli/initial-message.d.ts.map +1 -0
  33. package/dist/cli/initial-message.js +22 -0
  34. package/dist/cli/initial-message.js.map +1 -0
  35. package/dist/cli/list-models.d.ts +9 -0
  36. package/dist/cli/list-models.d.ts.map +1 -0
  37. package/dist/cli/list-models.js +98 -0
  38. package/dist/cli/list-models.js.map +1 -0
  39. package/dist/cli/session-picker.d.ts +9 -0
  40. package/dist/cli/session-picker.d.ts.map +1 -0
  41. package/dist/cli/session-picker.js +35 -0
  42. package/dist/cli/session-picker.js.map +1 -0
  43. package/dist/cli.d.ts +3 -0
  44. package/dist/cli.d.ts.map +1 -0
  45. package/dist/cli.js +14 -0
  46. package/dist/cli.js.map +1 -0
  47. package/dist/config.d.ts +82 -0
  48. package/dist/config.d.ts.map +1 -0
  49. package/dist/config.js +406 -0
  50. package/dist/config.js.map +1 -0
  51. package/dist/core/agent-session.d.ts +970 -0
  52. package/dist/core/agent-session.d.ts.map +1 -0
  53. package/dist/core/agent-session.js +5191 -0
  54. package/dist/core/agent-session.js.map +1 -0
  55. package/dist/core/auth-guidance.d.ts +5 -0
  56. package/dist/core/auth-guidance.d.ts.map +1 -0
  57. package/dist/core/auth-guidance.js +21 -0
  58. package/dist/core/auth-guidance.js.map +1 -0
  59. package/dist/core/auth-storage.d.ts +150 -0
  60. package/dist/core/auth-storage.d.ts.map +1 -0
  61. package/dist/core/auth-storage.js +557 -0
  62. package/dist/core/auth-storage.js.map +1 -0
  63. package/dist/core/bash-executor.d.ts +26 -0
  64. package/dist/core/bash-executor.d.ts.map +1 -0
  65. package/dist/core/bash-executor.js +99 -0
  66. package/dist/core/bash-executor.js.map +1 -0
  67. package/dist/core/compaction/branch-summarization.d.ts +83 -0
  68. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  69. package/dist/core/compaction/branch-summarization.js +220 -0
  70. package/dist/core/compaction/branch-summarization.js.map +1 -0
  71. package/dist/core/compaction/compaction.d.ts +65 -0
  72. package/dist/core/compaction/compaction.d.ts.map +1 -0
  73. package/dist/core/compaction/compaction.js +550 -0
  74. package/dist/core/compaction/compaction.js.map +1 -0
  75. package/dist/core/compaction/compression-detection-ledger.d.ts +34 -0
  76. package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -0
  77. package/dist/core/compaction/compression-detection-ledger.js +52 -0
  78. package/dist/core/compaction/compression-detection-ledger.js.map +1 -0
  79. package/dist/core/compaction/compression-detector.d.ts +71 -0
  80. package/dist/core/compaction/compression-detector.d.ts.map +1 -0
  81. package/dist/core/compaction/compression-detector.js +407 -0
  82. package/dist/core/compaction/compression-detector.js.map +1 -0
  83. package/dist/core/compaction/compression-economics.d.ts +55 -0
  84. package/dist/core/compaction/compression-economics.d.ts.map +1 -0
  85. package/dist/core/compaction/compression-economics.js +151 -0
  86. package/dist/core/compaction/compression-economics.js.map +1 -0
  87. package/dist/core/compaction/utils.d.ts +28 -0
  88. package/dist/core/compaction/utils.d.ts.map +1 -0
  89. package/dist/core/compaction/utils.js +165 -0
  90. package/dist/core/compaction/utils.js.map +1 -0
  91. package/dist/core/defaults.d.ts +3 -0
  92. package/dist/core/defaults.d.ts.map +1 -0
  93. package/dist/core/defaults.js +2 -0
  94. package/dist/core/defaults.js.map +1 -0
  95. package/dist/core/diagnostics.d.ts +18 -0
  96. package/dist/core/diagnostics.d.ts.map +1 -0
  97. package/dist/core/diagnostics.js +2 -0
  98. package/dist/core/diagnostics.js.map +1 -0
  99. package/dist/core/event-bus.d.ts +9 -0
  100. package/dist/core/event-bus.d.ts.map +1 -0
  101. package/dist/core/event-bus.js +25 -0
  102. package/dist/core/event-bus.js.map +1 -0
  103. package/dist/core/exec.d.ts +29 -0
  104. package/dist/core/exec.d.ts.map +1 -0
  105. package/dist/core/exec.js +75 -0
  106. package/dist/core/exec.js.map +1 -0
  107. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  108. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  109. package/dist/core/export-html/ansi-to-html.js +245 -0
  110. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  111. package/dist/core/export-html/index.d.ts +21 -0
  112. package/dist/core/export-html/index.d.ts.map +1 -0
  113. package/dist/core/export-html/index.js +230 -0
  114. package/dist/core/export-html/index.js.map +1 -0
  115. package/dist/core/export-html/template.css +1066 -0
  116. package/dist/core/export-html/template.html +55 -0
  117. package/dist/core/export-html/template.js +1864 -0
  118. package/dist/core/export-html/tool-renderer.d.ts +32 -0
  119. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  120. package/dist/core/export-html/tool-renderer.js +108 -0
  121. package/dist/core/export-html/tool-renderer.js.map +1 -0
  122. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  123. package/dist/core/export-html/vendor/marked.min.js +78 -0
  124. package/dist/core/extensions/loader.d.ts +24 -0
  125. package/dist/core/extensions/loader.d.ts.map +1 -0
  126. package/dist/core/extensions/loader.js +613 -0
  127. package/dist/core/extensions/loader.js.map +1 -0
  128. package/dist/core/extensions/runner.d.ts +160 -0
  129. package/dist/core/extensions/runner.d.ts.map +1 -0
  130. package/dist/core/extensions/runner.js +962 -0
  131. package/dist/core/extensions/runner.js.map +1 -0
  132. package/dist/core/extensions/types.d.ts +1311 -0
  133. package/dist/core/extensions/types.d.ts.map +1 -0
  134. package/dist/core/extensions/types.js +51 -0
  135. package/dist/core/extensions/types.js.map +1 -0
  136. package/dist/core/extensions/wrapper.d.ts +20 -0
  137. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  138. package/dist/core/extensions/wrapper.js +22 -0
  139. package/dist/core/extensions/wrapper.js.map +1 -0
  140. package/dist/core/footer-data-provider.d.ts +52 -0
  141. package/dist/core/footer-data-provider.d.ts.map +1 -0
  142. package/dist/core/footer-data-provider.js +318 -0
  143. package/dist/core/footer-data-provider.js.map +1 -0
  144. package/dist/core/grip-agent.d.ts +240 -0
  145. package/dist/core/grip-agent.d.ts.map +1 -0
  146. package/dist/core/grip-agent.js +1243 -0
  147. package/dist/core/grip-agent.js.map +1 -0
  148. package/dist/core/grip-manifest.d.ts +9 -0
  149. package/dist/core/grip-manifest.d.ts.map +1 -0
  150. package/dist/core/grip-manifest.js +25 -0
  151. package/dist/core/grip-manifest.js.map +1 -0
  152. package/dist/core/hooks/aggregate.d.ts +5 -0
  153. package/dist/core/hooks/aggregate.d.ts.map +1 -0
  154. package/dist/core/hooks/aggregate.js +226 -0
  155. package/dist/core/hooks/aggregate.js.map +1 -0
  156. package/dist/core/hooks/config.d.ts +14 -0
  157. package/dist/core/hooks/config.d.ts.map +1 -0
  158. package/dist/core/hooks/config.js +372 -0
  159. package/dist/core/hooks/config.js.map +1 -0
  160. package/dist/core/hooks/executor.d.ts +12 -0
  161. package/dist/core/hooks/executor.d.ts.map +1 -0
  162. package/dist/core/hooks/executor.js +708 -0
  163. package/dist/core/hooks/executor.js.map +1 -0
  164. package/dist/core/hooks/index.d.ts +9 -0
  165. package/dist/core/hooks/index.d.ts.map +1 -0
  166. package/dist/core/hooks/index.js +14 -0
  167. package/dist/core/hooks/index.js.map +1 -0
  168. package/dist/core/hooks/matcher.d.ts +10 -0
  169. package/dist/core/hooks/matcher.d.ts.map +1 -0
  170. package/dist/core/hooks/matcher.js +70 -0
  171. package/dist/core/hooks/matcher.js.map +1 -0
  172. package/dist/core/hooks/trust-store.d.ts +38 -0
  173. package/dist/core/hooks/trust-store.d.ts.map +1 -0
  174. package/dist/core/hooks/trust-store.js +167 -0
  175. package/dist/core/hooks/trust-store.js.map +1 -0
  176. package/dist/core/hooks/types.d.ts +234 -0
  177. package/dist/core/hooks/types.d.ts.map +1 -0
  178. package/dist/core/hooks/types.js +52 -0
  179. package/dist/core/hooks/types.js.map +1 -0
  180. package/dist/core/http-dispatcher.d.ts +21 -0
  181. package/dist/core/http-dispatcher.d.ts.map +1 -0
  182. package/dist/core/http-dispatcher.js +82 -0
  183. package/dist/core/http-dispatcher.js.map +1 -0
  184. package/dist/core/instruction-resource-loader.d.ts +81 -0
  185. package/dist/core/instruction-resource-loader.d.ts.map +1 -0
  186. package/dist/core/instruction-resource-loader.js +574 -0
  187. package/dist/core/instruction-resource-loader.js.map +1 -0
  188. package/dist/core/keybindings.d.ts +399 -0
  189. package/dist/core/keybindings.d.ts.map +1 -0
  190. package/dist/core/keybindings.js +299 -0
  191. package/dist/core/keybindings.js.map +1 -0
  192. package/dist/core/lsp/abort.d.ts +3 -0
  193. package/dist/core/lsp/abort.d.ts.map +1 -0
  194. package/dist/core/lsp/abort.js +28 -0
  195. package/dist/core/lsp/abort.js.map +1 -0
  196. package/dist/core/lsp/client.d.ts +108 -0
  197. package/dist/core/lsp/client.d.ts.map +1 -0
  198. package/dist/core/lsp/client.js +586 -0
  199. package/dist/core/lsp/client.js.map +1 -0
  200. package/dist/core/lsp/config-loader.d.ts +44 -0
  201. package/dist/core/lsp/config-loader.d.ts.map +1 -0
  202. package/dist/core/lsp/config-loader.js +223 -0
  203. package/dist/core/lsp/config-loader.js.map +1 -0
  204. package/dist/core/lsp/config.d.ts +134 -0
  205. package/dist/core/lsp/config.d.ts.map +1 -0
  206. package/dist/core/lsp/config.js +682 -0
  207. package/dist/core/lsp/config.js.map +1 -0
  208. package/dist/core/lsp/diagnostics.d.ts +18 -0
  209. package/dist/core/lsp/diagnostics.d.ts.map +1 -0
  210. package/dist/core/lsp/diagnostics.js +311 -0
  211. package/dist/core/lsp/diagnostics.js.map +1 -0
  212. package/dist/core/lsp/file-sync.d.ts +58 -0
  213. package/dist/core/lsp/file-sync.d.ts.map +1 -0
  214. package/dist/core/lsp/file-sync.js +432 -0
  215. package/dist/core/lsp/file-sync.js.map +1 -0
  216. package/dist/core/lsp/integration.d.ts +62 -0
  217. package/dist/core/lsp/integration.d.ts.map +1 -0
  218. package/dist/core/lsp/integration.js +145 -0
  219. package/dist/core/lsp/integration.js.map +1 -0
  220. package/dist/core/lsp/language-map.d.ts +54 -0
  221. package/dist/core/lsp/language-map.d.ts.map +1 -0
  222. package/dist/core/lsp/language-map.js +300 -0
  223. package/dist/core/lsp/language-map.js.map +1 -0
  224. package/dist/core/lsp/manager.d.ts +120 -0
  225. package/dist/core/lsp/manager.d.ts.map +1 -0
  226. package/dist/core/lsp/manager.js +636 -0
  227. package/dist/core/lsp/manager.js.map +1 -0
  228. package/dist/core/lsp/navigation.d.ts +32 -0
  229. package/dist/core/lsp/navigation.d.ts.map +1 -0
  230. package/dist/core/lsp/navigation.js +327 -0
  231. package/dist/core/lsp/navigation.js.map +1 -0
  232. package/dist/core/lsp/portable-path.d.ts +18 -0
  233. package/dist/core/lsp/portable-path.d.ts.map +1 -0
  234. package/dist/core/lsp/portable-path.js +83 -0
  235. package/dist/core/lsp/portable-path.js.map +1 -0
  236. package/dist/core/lsp/refactor.d.ts +32 -0
  237. package/dist/core/lsp/refactor.d.ts.map +1 -0
  238. package/dist/core/lsp/refactor.js +519 -0
  239. package/dist/core/lsp/refactor.js.map +1 -0
  240. package/dist/core/lsp/transport.d.ts +39 -0
  241. package/dist/core/lsp/transport.d.ts.map +1 -0
  242. package/dist/core/lsp/transport.js +261 -0
  243. package/dist/core/lsp/transport.js.map +1 -0
  244. package/dist/core/messages.d.ts +34 -0
  245. package/dist/core/messages.d.ts.map +1 -0
  246. package/dist/core/messages.js +140 -0
  247. package/dist/core/messages.js.map +1 -0
  248. package/dist/core/model-registry.d.ts +148 -0
  249. package/dist/core/model-registry.d.ts.map +1 -0
  250. package/dist/core/model-registry.js +812 -0
  251. package/dist/core/model-registry.js.map +1 -0
  252. package/dist/core/model-resolver.d.ts +115 -0
  253. package/dist/core/model-resolver.d.ts.map +1 -0
  254. package/dist/core/model-resolver.js +498 -0
  255. package/dist/core/model-resolver.js.map +1 -0
  256. package/dist/core/output-guard.d.ts +7 -0
  257. package/dist/core/output-guard.d.ts.map +1 -0
  258. package/dist/core/output-guard.js +89 -0
  259. package/dist/core/output-guard.js.map +1 -0
  260. package/dist/core/package-manager.d.ts +209 -0
  261. package/dist/core/package-manager.d.ts.map +1 -0
  262. package/dist/core/package-manager.js +2341 -0
  263. package/dist/core/package-manager.js.map +1 -0
  264. package/dist/core/prompt-templates.d.ts +57 -0
  265. package/dist/core/prompt-templates.d.ts.map +1 -0
  266. package/dist/core/prompt-templates.js +353 -0
  267. package/dist/core/prompt-templates.js.map +1 -0
  268. package/dist/core/provider-display-names.d.ts +2 -0
  269. package/dist/core/provider-display-names.d.ts.map +1 -0
  270. package/dist/core/provider-display-names.js +33 -0
  271. package/dist/core/provider-display-names.js.map +1 -0
  272. package/dist/core/remote-workspace-protocol/contract.d.ts +465 -0
  273. package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -0
  274. package/dist/core/remote-workspace-protocol/contract.js +825 -0
  275. package/dist/core/remote-workspace-protocol/contract.js.map +1 -0
  276. package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts +16 -0
  277. package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -0
  278. package/dist/core/remote-workspace-protocol/guest-shared-client.js +54 -0
  279. package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -0
  280. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts +23 -0
  281. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -0
  282. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +112 -0
  283. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -0
  284. package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts +30 -0
  285. package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -0
  286. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +243 -0
  287. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -0
  288. package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts +3 -0
  289. package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -0
  290. package/dist/core/remote-workspace-protocol/lima-owner-directory.js +31 -0
  291. package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -0
  292. package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts +9 -0
  293. package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -0
  294. package/dist/core/remote-workspace-protocol/lima-owner-lock.js +89 -0
  295. package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -0
  296. package/dist/core/remote-workspace-protocol/session.d.ts +249 -0
  297. package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -0
  298. package/dist/core/remote-workspace-protocol/session.js +1842 -0
  299. package/dist/core/remote-workspace-protocol/session.js.map +1 -0
  300. package/dist/core/remote-workspace-protocol/shared-transport.d.ts +71 -0
  301. package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -0
  302. package/dist/core/remote-workspace-protocol/shared-transport.js +68 -0
  303. package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -0
  304. package/dist/core/resolve-config-value.d.ts +32 -0
  305. package/dist/core/resolve-config-value.d.ts.map +1 -0
  306. package/dist/core/resolve-config-value.js +257 -0
  307. package/dist/core/resolve-config-value.js.map +1 -0
  308. package/dist/core/resource-loader.d.ts +200 -0
  309. package/dist/core/resource-loader.d.ts.map +1 -0
  310. package/dist/core/resource-loader.js +1209 -0
  311. package/dist/core/resource-loader.js.map +1 -0
  312. package/dist/core/rules.d.ts +40 -0
  313. package/dist/core/rules.d.ts.map +1 -0
  314. package/dist/core/rules.js +57 -0
  315. package/dist/core/rules.js.map +1 -0
  316. package/dist/core/sandbox/command.d.ts +25 -0
  317. package/dist/core/sandbox/command.d.ts.map +1 -0
  318. package/dist/core/sandbox/command.js +102 -0
  319. package/dist/core/sandbox/command.js.map +1 -0
  320. package/dist/core/sandbox/config.d.ts +91 -0
  321. package/dist/core/sandbox/config.d.ts.map +1 -0
  322. package/dist/core/sandbox/config.js +88 -0
  323. package/dist/core/sandbox/config.js.map +1 -0
  324. package/dist/core/sandbox/lima-guest-binary.d.ts +11 -0
  325. package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -0
  326. package/dist/core/sandbox/lima-guest-binary.js +140 -0
  327. package/dist/core/sandbox/lima-guest-binary.js.map +1 -0
  328. package/dist/core/sandbox/lima.d.ts +57 -0
  329. package/dist/core/sandbox/lima.d.ts.map +1 -0
  330. package/dist/core/sandbox/lima.js +716 -0
  331. package/dist/core/sandbox/lima.js.map +1 -0
  332. package/dist/core/sandbox/shared-lima-roots.d.ts +11 -0
  333. package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -0
  334. package/dist/core/sandbox/shared-lima-roots.js +25 -0
  335. package/dist/core/sandbox/shared-lima-roots.js.map +1 -0
  336. package/dist/core/sandbox/update-shared-guest-binary.d.ts +8 -0
  337. package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -0
  338. package/dist/core/sandbox/update-shared-guest-binary.js +100 -0
  339. package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -0
  340. package/dist/core/session/constants.d.ts +2 -0
  341. package/dist/core/session/constants.d.ts.map +1 -0
  342. package/dist/core/session/constants.js +2 -0
  343. package/dist/core/session/constants.js.map +1 -0
  344. package/dist/core/session/context-metadata.d.ts +5 -0
  345. package/dist/core/session/context-metadata.d.ts.map +1 -0
  346. package/dist/core/session/context-metadata.js +55 -0
  347. package/dist/core/session/context-metadata.js.map +1 -0
  348. package/dist/core/session/context.d.ts +14 -0
  349. package/dist/core/session/context.d.ts.map +1 -0
  350. package/dist/core/session/context.js +117 -0
  351. package/dist/core/session/context.js.map +1 -0
  352. package/dist/core/session/ids.d.ts +9 -0
  353. package/dist/core/session/ids.d.ts.map +1 -0
  354. package/dist/core/session/ids.js +21 -0
  355. package/dist/core/session/ids.js.map +1 -0
  356. package/dist/core/session/in-memory-session-manager.d.ts +17 -0
  357. package/dist/core/session/in-memory-session-manager.d.ts.map +1 -0
  358. package/dist/core/session/in-memory-session-manager.js +40 -0
  359. package/dist/core/session/in-memory-session-manager.js.map +1 -0
  360. package/dist/core/session/in-memory-session.d.ts +7 -0
  361. package/dist/core/session/in-memory-session.d.ts.map +1 -0
  362. package/dist/core/session/in-memory-session.js +11 -0
  363. package/dist/core/session/in-memory-session.js.map +1 -0
  364. package/dist/core/session/jsonl-errors.d.ts +36 -0
  365. package/dist/core/session/jsonl-errors.d.ts.map +1 -0
  366. package/dist/core/session/jsonl-errors.js +49 -0
  367. package/dist/core/session/jsonl-errors.js.map +1 -0
  368. package/dist/core/session/jsonl-helpers.d.ts +20 -0
  369. package/dist/core/session/jsonl-helpers.d.ts.map +1 -0
  370. package/dist/core/session/jsonl-helpers.js +21 -0
  371. package/dist/core/session/jsonl-helpers.js.map +1 -0
  372. package/dist/core/session/local-session-manager.d.ts +30 -0
  373. package/dist/core/session/local-session-manager.d.ts.map +1 -0
  374. package/dist/core/session/local-session-manager.js +205 -0
  375. package/dist/core/session/local-session-manager.js.map +1 -0
  376. package/dist/core/session/local-session.d.ts +9 -0
  377. package/dist/core/session/local-session.d.ts.map +1 -0
  378. package/dist/core/session/local-session.js +15 -0
  379. package/dist/core/session/local-session.js.map +1 -0
  380. package/dist/core/session/migrations.d.ts +11 -0
  381. package/dist/core/session/migrations.d.ts.map +1 -0
  382. package/dist/core/session/migrations.js +78 -0
  383. package/dist/core/session/migrations.js.map +1 -0
  384. package/dist/core/session/remote-session-client.d.ts +83 -0
  385. package/dist/core/session/remote-session-client.d.ts.map +1 -0
  386. package/dist/core/session/remote-session-client.js +224 -0
  387. package/dist/core/session/remote-session-client.js.map +1 -0
  388. package/dist/core/session/remote-session-manager.d.ts +32 -0
  389. package/dist/core/session/remote-session-manager.d.ts.map +1 -0
  390. package/dist/core/session/remote-session-manager.js +124 -0
  391. package/dist/core/session/remote-session-manager.js.map +1 -0
  392. package/dist/core/session/remote-session.d.ts +20 -0
  393. package/dist/core/session/remote-session.d.ts.map +1 -0
  394. package/dist/core/session/remote-session.js +33 -0
  395. package/dist/core/session/remote-session.js.map +1 -0
  396. package/dist/core/session/session-manager.d.ts +18 -0
  397. package/dist/core/session/session-manager.d.ts.map +1 -0
  398. package/dist/core/session/session-manager.js +2 -0
  399. package/dist/core/session/session-manager.js.map +1 -0
  400. package/dist/core/session/session.d.ts +140 -0
  401. package/dist/core/session/session.d.ts.map +1 -0
  402. package/dist/core/session/session.js +461 -0
  403. package/dist/core/session/session.js.map +1 -0
  404. package/dist/core/session/stores/in-memory-session-store.d.ts +39 -0
  405. package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -0
  406. package/dist/core/session/stores/in-memory-session-store.js +168 -0
  407. package/dist/core/session/stores/in-memory-session-store.js.map +1 -0
  408. package/dist/core/session/stores/jsonl-session-store.d.ts +97 -0
  409. package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -0
  410. package/dist/core/session/stores/jsonl-session-store.js +1140 -0
  411. package/dist/core/session/stores/jsonl-session-store.js.map +1 -0
  412. package/dist/core/session/stores/remote-session-store.d.ts +44 -0
  413. package/dist/core/session/stores/remote-session-store.d.ts.map +1 -0
  414. package/dist/core/session/stores/remote-session-store.js +159 -0
  415. package/dist/core/session/stores/remote-session-store.js.map +1 -0
  416. package/dist/core/session/stores/session-store.d.ts +42 -0
  417. package/dist/core/session/stores/session-store.d.ts.map +1 -0
  418. package/dist/core/session/stores/session-store.js +2 -0
  419. package/dist/core/session/stores/session-store.js.map +1 -0
  420. package/dist/core/session/types.d.ts +141 -0
  421. package/dist/core/session/types.d.ts.map +1 -0
  422. package/dist/core/session/types.js +2 -0
  423. package/dist/core/session/types.js.map +1 -0
  424. package/dist/core/session/usage-ledger.d.ts +18 -0
  425. package/dist/core/session/usage-ledger.d.ts.map +1 -0
  426. package/dist/core/session/usage-ledger.js +68 -0
  427. package/dist/core/session/usage-ledger.js.map +1 -0
  428. package/dist/core/session-cwd.d.ts +19 -0
  429. package/dist/core/session-cwd.d.ts.map +1 -0
  430. package/dist/core/session-cwd.js +38 -0
  431. package/dist/core/session-cwd.js.map +1 -0
  432. package/dist/core/settings-manager.d.ts +314 -0
  433. package/dist/core/settings-manager.d.ts.map +1 -0
  434. package/dist/core/settings-manager.js +991 -0
  435. package/dist/core/settings-manager.js.map +1 -0
  436. package/dist/core/skills.d.ts +40 -0
  437. package/dist/core/skills.d.ts.map +1 -0
  438. package/dist/core/skills.js +57 -0
  439. package/dist/core/skills.js.map +1 -0
  440. package/dist/core/slash-commands.d.ts +15 -0
  441. package/dist/core/slash-commands.d.ts.map +1 -0
  442. package/dist/core/slash-commands.js +36 -0
  443. package/dist/core/slash-commands.js.map +1 -0
  444. package/dist/core/source-info.d.ts +26 -0
  445. package/dist/core/source-info.d.ts.map +1 -0
  446. package/dist/core/source-info.js +27 -0
  447. package/dist/core/source-info.js.map +1 -0
  448. package/dist/core/system-prompt.d.ts +32 -0
  449. package/dist/core/system-prompt.d.ts.map +1 -0
  450. package/dist/core/system-prompt.js +131 -0
  451. package/dist/core/system-prompt.js.map +1 -0
  452. package/dist/core/telemetry.d.ts +3 -0
  453. package/dist/core/telemetry.d.ts.map +1 -0
  454. package/dist/core/telemetry.js +9 -0
  455. package/dist/core/telemetry.js.map +1 -0
  456. package/dist/core/timings.d.ts +10 -0
  457. package/dist/core/timings.d.ts.map +1 -0
  458. package/dist/core/timings.js +41 -0
  459. package/dist/core/timings.js.map +1 -0
  460. package/dist/core/tools/bash.d.ts +51 -0
  461. package/dist/core/tools/bash.d.ts.map +1 -0
  462. package/dist/core/tools/bash.js +321 -0
  463. package/dist/core/tools/bash.js.map +1 -0
  464. package/dist/core/tools/compress-context.d.ts +27 -0
  465. package/dist/core/tools/compress-context.d.ts.map +1 -0
  466. package/dist/core/tools/compress-context.js +142 -0
  467. package/dist/core/tools/compress-context.js.map +1 -0
  468. package/dist/core/tools/edit-diff.d.ts +82 -0
  469. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  470. package/dist/core/tools/edit-diff.js +327 -0
  471. package/dist/core/tools/edit-diff.js.map +1 -0
  472. package/dist/core/tools/edit.d.ts +50 -0
  473. package/dist/core/tools/edit.d.ts.map +1 -0
  474. package/dist/core/tools/edit.js +324 -0
  475. package/dist/core/tools/edit.js.map +1 -0
  476. package/dist/core/tools/file-mutation-queue.d.ts +8 -0
  477. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  478. package/dist/core/tools/file-mutation-queue.js +69 -0
  479. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  480. package/dist/core/tools/find.d.ts +22 -0
  481. package/dist/core/tools/find.d.ts.map +1 -0
  482. package/dist/core/tools/find.js +268 -0
  483. package/dist/core/tools/find.js.map +1 -0
  484. package/dist/core/tools/grep.d.ts +27 -0
  485. package/dist/core/tools/grep.d.ts.map +1 -0
  486. package/dist/core/tools/grep.js +332 -0
  487. package/dist/core/tools/grep.js.map +1 -0
  488. package/dist/core/tools/hash-store.d.ts +12 -0
  489. package/dist/core/tools/hash-store.d.ts.map +1 -0
  490. package/dist/core/tools/hash-store.js +48 -0
  491. package/dist/core/tools/hash-store.js.map +1 -0
  492. package/dist/core/tools/hashline/apply.d.ts +40 -0
  493. package/dist/core/tools/hashline/apply.d.ts.map +1 -0
  494. package/dist/core/tools/hashline/apply.js +261 -0
  495. package/dist/core/tools/hashline/apply.js.map +1 -0
  496. package/dist/core/tools/hashline/hash.d.ts +56 -0
  497. package/dist/core/tools/hashline/hash.d.ts.map +1 -0
  498. package/dist/core/tools/hashline/hash.js +196 -0
  499. package/dist/core/tools/hashline/hash.js.map +1 -0
  500. package/dist/core/tools/hashline/parse.d.ts +8 -0
  501. package/dist/core/tools/hashline/parse.d.ts.map +1 -0
  502. package/dist/core/tools/hashline/parse.js +41 -0
  503. package/dist/core/tools/hashline/parse.js.map +1 -0
  504. package/dist/core/tools/hashline/resolve.d.ts +51 -0
  505. package/dist/core/tools/hashline/resolve.d.ts.map +1 -0
  506. package/dist/core/tools/hashline/resolve.js +187 -0
  507. package/dist/core/tools/hashline/resolve.js.map +1 -0
  508. package/dist/core/tools/hashline-utils.d.ts +6 -0
  509. package/dist/core/tools/hashline-utils.d.ts.map +1 -0
  510. package/dist/core/tools/hashline-utils.js +23 -0
  511. package/dist/core/tools/hashline-utils.js.map +1 -0
  512. package/dist/core/tools/index.d.ts +36 -0
  513. package/dist/core/tools/index.d.ts.map +1 -0
  514. package/dist/core/tools/index.js +141 -0
  515. package/dist/core/tools/index.js.map +1 -0
  516. package/dist/core/tools/ls.d.ts +21 -0
  517. package/dist/core/tools/ls.d.ts.map +1 -0
  518. package/dist/core/tools/ls.js +156 -0
  519. package/dist/core/tools/ls.js.map +1 -0
  520. package/dist/core/tools/operations.d.ts +212 -0
  521. package/dist/core/tools/operations.d.ts.map +1 -0
  522. package/dist/core/tools/operations.js +793 -0
  523. package/dist/core/tools/operations.js.map +1 -0
  524. package/dist/core/tools/output-accumulator.d.ts +54 -0
  525. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  526. package/dist/core/tools/output-accumulator.js +184 -0
  527. package/dist/core/tools/output-accumulator.js.map +1 -0
  528. package/dist/core/tools/path-utils.d.ts +9 -0
  529. package/dist/core/tools/path-utils.d.ts.map +1 -0
  530. package/dist/core/tools/path-utils.js +99 -0
  531. package/dist/core/tools/path-utils.js.map +1 -0
  532. package/dist/core/tools/read.d.ts +32 -0
  533. package/dist/core/tools/read.d.ts.map +1 -0
  534. package/dist/core/tools/read.js +318 -0
  535. package/dist/core/tools/read.js.map +1 -0
  536. package/dist/core/tools/render-utils.d.ts +33 -0
  537. package/dist/core/tools/render-utils.d.ts.map +1 -0
  538. package/dist/core/tools/render-utils.js +61 -0
  539. package/dist/core/tools/render-utils.js.map +1 -0
  540. package/dist/core/tools/replace-diff.d.ts +16 -0
  541. package/dist/core/tools/replace-diff.d.ts.map +1 -0
  542. package/dist/core/tools/replace-diff.js +117 -0
  543. package/dist/core/tools/replace-diff.js.map +1 -0
  544. package/dist/core/tools/replace-normalize.d.ts +2 -0
  545. package/dist/core/tools/replace-normalize.d.ts.map +1 -0
  546. package/dist/core/tools/replace-normalize.js +73 -0
  547. package/dist/core/tools/replace-normalize.js.map +1 -0
  548. package/dist/core/tools/replace-render.d.ts +51 -0
  549. package/dist/core/tools/replace-render.d.ts.map +1 -0
  550. package/dist/core/tools/replace-render.js +162 -0
  551. package/dist/core/tools/replace-render.js.map +1 -0
  552. package/dist/core/tools/runtime.d.ts +2 -0
  553. package/dist/core/tools/runtime.d.ts.map +1 -0
  554. package/dist/core/tools/runtime.js +6 -0
  555. package/dist/core/tools/runtime.js.map +1 -0
  556. package/dist/core/tools/session-history.d.ts +55 -0
  557. package/dist/core/tools/session-history.d.ts.map +1 -0
  558. package/dist/core/tools/session-history.js +649 -0
  559. package/dist/core/tools/session-history.js.map +1 -0
  560. package/dist/core/tools/subagent-agents.d.ts +29 -0
  561. package/dist/core/tools/subagent-agents.d.ts.map +1 -0
  562. package/dist/core/tools/subagent-agents.js +223 -0
  563. package/dist/core/tools/subagent-agents.js.map +1 -0
  564. package/dist/core/tools/subagent.d.ts +185 -0
  565. package/dist/core/tools/subagent.d.ts.map +1 -0
  566. package/dist/core/tools/subagent.js +1309 -0
  567. package/dist/core/tools/subagent.js.map +1 -0
  568. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  569. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  570. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  571. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  572. package/dist/core/tools/truncate.d.ts +39 -0
  573. package/dist/core/tools/truncate.d.ts.map +1 -0
  574. package/dist/core/tools/truncate.js +215 -0
  575. package/dist/core/tools/truncate.js.map +1 -0
  576. package/dist/core/tools/websearch.d.ts +33 -0
  577. package/dist/core/tools/websearch.d.ts.map +1 -0
  578. package/dist/core/tools/websearch.js +341 -0
  579. package/dist/core/tools/websearch.js.map +1 -0
  580. package/dist/core/tools/workspace-tool-host.d.ts +102 -0
  581. package/dist/core/tools/workspace-tool-host.d.ts.map +1 -0
  582. package/dist/core/tools/workspace-tool-host.js +348 -0
  583. package/dist/core/tools/workspace-tool-host.js.map +1 -0
  584. package/dist/core/tools/write.d.ts +16 -0
  585. package/dist/core/tools/write.d.ts.map +1 -0
  586. package/dist/core/tools/write.js +204 -0
  587. package/dist/core/tools/write.js.map +1 -0
  588. package/dist/core/workspace-identity.d.ts +7 -0
  589. package/dist/core/workspace-identity.d.ts.map +1 -0
  590. package/dist/core/workspace-identity.js +2 -0
  591. package/dist/core/workspace-identity.js.map +1 -0
  592. package/dist/daemon/activity-budget.d.ts +10 -0
  593. package/dist/daemon/activity-budget.d.ts.map +1 -0
  594. package/dist/daemon/activity-budget.js +34 -0
  595. package/dist/daemon/activity-budget.js.map +1 -0
  596. package/dist/daemon/command.d.ts +6 -0
  597. package/dist/daemon/command.d.ts.map +1 -0
  598. package/dist/daemon/command.js +58 -0
  599. package/dist/daemon/command.js.map +1 -0
  600. package/dist/daemon/config.d.ts +45 -0
  601. package/dist/daemon/config.d.ts.map +1 -0
  602. package/dist/daemon/config.js +319 -0
  603. package/dist/daemon/config.js.map +1 -0
  604. package/dist/daemon/help.d.ts +2 -0
  605. package/dist/daemon/help.d.ts.map +1 -0
  606. package/dist/daemon/help.js +42 -0
  607. package/dist/daemon/help.js.map +1 -0
  608. package/dist/daemon/lsp-config.d.ts +4 -0
  609. package/dist/daemon/lsp-config.d.ts.map +1 -0
  610. package/dist/daemon/lsp-config.js +155 -0
  611. package/dist/daemon/lsp-config.js.map +1 -0
  612. package/dist/daemon/outbound-budget.d.ts +10 -0
  613. package/dist/daemon/outbound-budget.d.ts.map +1 -0
  614. package/dist/daemon/outbound-budget.js +30 -0
  615. package/dist/daemon/outbound-budget.js.map +1 -0
  616. package/dist/daemon/security.d.ts +19 -0
  617. package/dist/daemon/security.d.ts.map +1 -0
  618. package/dist/daemon/security.js +177 -0
  619. package/dist/daemon/security.js.map +1 -0
  620. package/dist/daemon/server.d.ts +20 -0
  621. package/dist/daemon/server.d.ts.map +1 -0
  622. package/dist/daemon/server.js +480 -0
  623. package/dist/daemon/server.js.map +1 -0
  624. package/dist/daemon/shared-connection.d.ts +33 -0
  625. package/dist/daemon/shared-connection.d.ts.map +1 -0
  626. package/dist/daemon/shared-connection.js +271 -0
  627. package/dist/daemon/shared-connection.js.map +1 -0
  628. package/dist/daemon/shared-revision.d.ts +5 -0
  629. package/dist/daemon/shared-revision.d.ts.map +1 -0
  630. package/dist/daemon/shared-revision.js +61 -0
  631. package/dist/daemon/shared-revision.js.map +1 -0
  632. package/dist/daemon/shared-roots.d.ts +9 -0
  633. package/dist/daemon/shared-roots.d.ts.map +1 -0
  634. package/dist/daemon/shared-roots.js +33 -0
  635. package/dist/daemon/shared-roots.js.map +1 -0
  636. package/dist/daemon/workspace-runtime.d.ts +46 -0
  637. package/dist/daemon/workspace-runtime.d.ts.map +1 -0
  638. package/dist/daemon/workspace-runtime.js +705 -0
  639. package/dist/daemon/workspace-runtime.js.map +1 -0
  640. package/dist/index.d.ts +109 -0
  641. package/dist/index.d.ts.map +1 -0
  642. package/dist/index.js +107 -0
  643. package/dist/index.js.map +1 -0
  644. package/dist/main.d.ts +39 -0
  645. package/dist/main.d.ts.map +1 -0
  646. package/dist/main.js +765 -0
  647. package/dist/main.js.map +1 -0
  648. package/dist/migrations.d.ts +35 -0
  649. package/dist/migrations.d.ts.map +1 -0
  650. package/dist/migrations.js +412 -0
  651. package/dist/migrations.js.map +1 -0
  652. package/dist/modes/interactive/components/assistant-message.d.ts +30 -0
  653. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  654. package/dist/modes/interactive/components/assistant-message.js +159 -0
  655. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  656. package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
  657. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  658. package/dist/modes/interactive/components/bash-execution.js +173 -0
  659. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  660. package/dist/modes/interactive/components/bordered-loader.d.ts +18 -0
  661. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  662. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  663. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  664. package/dist/modes/interactive/components/branch-summary-message.d.ts +17 -0
  665. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  666. package/dist/modes/interactive/components/branch-summary-message.js +45 -0
  667. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  668. package/dist/modes/interactive/components/compaction-summary-message.d.ts +17 -0
  669. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  670. package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
  671. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  672. package/dist/modes/interactive/components/config-selector.d.ts +74 -0
  673. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  674. package/dist/modes/interactive/components/config-selector.js +514 -0
  675. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  676. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  677. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  678. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  679. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  680. package/dist/modes/interactive/components/custom-editor.d.ts +25 -0
  681. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  682. package/dist/modes/interactive/components/custom-editor.js +85 -0
  683. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  684. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  685. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  686. package/dist/modes/interactive/components/custom-message.js +81 -0
  687. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  688. package/dist/modes/interactive/components/diff.d.ts +12 -0
  689. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  690. package/dist/modes/interactive/components/diff.js +118 -0
  691. package/dist/modes/interactive/components/diff.js.map +1 -0
  692. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  693. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  694. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  695. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  696. package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
  697. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  698. package/dist/modes/interactive/components/extension-editor.js +128 -0
  699. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  700. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  701. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  702. package/dist/modes/interactive/components/extension-input.js +61 -0
  703. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  704. package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
  705. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  706. package/dist/modes/interactive/components/extension-selector.js +83 -0
  707. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  708. package/dist/modes/interactive/components/footer.d.ts +36 -0
  709. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  710. package/dist/modes/interactive/components/footer.js +227 -0
  711. package/dist/modes/interactive/components/footer.js.map +1 -0
  712. package/dist/modes/interactive/components/hook-execution.d.ts +19 -0
  713. package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -0
  714. package/dist/modes/interactive/components/hook-execution.js +185 -0
  715. package/dist/modes/interactive/components/hook-execution.js.map +1 -0
  716. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  717. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  718. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  719. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  720. package/dist/modes/interactive/components/login-dialog.d.ts +55 -0
  721. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  722. package/dist/modes/interactive/components/login-dialog.js +176 -0
  723. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  724. package/dist/modes/interactive/components/markdown-transform.d.ts +4 -0
  725. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  726. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  727. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  728. package/dist/modes/interactive/components/mermaid.d.ts +14 -0
  729. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
  730. package/dist/modes/interactive/components/mermaid.js +228 -0
  731. package/dist/modes/interactive/components/mermaid.js.map +1 -0
  732. package/dist/modes/interactive/components/message-card.d.ts +9 -0
  733. package/dist/modes/interactive/components/message-card.d.ts.map +1 -0
  734. package/dist/modes/interactive/components/message-card.js +24 -0
  735. package/dist/modes/interactive/components/message-card.js.map +1 -0
  736. package/dist/modes/interactive/components/model-selector.d.ts +52 -0
  737. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  738. package/dist/modes/interactive/components/model-selector.js +296 -0
  739. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  740. package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
  741. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  742. package/dist/modes/interactive/components/oauth-selector.js +165 -0
  743. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  744. package/dist/modes/interactive/components/scoped-models-selector.d.ts +50 -0
  745. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  746. package/dist/modes/interactive/components/scoped-models-selector.js +300 -0
  747. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  748. package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
  749. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  750. package/dist/modes/interactive/components/session-selector-search.js +144 -0
  751. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  752. package/dist/modes/interactive/components/session-selector.d.ts +108 -0
  753. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  754. package/dist/modes/interactive/components/session-selector.js +835 -0
  755. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  756. package/dist/modes/interactive/components/settings-selector.d.ts +81 -0
  757. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  758. package/dist/modes/interactive/components/settings-selector.js +455 -0
  759. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  760. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  761. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  762. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  763. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  764. package/dist/modes/interactive/components/skill-invocation-message.d.ts +18 -0
  765. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  766. package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
  767. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  768. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  769. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  770. package/dist/modes/interactive/components/theme-selector.js +50 -0
  771. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  772. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  773. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  774. package/dist/modes/interactive/components/thinking-selector.js +51 -0
  775. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  776. package/dist/modes/interactive/components/tool-execution.d.ts +67 -0
  777. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  778. package/dist/modes/interactive/components/tool-execution.js +312 -0
  779. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  780. package/dist/modes/interactive/components/tree-selector.d.ts +127 -0
  781. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  782. package/dist/modes/interactive/components/tree-selector.js +1098 -0
  783. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  784. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  785. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  786. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  787. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  788. package/dist/modes/interactive/components/user-message.d.ts +16 -0
  789. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  790. package/dist/modes/interactive/components/user-message.js +50 -0
  791. package/dist/modes/interactive/components/user-message.js.map +1 -0
  792. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  793. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  794. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  795. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  796. package/dist/modes/interactive/interactive-mode.d.ts +554 -0
  797. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  798. package/dist/modes/interactive/interactive-mode.js +5870 -0
  799. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  800. package/dist/modes/interactive/theme/dark.json +86 -0
  801. package/dist/modes/interactive/theme/light.json +85 -0
  802. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  803. package/dist/modes/interactive/theme/theme.d.ts +109 -0
  804. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  805. package/dist/modes/interactive/theme/theme.js +1040 -0
  806. package/dist/modes/interactive/theme/theme.js.map +1 -0
  807. package/dist/modes/json-event.d.ts +28 -0
  808. package/dist/modes/json-event.d.ts.map +1 -0
  809. package/dist/modes/json-event.js +12 -0
  810. package/dist/modes/json-event.js.map +1 -0
  811. package/dist/modes/print-mode.d.ts +29 -0
  812. package/dist/modes/print-mode.d.ts.map +1 -0
  813. package/dist/modes/print-mode.js +142 -0
  814. package/dist/modes/print-mode.js.map +1 -0
  815. package/dist/modes/rpc/jsonl.d.ts +17 -0
  816. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  817. package/dist/modes/rpc/jsonl.js +49 -0
  818. package/dist/modes/rpc/jsonl.js.map +1 -0
  819. package/dist/modes/rpc/rpc-client.d.ts +321 -0
  820. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  821. package/dist/modes/rpc/rpc-client.js +755 -0
  822. package/dist/modes/rpc/rpc-client.js.map +1 -0
  823. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  824. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  825. package/dist/modes/rpc/rpc-mode.js +963 -0
  826. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  827. package/dist/modes/rpc/rpc-types.d.ts +652 -0
  828. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  829. package/dist/modes/rpc/rpc-types.js +8 -0
  830. package/dist/modes/rpc/rpc-types.js.map +1 -0
  831. package/dist/package-manager-cli.d.ts +4 -0
  832. package/dist/package-manager-cli.d.ts.map +1 -0
  833. package/dist/package-manager-cli.js +488 -0
  834. package/dist/package-manager-cli.js.map +1 -0
  835. package/dist/utils/ansi.d.ts +2 -0
  836. package/dist/utils/ansi.d.ts.map +1 -0
  837. package/dist/utils/ansi.js +25 -0
  838. package/dist/utils/ansi.js.map +1 -0
  839. package/dist/utils/changelog.d.ts +23 -0
  840. package/dist/utils/changelog.d.ts.map +1 -0
  841. package/dist/utils/changelog.js +74 -0
  842. package/dist/utils/changelog.js.map +1 -0
  843. package/dist/utils/child-process.d.ts +15 -0
  844. package/dist/utils/child-process.d.ts.map +1 -0
  845. package/dist/utils/child-process.js +88 -0
  846. package/dist/utils/child-process.js.map +1 -0
  847. package/dist/utils/clipboard-image.d.ts +13 -0
  848. package/dist/utils/clipboard-image.d.ts.map +1 -0
  849. package/dist/utils/clipboard-image.js +248 -0
  850. package/dist/utils/clipboard-image.js.map +1 -0
  851. package/dist/utils/clipboard-native.d.ts +11 -0
  852. package/dist/utils/clipboard-native.d.ts.map +1 -0
  853. package/dist/utils/clipboard-native.js +20 -0
  854. package/dist/utils/clipboard-native.js.map +1 -0
  855. package/dist/utils/clipboard.d.ts +4 -0
  856. package/dist/utils/clipboard.d.ts.map +1 -0
  857. package/dist/utils/clipboard.js +171 -0
  858. package/dist/utils/clipboard.js.map +1 -0
  859. package/dist/utils/deprecation.d.ts +4 -0
  860. package/dist/utils/deprecation.d.ts.map +1 -0
  861. package/dist/utils/deprecation.js +13 -0
  862. package/dist/utils/deprecation.js.map +1 -0
  863. package/dist/utils/directory-completions.d.ts +5 -0
  864. package/dist/utils/directory-completions.d.ts.map +1 -0
  865. package/dist/utils/directory-completions.js +64 -0
  866. package/dist/utils/directory-completions.js.map +1 -0
  867. package/dist/utils/exif-orientation.d.ts +6 -0
  868. package/dist/utils/exif-orientation.d.ts.map +1 -0
  869. package/dist/utils/exif-orientation.js +166 -0
  870. package/dist/utils/exif-orientation.js.map +1 -0
  871. package/dist/utils/frontmatter.d.ts +8 -0
  872. package/dist/utils/frontmatter.d.ts.map +1 -0
  873. package/dist/utils/frontmatter.js +26 -0
  874. package/dist/utils/frontmatter.js.map +1 -0
  875. package/dist/utils/fs-watch.d.ts +5 -0
  876. package/dist/utils/fs-watch.d.ts.map +1 -0
  877. package/dist/utils/fs-watch.js +25 -0
  878. package/dist/utils/fs-watch.js.map +1 -0
  879. package/dist/utils/git.d.ts +27 -0
  880. package/dist/utils/git.d.ts.map +1 -0
  881. package/dist/utils/git.js +237 -0
  882. package/dist/utils/git.js.map +1 -0
  883. package/dist/utils/grip-user-agent.d.ts +2 -0
  884. package/dist/utils/grip-user-agent.d.ts.map +1 -0
  885. package/dist/utils/grip-user-agent.js +5 -0
  886. package/dist/utils/grip-user-agent.js.map +1 -0
  887. package/dist/utils/html.d.ts +7 -0
  888. package/dist/utils/html.d.ts.map +1 -0
  889. package/dist/utils/html.js +40 -0
  890. package/dist/utils/html.js.map +1 -0
  891. package/dist/utils/image-convert.d.ts +12 -0
  892. package/dist/utils/image-convert.d.ts.map +1 -0
  893. package/dist/utils/image-convert.js +43 -0
  894. package/dist/utils/image-convert.js.map +1 -0
  895. package/dist/utils/image-process.d.ts +18 -0
  896. package/dist/utils/image-process.d.ts.map +1 -0
  897. package/dist/utils/image-process.js +83 -0
  898. package/dist/utils/image-process.js.map +1 -0
  899. package/dist/utils/image-resize-core.d.ts +30 -0
  900. package/dist/utils/image-resize-core.d.ts.map +1 -0
  901. package/dist/utils/image-resize-core.js +133 -0
  902. package/dist/utils/image-resize-core.js.map +1 -0
  903. package/dist/utils/image-resize-worker.d.ts +2 -0
  904. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  905. package/dist/utils/image-resize-worker.js +31 -0
  906. package/dist/utils/image-resize-worker.js.map +1 -0
  907. package/dist/utils/image-resize.d.ts +19 -0
  908. package/dist/utils/image-resize.d.ts.map +1 -0
  909. package/dist/utils/image-resize.js +86 -0
  910. package/dist/utils/image-resize.js.map +1 -0
  911. package/dist/utils/json.d.ts +3 -0
  912. package/dist/utils/json.d.ts.map +1 -0
  913. package/dist/utils/json.js +7 -0
  914. package/dist/utils/json.js.map +1 -0
  915. package/dist/utils/mime.d.ts +3 -0
  916. package/dist/utils/mime.d.ts.map +1 -0
  917. package/dist/utils/mime.js +110 -0
  918. package/dist/utils/mime.js.map +1 -0
  919. package/dist/utils/open-browser.d.ts +9 -0
  920. package/dist/utils/open-browser.d.ts.map +1 -0
  921. package/dist/utils/open-browser.js +22 -0
  922. package/dist/utils/open-browser.js.map +1 -0
  923. package/dist/utils/paths.d.ts +31 -0
  924. package/dist/utils/paths.d.ts.map +1 -0
  925. package/dist/utils/paths.js +87 -0
  926. package/dist/utils/paths.js.map +1 -0
  927. package/dist/utils/photon.d.ts +22 -0
  928. package/dist/utils/photon.d.ts.map +1 -0
  929. package/dist/utils/photon.js +126 -0
  930. package/dist/utils/photon.js.map +1 -0
  931. package/dist/utils/shell.d.ts +28 -0
  932. package/dist/utils/shell.d.ts.map +1 -0
  933. package/dist/utils/shell.js +188 -0
  934. package/dist/utils/shell.js.map +1 -0
  935. package/dist/utils/sleep.d.ts +5 -0
  936. package/dist/utils/sleep.d.ts.map +1 -0
  937. package/dist/utils/sleep.js +17 -0
  938. package/dist/utils/sleep.js.map +1 -0
  939. package/dist/utils/syntax-highlight.d.ts +12 -0
  940. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  941. package/dist/utils/syntax-highlight.js +125 -0
  942. package/dist/utils/syntax-highlight.js.map +1 -0
  943. package/dist/utils/tools-manager.d.ts +5 -0
  944. package/dist/utils/tools-manager.d.ts.map +1 -0
  945. package/dist/utils/tools-manager.js +329 -0
  946. package/dist/utils/tools-manager.js.map +1 -0
  947. package/dist/utils/version-check.d.ts +14 -0
  948. package/dist/utils/version-check.d.ts.map +1 -0
  949. package/dist/utils/version-check.js +91 -0
  950. package/dist/utils/version-check.js.map +1 -0
  951. package/dist/utils/windows-self-update.d.ts +3 -0
  952. package/dist/utils/windows-self-update.d.ts.map +1 -0
  953. package/dist/utils/windows-self-update.js +77 -0
  954. package/dist/utils/windows-self-update.js.map +1 -0
  955. package/docs/compaction.md +408 -0
  956. package/docs/custom-provider.md +714 -0
  957. package/docs/daemon-architecture.md +399 -0
  958. package/docs/daemon.md +112 -0
  959. package/docs/development.md +72 -0
  960. package/docs/docs.json +164 -0
  961. package/docs/extensions.md +2745 -0
  962. package/docs/hooks.md +85 -0
  963. package/docs/images/doom-extension.png +0 -0
  964. package/docs/images/exy.png +0 -0
  965. package/docs/images/interactive-mode.png +0 -0
  966. package/docs/images/tree-view.png +0 -0
  967. package/docs/index.md +77 -0
  968. package/docs/json.md +89 -0
  969. package/docs/keybindings.md +230 -0
  970. package/docs/lsp.md +499 -0
  971. package/docs/migrating-to-grip.md +18 -0
  972. package/docs/models.md +496 -0
  973. package/docs/packages.md +228 -0
  974. package/docs/prompt-templates.md +88 -0
  975. package/docs/providers.md +251 -0
  976. package/docs/quickstart.md +159 -0
  977. package/docs/rpc.md +1492 -0
  978. package/docs/rules.md +117 -0
  979. package/docs/sandbox.md +104 -0
  980. package/docs/sdk.md +360 -0
  981. package/docs/session-format.md +414 -0
  982. package/docs/sessions.md +137 -0
  983. package/docs/settings.md +372 -0
  984. package/docs/shell-aliases.md +13 -0
  985. package/docs/skills.md +246 -0
  986. package/docs/terminal-setup.md +112 -0
  987. package/docs/termux.md +112 -0
  988. package/docs/themes.md +295 -0
  989. package/docs/tmux.md +61 -0
  990. package/docs/tui.md +918 -0
  991. package/docs/usage.md +304 -0
  992. package/docs/windows.md +17 -0
  993. package/examples/README.md +29 -0
  994. package/examples/daemon-docker/Dockerfile +43 -0
  995. package/examples/daemon-docker/README.md +45 -0
  996. package/examples/extensions/README.md +208 -0
  997. package/examples/extensions/auto-commit-on-exit.ts +46 -0
  998. package/examples/extensions/bash-spawn-hook.ts +30 -0
  999. package/examples/extensions/bookmark.ts +50 -0
  1000. package/examples/extensions/border-status-editor.ts +145 -0
  1001. package/examples/extensions/built-in-tool-renderer.ts +259 -0
  1002. package/examples/extensions/claude-rules.ts +86 -0
  1003. package/examples/extensions/commands.ts +82 -0
  1004. package/examples/extensions/confirm-destructive.ts +59 -0
  1005. package/examples/extensions/custom-compaction.ts +131 -0
  1006. package/examples/extensions/custom-footer.ts +79 -0
  1007. package/examples/extensions/custom-header.ts +73 -0
  1008. package/examples/extensions/custom-provider-anthropic/index.ts +707 -0
  1009. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  1010. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  1011. package/examples/extensions/custom-provider-gitlab-duo/index.ts +402 -0
  1012. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  1013. package/examples/extensions/custom-provider-gitlab-duo/test.ts +104 -0
  1014. package/examples/extensions/dirty-repo-guard.ts +59 -0
  1015. package/examples/extensions/doom-overlay/README.md +46 -0
  1016. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  1017. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  1018. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  1019. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  1020. package/examples/extensions/doom-overlay/doom-component.ts +133 -0
  1021. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  1022. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  1023. package/examples/extensions/doom-overlay/index.ts +74 -0
  1024. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  1025. package/examples/extensions/dynamic-resources/RULES.md +8 -0
  1026. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  1027. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  1028. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  1029. package/examples/extensions/dynamic-resources/index.ts +16 -0
  1030. package/examples/extensions/dynamic-tools.ts +74 -0
  1031. package/examples/extensions/event-bus.ts +43 -0
  1032. package/examples/extensions/file-trigger.ts +41 -0
  1033. package/examples/extensions/git-checkpoint.ts +53 -0
  1034. package/examples/extensions/git-merge-and-resolve.ts +125 -0
  1035. package/examples/extensions/github-issue-autocomplete.ts +191 -0
  1036. package/examples/extensions/handoff.ts +191 -0
  1037. package/examples/extensions/hello.ts +26 -0
  1038. package/examples/extensions/hidden-thinking-label.ts +53 -0
  1039. package/examples/extensions/inline-bash.ts +104 -0
  1040. package/examples/extensions/input-transform.ts +43 -0
  1041. package/examples/extensions/interactive-shell.ts +194 -0
  1042. package/examples/extensions/mac-system-theme.ts +47 -0
  1043. package/examples/extensions/message-renderer.ts +59 -0
  1044. package/examples/extensions/minimal-mode.ts +428 -0
  1045. package/examples/extensions/modal-editor.ts +86 -0
  1046. package/examples/extensions/model-status.ts +31 -0
  1047. package/examples/extensions/notify.ts +55 -0
  1048. package/examples/extensions/overlay-qa-tests.ts +1374 -0
  1049. package/examples/extensions/overlay-test.ts +171 -0
  1050. package/examples/extensions/permission-gate.ts +34 -0
  1051. package/examples/extensions/pirate.ts +47 -0
  1052. package/examples/extensions/plan-mode/README.md +65 -0
  1053. package/examples/extensions/plan-mode/index.ts +346 -0
  1054. package/examples/extensions/plan-mode/utils.ts +172 -0
  1055. package/examples/extensions/preset.ts +426 -0
  1056. package/examples/extensions/prompt-customizer.ts +97 -0
  1057. package/examples/extensions/protected-paths.ts +29 -0
  1058. package/examples/extensions/provider-payload.ts +18 -0
  1059. package/examples/extensions/qna.ts +125 -0
  1060. package/examples/extensions/question.ts +294 -0
  1061. package/examples/extensions/questionnaire.ts +459 -0
  1062. package/examples/extensions/rainbow-editor.ts +88 -0
  1063. package/examples/extensions/reload-runtime.ts +37 -0
  1064. package/examples/extensions/rpc-demo.ts +118 -0
  1065. package/examples/extensions/sandbox/index.ts +320 -0
  1066. package/examples/extensions/sandbox/package-lock.json +92 -0
  1067. package/examples/extensions/sandbox/package.json +19 -0
  1068. package/examples/extensions/send-user-message.ts +97 -0
  1069. package/examples/extensions/session-name.ts +27 -0
  1070. package/examples/extensions/shutdown-command.ts +63 -0
  1071. package/examples/extensions/snake.ts +381 -0
  1072. package/examples/extensions/space-invaders.ts +597 -0
  1073. package/examples/extensions/status-line.ts +32 -0
  1074. package/examples/extensions/structured-output.ts +65 -0
  1075. package/examples/extensions/subagent/README.md +175 -0
  1076. package/examples/extensions/subagent/agents/planner.md +37 -0
  1077. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  1078. package/examples/extensions/subagent/agents/scout.md +50 -0
  1079. package/examples/extensions/subagent/agents/worker.md +24 -0
  1080. package/examples/extensions/subagent/agents.ts +126 -0
  1081. package/examples/extensions/subagent/index.ts +1083 -0
  1082. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  1083. package/examples/extensions/subagent/prompts/implement.md +10 -0
  1084. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  1085. package/examples/extensions/summarize.ts +186 -0
  1086. package/examples/extensions/system-prompt-header.ts +17 -0
  1087. package/examples/extensions/tic-tac-toe.ts +1091 -0
  1088. package/examples/extensions/timed-confirm.ts +70 -0
  1089. package/examples/extensions/titlebar-spinner.ts +58 -0
  1090. package/examples/extensions/todo.ts +306 -0
  1091. package/examples/extensions/tool-override.ts +144 -0
  1092. package/examples/extensions/tools.ts +141 -0
  1093. package/examples/extensions/trigger-compact.ts +50 -0
  1094. package/examples/extensions/truncated-tool.ts +200 -0
  1095. package/examples/extensions/widget-placement.ts +9 -0
  1096. package/examples/extensions/with-deps/index.ts +32 -0
  1097. package/examples/extensions/with-deps/package-lock.json +31 -0
  1098. package/examples/extensions/with-deps/package.json +22 -0
  1099. package/examples/extensions/working-indicator.ts +123 -0
  1100. package/examples/extensions/working-message-test.ts +25 -0
  1101. package/examples/remote-session-server/README.md +71 -0
  1102. package/examples/remote-session-server/server.ts +353 -0
  1103. package/examples/rpc-extension-ui.ts +642 -0
  1104. package/examples/sdk/01-minimal.ts +27 -0
  1105. package/examples/sdk/02-custom-model.ts +54 -0
  1106. package/examples/sdk/03-custom-prompt.ts +76 -0
  1107. package/examples/sdk/04-skills.ts +60 -0
  1108. package/examples/sdk/05-tools.ts +55 -0
  1109. package/examples/sdk/06-extensions.ts +94 -0
  1110. package/examples/sdk/07-context-files.ts +47 -0
  1111. package/examples/sdk/08-prompt-templates.ts +56 -0
  1112. package/examples/sdk/09-api-keys-and-oauth.ts +50 -0
  1113. package/examples/sdk/10-settings.ts +58 -0
  1114. package/examples/sdk/11-sessions.ts +54 -0
  1115. package/examples/sdk/12-full-control.ts +79 -0
  1116. package/examples/sdk/13-session-runtime.ts +49 -0
  1117. package/examples/sdk/README.md +94 -0
  1118. package/npm-shrinkwrap.json +1878 -0
  1119. package/package.json +101 -5
@@ -0,0 +1,1374 @@
1
+ /**
2
+ * Overlay QA Tests - comprehensive overlay positioning and edge case tests
3
+ *
4
+ * Usage: grip --extension ./examples/extensions/overlay-qa-tests.ts
5
+ *
6
+ * Commands:
7
+ * /overlay-animation - Real-time animation demo (~30 FPS, proves DOOM-like rendering works)
8
+ * /overlay-anchors - Cycle through all 9 anchor positions
9
+ * /overlay-margins - Test margin and offset options
10
+ * /overlay-stack - Test stacked overlays
11
+ * /overlay-overflow - Test width overflow with streaming process output
12
+ * /overlay-edge - Test overlay positioned at terminal edge
13
+ * /overlay-percent - Test percentage-based positioning
14
+ * /overlay-maxheight - Test maxHeight truncation
15
+ * /overlay-sidepanel - Responsive sidepanel (hides when terminal < 100 cols)
16
+ * /overlay-toggle - Toggle visibility demo (demonstrates OverlayHandle.setHidden)
17
+ * /overlay-passive - Non-capturing overlay demo (passive info panel alongside active overlay)
18
+ * /overlay-focus - Focus cycling and rendering order with non-capturing overlays
19
+ * /overlay-streaming - Multiple input panels with simulated streaming (Tab to cycle focus)
20
+ */
21
+
22
+ import type { ExtensionAPI, ExtensionCommandContext, Theme } from "@greppleai/grip";
23
+ import type { Component, OverlayAnchor, OverlayHandle, OverlayOptions, TUI } from "@greppleai/grip-tui";
24
+ import { matchesKey, truncateToWidth, visibleWidth } from "@greppleai/grip-tui";
25
+ import { spawn } from "child_process";
26
+
27
+ // Global handle for toggle demo (in real code, use a more elegant pattern)
28
+ let globalToggleHandle: OverlayHandle | null = null;
29
+
30
+ type AnchorTestResult = "next" | "confirm" | "cancel";
31
+ type OverlayCycleResult = "next" | "close";
32
+ type OverlayPanelColor = "error" | "success" | "accent";
33
+
34
+ interface MarginTestConfig {
35
+ name: string;
36
+ options: OverlayOptions;
37
+ }
38
+
39
+ interface PercentTestConfig {
40
+ name: string;
41
+ row: number;
42
+ col: number;
43
+ }
44
+
45
+ export default function (pi: ExtensionAPI) {
46
+ // Animation demo - proves overlays can handle real-time updates (like pi-doom would need)
47
+ pi.registerCommand("overlay-animation", {
48
+ description: "Test real-time animation in overlay (~30 FPS)",
49
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
50
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new AnimationDemoComponent(tui, theme, done), {
51
+ overlay: true,
52
+ overlayOptions: { anchor: "center", width: 50, maxHeight: 20 },
53
+ });
54
+ },
55
+ });
56
+
57
+ // Test all 9 anchor positions
58
+ pi.registerCommand("overlay-anchors", {
59
+ description: "Cycle through all anchor positions",
60
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
61
+ const anchors: OverlayAnchor[] = [
62
+ "top-left",
63
+ "top-center",
64
+ "top-right",
65
+ "left-center",
66
+ "center",
67
+ "right-center",
68
+ "bottom-left",
69
+ "bottom-center",
70
+ "bottom-right",
71
+ ];
72
+
73
+ let index = 0;
74
+ while (true) {
75
+ const result = await ctx.ui.custom<AnchorTestResult>(
76
+ (_tui, theme, _kb, done) => new AnchorTestComponent(theme, anchors[index]!, done),
77
+ {
78
+ overlay: true,
79
+ overlayOptions: { anchor: anchors[index], width: 40 },
80
+ },
81
+ );
82
+
83
+ if (result === "next") {
84
+ index = (index + 1) % anchors.length;
85
+ continue;
86
+ }
87
+ if (result === "confirm") {
88
+ ctx.ui.notify(`Selected: ${anchors[index]}`, "info");
89
+ }
90
+ break;
91
+ }
92
+ },
93
+ });
94
+
95
+ // Test margins and offsets
96
+ pi.registerCommand("overlay-margins", {
97
+ description: "Test margin and offset options",
98
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
99
+ const configs: MarginTestConfig[] = [
100
+ { name: "No margin (top-left)", options: { anchor: "top-left", width: 35 } },
101
+ { name: "Margin: 3 all sides", options: { anchor: "top-left", width: 35, margin: 3 } },
102
+ {
103
+ name: "Margin: top=5, left=10",
104
+ options: { anchor: "top-left", width: 35, margin: { top: 5, left: 10 } },
105
+ },
106
+ { name: "Center + offset (10, -3)", options: { anchor: "center", width: 35, offsetX: 10, offsetY: -3 } },
107
+ { name: "Bottom-right, margin: 2", options: { anchor: "bottom-right", width: 35, margin: 2 } },
108
+ ];
109
+
110
+ let index = 0;
111
+ while (true) {
112
+ const result = await ctx.ui.custom<OverlayCycleResult>(
113
+ (_tui, theme, _kb, done) => new MarginTestComponent(theme, configs[index]!, done),
114
+ {
115
+ overlay: true,
116
+ overlayOptions: configs[index]!.options,
117
+ },
118
+ );
119
+
120
+ if (result === "next") {
121
+ index = (index + 1) % configs.length;
122
+ continue;
123
+ }
124
+ break;
125
+ }
126
+ },
127
+ });
128
+
129
+ // Test stacked overlays
130
+ pi.registerCommand("overlay-stack", {
131
+ description: "Test stacked overlays",
132
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
133
+ // Three large overlays that overlap in the center area
134
+ // Each offset slightly so you can see the stacking
135
+
136
+ ctx.ui.notify("Showing overlay 1 (back)...", "info");
137
+ const p1 = ctx.ui.custom<string>(
138
+ (_tui, theme, _kb, done) => new StackOverlayComponent(theme, 1, "back (red border)", done),
139
+ {
140
+ overlay: true,
141
+ overlayOptions: { anchor: "center", width: 50, offsetX: -8, offsetY: -4, maxHeight: 15 },
142
+ },
143
+ );
144
+
145
+ await sleep(400);
146
+
147
+ ctx.ui.notify("Showing overlay 2 (middle)...", "info");
148
+ const p2 = ctx.ui.custom<string>(
149
+ (_tui, theme, _kb, done) => new StackOverlayComponent(theme, 2, "middle (green border)", done),
150
+ {
151
+ overlay: true,
152
+ overlayOptions: { anchor: "center", width: 50, offsetX: 0, offsetY: 0, maxHeight: 15 },
153
+ },
154
+ );
155
+
156
+ await sleep(400);
157
+
158
+ ctx.ui.notify("Showing overlay 3 (front)...", "info");
159
+ const p3 = ctx.ui.custom<string>(
160
+ (_tui, theme, _kb, done) => new StackOverlayComponent(theme, 3, "front (blue border)", done),
161
+ {
162
+ overlay: true,
163
+ overlayOptions: { anchor: "center", width: 50, offsetX: 8, offsetY: 4, maxHeight: 15 },
164
+ },
165
+ );
166
+
167
+ // Wait for all to close
168
+ const results = await Promise.all([p1, p2, p3]);
169
+ ctx.ui.notify(`Closed in order: ${results.join(", ")}`, "info");
170
+ },
171
+ });
172
+
173
+ // Test width overflow scenarios (original crash case) - streams real process output
174
+ pi.registerCommand("overlay-overflow", {
175
+ description: "Test width overflow with streaming process output",
176
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
177
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new StreamingOverflowComponent(tui, theme, done), {
178
+ overlay: true,
179
+ overlayOptions: { anchor: "center", width: 90, maxHeight: 20 },
180
+ });
181
+ },
182
+ });
183
+
184
+ // Test overlay at terminal edge
185
+ pi.registerCommand("overlay-edge", {
186
+ description: "Test overlay positioned at terminal edge",
187
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
188
+ await ctx.ui.custom<void>((_tui, theme, _kb, done) => new EdgeTestComponent(theme, done), {
189
+ overlay: true,
190
+ overlayOptions: { anchor: "right-center", width: 40, margin: { right: 0 } },
191
+ });
192
+ },
193
+ });
194
+
195
+ // Test percentage-based positioning
196
+ pi.registerCommand("overlay-percent", {
197
+ description: "Test percentage-based positioning",
198
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
199
+ const configs: PercentTestConfig[] = [
200
+ { name: "rowPercent: 0 (top)", row: 0, col: 50 },
201
+ { name: "rowPercent: 50 (middle)", row: 50, col: 50 },
202
+ { name: "rowPercent: 100 (bottom)", row: 100, col: 50 },
203
+ { name: "colPercent: 0 (left)", row: 50, col: 0 },
204
+ { name: "colPercent: 100 (right)", row: 50, col: 100 },
205
+ ];
206
+
207
+ let index = 0;
208
+ while (true) {
209
+ const config = configs[index]!;
210
+ const result = await ctx.ui.custom<OverlayCycleResult>(
211
+ (_tui, theme, _kb, done) => new PercentTestComponent(theme, config, done),
212
+ {
213
+ overlay: true,
214
+ overlayOptions: {
215
+ width: 30,
216
+ row: `${config.row}%`,
217
+ col: `${config.col}%`,
218
+ },
219
+ },
220
+ );
221
+
222
+ if (result === "next") {
223
+ index = (index + 1) % configs.length;
224
+ continue;
225
+ }
226
+ break;
227
+ }
228
+ },
229
+ });
230
+
231
+ // Test maxHeight
232
+ pi.registerCommand("overlay-maxheight", {
233
+ description: "Test maxHeight truncation",
234
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
235
+ await ctx.ui.custom<void>((_tui, theme, _kb, done) => new MaxHeightTestComponent(theme, done), {
236
+ overlay: true,
237
+ overlayOptions: { anchor: "center", width: 50, maxHeight: 10 },
238
+ });
239
+ },
240
+ });
241
+
242
+ // Test responsive sidepanel - only shows when terminal is wide enough
243
+ pi.registerCommand("overlay-sidepanel", {
244
+ description: "Test responsive sidepanel (hides when terminal < 100 cols)",
245
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
246
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new SidepanelComponent(tui, theme, done), {
247
+ overlay: true,
248
+ overlayOptions: {
249
+ anchor: "right-center",
250
+ width: "25%",
251
+ minWidth: 30,
252
+ margin: { right: 1 },
253
+ // Only show when terminal is wide enough
254
+ visible: (termWidth) => termWidth >= 100,
255
+ },
256
+ });
257
+ },
258
+ });
259
+
260
+ // Test toggle overlay - demonstrates OverlayHandle.setHidden() via onHandle callback
261
+ pi.registerCommand("overlay-toggle", {
262
+ description: "Test overlay toggle (press 't' to toggle visibility)",
263
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
264
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new ToggleDemoComponent(tui, theme, done), {
265
+ overlay: true,
266
+ overlayOptions: { anchor: "center", width: 50 },
267
+ // onHandle callback provides access to the OverlayHandle for visibility control
268
+ onHandle: (handle) => {
269
+ // Store handle globally so component can access it
270
+ // (In real code, you'd use a more elegant pattern like a store or event emitter)
271
+ globalToggleHandle = handle;
272
+ },
273
+ });
274
+ globalToggleHandle = null;
275
+ },
276
+ });
277
+
278
+ // Non-capturing overlay demo - passive info panel that doesn't steal focus
279
+ pi.registerCommand("overlay-passive", {
280
+ description: "Test non-capturing overlay (passive info panel alongside active overlay)",
281
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
282
+ ctx.ui.setEditorText("");
283
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new PassiveDemoController(tui, theme, done), {
284
+ overlay: true,
285
+ overlayOptions: { anchor: "center", width: 48 },
286
+ });
287
+ },
288
+ });
289
+
290
+ // Focus cycling demo - demonstrates focus(), unfocus(), isFocused() and rendering order
291
+ pi.registerCommand("overlay-focus", {
292
+ description: "Test focus cycling and rendering order with non-capturing overlays",
293
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
294
+ ctx.ui.setEditorText("");
295
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new FocusDemoController(tui, theme, done), {
296
+ overlay: true,
297
+ overlayOptions: { anchor: "bottom-center", width: 55, margin: { bottom: 1 } },
298
+ });
299
+ },
300
+ });
301
+
302
+ // Test multiple input panels with simulated streaming
303
+ pi.registerCommand("overlay-streaming", {
304
+ description: "Multiple input panels with simulated streaming (Tab to cycle focus)",
305
+ handler: async (_args: string, ctx: ExtensionCommandContext) => {
306
+ ctx.ui.setEditorText("");
307
+ await ctx.ui.custom<void>((tui, theme, _kb, done) => new StreamingInputController(tui, theme, done), {
308
+ overlay: true,
309
+ overlayOptions: { anchor: "bottom-center", width: 60, margin: { bottom: 1 } },
310
+ });
311
+ },
312
+ });
313
+ }
314
+
315
+ function sleep(ms: number): Promise<void> {
316
+ return new Promise((resolve) => setTimeout(resolve, ms));
317
+ }
318
+
319
+ // Base overlay component with common rendering
320
+ abstract class BaseOverlay {
321
+ protected theme: Theme;
322
+
323
+ constructor(theme: Theme) {
324
+ this.theme = theme;
325
+ }
326
+
327
+ protected box(lines: string[], width: number, title?: string): string[] {
328
+ const th = this.theme;
329
+ const innerW = Math.max(1, width - 2);
330
+ const result: string[] = [];
331
+
332
+ const titleStr = title ? truncateToWidth(` ${title} `, innerW) : "";
333
+ const titleW = visibleWidth(titleStr);
334
+ const topLine = "─".repeat(Math.floor((innerW - titleW) / 2));
335
+ const topLine2 = "─".repeat(Math.max(0, innerW - titleW - topLine.length));
336
+ result.push(th.fg("border", `╭${topLine}`) + th.fg("accent", titleStr) + th.fg("border", `${topLine2}╮`));
337
+
338
+ for (const line of lines) {
339
+ result.push(th.fg("border", "│") + truncateToWidth(line, innerW, "...", true) + th.fg("border", "│"));
340
+ }
341
+
342
+ result.push(th.fg("border", `╰${"─".repeat(innerW)}╯`));
343
+ return result;
344
+ }
345
+
346
+ invalidate(): void {}
347
+ dispose(): void {}
348
+ }
349
+
350
+ // Anchor position test
351
+ class AnchorTestComponent extends BaseOverlay {
352
+ private anchor: OverlayAnchor;
353
+ private done: (result: AnchorTestResult) => void;
354
+
355
+ constructor(theme: Theme, anchor: OverlayAnchor, done: (result: AnchorTestResult) => void) {
356
+ super(theme);
357
+ this.anchor = anchor;
358
+ this.done = done;
359
+ }
360
+
361
+ handleInput(data: string): void {
362
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
363
+ this.done("cancel");
364
+ } else if (matchesKey(data, "return")) {
365
+ this.done("confirm");
366
+ } else if (matchesKey(data, "space") || matchesKey(data, "right")) {
367
+ this.done("next");
368
+ }
369
+ }
370
+
371
+ render(width: number): string[] {
372
+ const th = this.theme;
373
+ return this.box(
374
+ [
375
+ "",
376
+ ` Current: ${th.fg("accent", this.anchor)}`,
377
+ "",
378
+ ` ${th.fg("dim", "Space/→ = next anchor")}`,
379
+ ` ${th.fg("dim", "Enter = confirm")}`,
380
+ ` ${th.fg("dim", "Esc = cancel")}`,
381
+ "",
382
+ ],
383
+ width,
384
+ "Anchor Test",
385
+ );
386
+ }
387
+ }
388
+
389
+ // Margin/offset test
390
+ class MarginTestComponent extends BaseOverlay {
391
+ private config: MarginTestConfig;
392
+ private done: (result: OverlayCycleResult) => void;
393
+
394
+ constructor(theme: Theme, config: MarginTestConfig, done: (result: OverlayCycleResult) => void) {
395
+ super(theme);
396
+ this.config = config;
397
+ this.done = done;
398
+ }
399
+
400
+ handleInput(data: string): void {
401
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
402
+ this.done("close");
403
+ } else if (matchesKey(data, "space") || matchesKey(data, "right")) {
404
+ this.done("next");
405
+ }
406
+ }
407
+
408
+ render(width: number): string[] {
409
+ const th = this.theme;
410
+ return this.box(
411
+ [
412
+ "",
413
+ ` ${th.fg("accent", this.config.name)}`,
414
+ "",
415
+ ` ${th.fg("dim", "Space/→ = next config")}`,
416
+ ` ${th.fg("dim", "Esc = close")}`,
417
+ "",
418
+ ],
419
+ width,
420
+ "Margin Test",
421
+ );
422
+ }
423
+ }
424
+
425
+ // Stacked overlay test
426
+ class StackOverlayComponent extends BaseOverlay {
427
+ private num: number;
428
+ private position: string;
429
+ private done: (result: string) => void;
430
+
431
+ constructor(theme: Theme, num: number, position: string, done: (result: string) => void) {
432
+ super(theme);
433
+ this.num = num;
434
+ this.position = position;
435
+ this.done = done;
436
+ }
437
+
438
+ handleInput(data: string): void {
439
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c") || matchesKey(data, "return")) {
440
+ this.done(`Overlay ${this.num}`);
441
+ }
442
+ }
443
+
444
+ render(width: number): string[] {
445
+ const th = this.theme;
446
+ // Use different colors for each overlay to show stacking
447
+ const colors = ["error", "success", "accent"] as const;
448
+ const color = colors[(this.num - 1) % colors.length]!;
449
+ const innerW = Math.max(1, width - 2);
450
+ const border = (char: string) => th.fg(color, char);
451
+ const padLine = (s: string) => truncateToWidth(s, innerW, "...", true);
452
+ const lines: string[] = [];
453
+
454
+ lines.push(border(`╭${"─".repeat(innerW)}╮`));
455
+ lines.push(border("│") + padLine(` Overlay ${th.fg("accent", `#${this.num}`)}`) + border("│"));
456
+ lines.push(border("│") + padLine(` Layer: ${th.fg(color, this.position)}`) + border("│"));
457
+ lines.push(border("│") + padLine("") + border("│"));
458
+ // Add extra lines to make it taller
459
+ for (let i = 0; i < 5; i++) {
460
+ lines.push(border("│") + padLine(` ${"░".repeat(innerW - 2)} `) + border("│"));
461
+ }
462
+ lines.push(border("│") + padLine("") + border("│"));
463
+ lines.push(border("│") + padLine(th.fg("dim", " Press Enter/Esc to close")) + border("│"));
464
+ lines.push(border(`╰${"─".repeat(innerW)}╯`));
465
+
466
+ return lines;
467
+ }
468
+ }
469
+
470
+ // Streaming overflow test - spawns real process with colored output (original crash scenario)
471
+ class StreamingOverflowComponent extends BaseOverlay {
472
+ private tui: TUI;
473
+ private lines: string[] = [];
474
+ private proc: ReturnType<typeof spawn> | null = null;
475
+ private scrollOffset = 0;
476
+ private maxVisibleLines = 15;
477
+ private finished = false;
478
+ private disposed = false;
479
+ private done: () => void;
480
+
481
+ constructor(tui: TUI, theme: Theme, done: () => void) {
482
+ super(theme);
483
+ this.tui = tui;
484
+ this.done = done;
485
+ this.startProcess();
486
+ }
487
+
488
+ private startProcess(): void {
489
+ // Run a command that produces many lines with ANSI colors
490
+ // Using find with -ls produces file listings, or use ls --color
491
+ this.proc = spawn("bash", [
492
+ "-c",
493
+ `
494
+ echo "Starting streaming overflow test (30+ seconds)..."
495
+ echo "This simulates subagent output with colors, hyperlinks, and long paths"
496
+ echo ""
497
+ for i in $(seq 1 100); do
498
+ # Simulate long file paths with OSC 8 hyperlinks (clickable) - tests width overflow
499
+ DIR="/Users/nicobailon/Documents/development/pi-mono/packages/coding-agent/src/modes/interactive"
500
+ FILE="\${DIR}/components/very-long-component-name-that-exceeds-width-\${i}.ts"
501
+ echo -e "\\033]8;;file://\${FILE}\\007▶ read: \${FILE}\\033]8;;\\007"
502
+
503
+ # Add some colored status messages with long text
504
+ if [ $((i % 5)) -eq 0 ]; then
505
+ echo -e " \\033[32m✓ Successfully processed \${i} files in /Users/nicobailon/Documents/development/pi-mono\\033[0m"
506
+ fi
507
+ if [ $((i % 7)) -eq 0 ]; then
508
+ echo -e " \\033[33m⚠ Warning: potential issue detected at line \${i} in very-long-component-name-that-exceeds-width.ts\\033[0m"
509
+ fi
510
+ if [ $((i % 11)) -eq 0 ]; then
511
+ echo -e " \\033[31m✗ Error: file not found /some/really/long/path/that/definitely/exceeds/the/overlay/width/limit/file-\${i}.ts\\033[0m"
512
+ fi
513
+ sleep 0.3
514
+ done
515
+ echo ""
516
+ echo -e "\\033[32m✓ Complete - 100 files processed in 30 seconds\\033[0m"
517
+ echo "Press Esc to close"
518
+ `,
519
+ ]);
520
+
521
+ this.proc.stdout?.on("data", (data: Buffer) => {
522
+ if (this.disposed) return; // Guard against callbacks after dispose
523
+ const text = data.toString();
524
+ const newLines = text.split("\n");
525
+ for (const line of newLines) {
526
+ if (line) this.lines.push(line);
527
+ }
528
+ // Auto-scroll to bottom
529
+ this.scrollOffset = Math.max(0, this.lines.length - this.maxVisibleLines);
530
+ this.tui.requestRender();
531
+ });
532
+
533
+ this.proc.stderr?.on("data", (data: Buffer) => {
534
+ if (this.disposed) return; // Guard against callbacks after dispose
535
+ this.lines.push(this.theme.fg("error", data.toString().trim()));
536
+ this.tui.requestRender();
537
+ });
538
+
539
+ this.proc.on("close", () => {
540
+ if (this.disposed) return; // Guard against callbacks after dispose
541
+ this.finished = true;
542
+ this.tui.requestRender();
543
+ });
544
+ }
545
+
546
+ handleInput(data: string): void {
547
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
548
+ this.proc?.kill();
549
+ this.done();
550
+ } else if (matchesKey(data, "up")) {
551
+ this.scrollOffset = Math.max(0, this.scrollOffset - 1);
552
+ this.tui.requestRender(); // Trigger re-render after scroll
553
+ } else if (matchesKey(data, "down")) {
554
+ this.scrollOffset = Math.min(Math.max(0, this.lines.length - this.maxVisibleLines), this.scrollOffset + 1);
555
+ this.tui.requestRender(); // Trigger re-render after scroll
556
+ }
557
+ }
558
+
559
+ render(width: number): string[] {
560
+ const th = this.theme;
561
+ const innerW = Math.max(1, width - 2);
562
+ const padLine = (s: string) => truncateToWidth(s, innerW, "...", true);
563
+ const border = (c: string) => th.fg("border", c);
564
+
565
+ const result: string[] = [];
566
+ const title = truncateToWidth(` Streaming Output (${this.lines.length} lines) `, innerW);
567
+ const titlePad = Math.max(0, innerW - visibleWidth(title));
568
+ result.push(border("╭") + th.fg("accent", title) + border(`${"─".repeat(titlePad)}╮`));
569
+
570
+ // Scroll indicators
571
+ const canScrollUp = this.scrollOffset > 0;
572
+ const canScrollDown = this.scrollOffset < this.lines.length - this.maxVisibleLines;
573
+ const scrollInfo = `↑${this.scrollOffset} | ↓${Math.max(0, this.lines.length - this.maxVisibleLines - this.scrollOffset)}`;
574
+
575
+ result.push(
576
+ border("│") + padLine(canScrollUp || canScrollDown ? th.fg("dim", ` ${scrollInfo}`) : "") + border("│"),
577
+ );
578
+
579
+ // Visible lines - truncate long lines to fit within border
580
+ const visibleLines = this.lines.slice(this.scrollOffset, this.scrollOffset + this.maxVisibleLines);
581
+ for (const line of visibleLines) {
582
+ result.push(border("│") + padLine(` ${line}`) + border("│"));
583
+ }
584
+
585
+ // Pad to maxVisibleLines
586
+ for (let i = visibleLines.length; i < this.maxVisibleLines; i++) {
587
+ result.push(border("│") + padLine("") + border("│"));
588
+ }
589
+
590
+ const status = this.finished ? th.fg("success", "✓ Done") : th.fg("warning", "● Running");
591
+ result.push(border("│") + padLine(` ${status} ${th.fg("dim", "| ↑↓ scroll | Esc close")}`) + border("│"));
592
+ result.push(border(`╰${"─".repeat(innerW)}╯`));
593
+
594
+ return result;
595
+ }
596
+
597
+ dispose(): void {
598
+ this.disposed = true;
599
+ this.proc?.kill();
600
+ }
601
+ }
602
+
603
+ // Edge position test
604
+ class EdgeTestComponent extends BaseOverlay {
605
+ private done: () => void;
606
+
607
+ constructor(theme: Theme, done: () => void) {
608
+ super(theme);
609
+ this.done = done;
610
+ }
611
+
612
+ handleInput(data: string): void {
613
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
614
+ this.done();
615
+ }
616
+ }
617
+
618
+ render(width: number): string[] {
619
+ const th = this.theme;
620
+ return this.box(
621
+ [
622
+ "",
623
+ " This overlay is at the",
624
+ " right edge of terminal.",
625
+ "",
626
+ ` ${th.fg("dim", "Verify right border")}`,
627
+ ` ${th.fg("dim", "aligns with edge.")}`,
628
+ "",
629
+ ` ${th.fg("dim", "Press Esc to close")}`,
630
+ "",
631
+ ],
632
+ width,
633
+ "Edge Test",
634
+ );
635
+ }
636
+ }
637
+
638
+ // Percentage positioning test
639
+ class PercentTestComponent extends BaseOverlay {
640
+ private config: PercentTestConfig;
641
+ private done: (result: OverlayCycleResult) => void;
642
+
643
+ constructor(theme: Theme, config: PercentTestConfig, done: (result: OverlayCycleResult) => void) {
644
+ super(theme);
645
+ this.config = config;
646
+ this.done = done;
647
+ }
648
+
649
+ handleInput(data: string): void {
650
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
651
+ this.done("close");
652
+ } else if (matchesKey(data, "space") || matchesKey(data, "right")) {
653
+ this.done("next");
654
+ }
655
+ }
656
+
657
+ render(width: number): string[] {
658
+ const th = this.theme;
659
+ return this.box(
660
+ [
661
+ "",
662
+ ` ${th.fg("accent", this.config.name)}`,
663
+ "",
664
+ ` ${th.fg("dim", "Space/→ = next")}`,
665
+ ` ${th.fg("dim", "Esc = close")}`,
666
+ "",
667
+ ],
668
+ width,
669
+ "Percent Test",
670
+ );
671
+ }
672
+ }
673
+
674
+ // MaxHeight test - renders 20 lines, truncated to 10 by maxHeight
675
+ class MaxHeightTestComponent extends BaseOverlay {
676
+ private done: () => void;
677
+
678
+ constructor(theme: Theme, done: () => void) {
679
+ super(theme);
680
+ this.done = done;
681
+ }
682
+
683
+ handleInput(data: string): void {
684
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
685
+ this.done();
686
+ }
687
+ }
688
+
689
+ render(width: number): string[] {
690
+ const th = this.theme;
691
+ // Intentionally render 21 lines - maxHeight: 10 will truncate to first 10
692
+ // You should see header + lines 1-6, with bottom border cut off
693
+ const contentLines: string[] = [
694
+ th.fg("warning", " ⚠ Rendering 21 lines, maxHeight: 10"),
695
+ th.fg("dim", " Lines 11-21 truncated (no bottom border)"),
696
+ "",
697
+ ];
698
+
699
+ for (let i = 1; i <= 14; i++) {
700
+ contentLines.push(` Line ${i} of 14`);
701
+ }
702
+
703
+ contentLines.push("", th.fg("dim", " Press Esc to close"));
704
+
705
+ return this.box(contentLines, width, "MaxHeight Test");
706
+ }
707
+ }
708
+
709
+ // Responsive sidepanel - demonstrates percentage width and visibility callback
710
+ class SidepanelComponent extends BaseOverlay {
711
+ private tui: TUI;
712
+ private items = ["Dashboard", "Messages", "Settings", "Help", "About"];
713
+ private selectedIndex = 0;
714
+ private done: () => void;
715
+
716
+ constructor(tui: TUI, theme: Theme, done: () => void) {
717
+ super(theme);
718
+ this.tui = tui;
719
+ this.done = done;
720
+ }
721
+
722
+ handleInput(data: string): void {
723
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
724
+ this.done();
725
+ } else if (matchesKey(data, "up")) {
726
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
727
+ this.tui.requestRender();
728
+ } else if (matchesKey(data, "down")) {
729
+ this.selectedIndex = Math.min(this.items.length - 1, this.selectedIndex + 1);
730
+ this.tui.requestRender();
731
+ } else if (matchesKey(data, "return")) {
732
+ // Could trigger an action here
733
+ this.tui.requestRender();
734
+ }
735
+ }
736
+
737
+ render(width: number): string[] {
738
+ const th = this.theme;
739
+ const innerW = Math.max(1, width - 2);
740
+ const padLine = (s: string) => truncateToWidth(s, innerW, "...", true);
741
+ const border = (c: string) => th.fg("border", c);
742
+ const lines: string[] = [];
743
+
744
+ // Header
745
+ lines.push(border(`╭${"─".repeat(innerW)}╮`));
746
+ lines.push(border("│") + padLine(th.fg("accent", " Responsive Sidepanel")) + border("│"));
747
+ lines.push(border("├") + border("─".repeat(innerW)) + border("┤"));
748
+
749
+ // Menu items
750
+ for (let i = 0; i < this.items.length; i++) {
751
+ const item = this.items[i]!;
752
+ const isSelected = i === this.selectedIndex;
753
+ const prefix = isSelected ? th.fg("accent", "→ ") : " ";
754
+ const text = isSelected ? th.fg("accent", item) : item;
755
+ lines.push(border("│") + padLine(`${prefix}${text}`) + border("│"));
756
+ }
757
+
758
+ // Footer with responsive behavior info
759
+ lines.push(border("├") + border("─".repeat(innerW)) + border("┤"));
760
+ lines.push(border("│") + padLine(th.fg("warning", " ⚠ Resize terminal < 100 cols")) + border("│"));
761
+ lines.push(border("│") + padLine(th.fg("warning", " to see panel auto-hide")) + border("│"));
762
+ lines.push(border("│") + padLine(th.fg("dim", " Uses visible: (w) => w >= 100")) + border("│"));
763
+ lines.push(border("│") + padLine(th.fg("dim", " ↑↓ navigate | Esc close")) + border("│"));
764
+ lines.push(border(`╰${"─".repeat(innerW)}╯`));
765
+
766
+ return lines;
767
+ }
768
+ }
769
+
770
+ // Animation demo - proves overlays can handle real-time updates like pi-doom
771
+ class AnimationDemoComponent extends BaseOverlay {
772
+ private tui: TUI;
773
+ private frame = 0;
774
+ private interval: ReturnType<typeof setInterval> | null = null;
775
+ private fps = 0;
776
+ private lastFpsUpdate = Date.now();
777
+ private framesSinceLastFps = 0;
778
+ private done: () => void;
779
+
780
+ constructor(tui: TUI, theme: Theme, done: () => void) {
781
+ super(theme);
782
+ this.tui = tui;
783
+ this.done = done;
784
+ this.startAnimation();
785
+ }
786
+
787
+ private startAnimation(): void {
788
+ // Run at ~30 FPS (same as DOOM target)
789
+ this.interval = setInterval(() => {
790
+ this.frame++;
791
+ this.framesSinceLastFps++;
792
+
793
+ // Update FPS counter every second
794
+ const now = Date.now();
795
+ if (now - this.lastFpsUpdate >= 1000) {
796
+ this.fps = this.framesSinceLastFps;
797
+ this.framesSinceLastFps = 0;
798
+ this.lastFpsUpdate = now;
799
+ }
800
+
801
+ this.tui.requestRender();
802
+ }, 1000 / 30);
803
+ }
804
+
805
+ handleInput(data: string): void {
806
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
807
+ this.dispose();
808
+ this.done();
809
+ }
810
+ }
811
+
812
+ render(width: number): string[] {
813
+ const th = this.theme;
814
+ const innerW = Math.max(1, width - 2);
815
+ const padLine = (s: string) => truncateToWidth(s, innerW, "...", true);
816
+ const border = (c: string) => th.fg("border", c);
817
+
818
+ const lines: string[] = [];
819
+ lines.push(border(`╭${"─".repeat(innerW)}╮`));
820
+ lines.push(border("│") + padLine(th.fg("accent", " Animation Demo (~30 FPS)")) + border("│"));
821
+ lines.push(border("│") + padLine(``) + border("│"));
822
+ lines.push(border("│") + padLine(` Frame: ${th.fg("accent", String(this.frame))}`) + border("│"));
823
+ lines.push(border("│") + padLine(` FPS: ${th.fg("success", String(this.fps))}`) + border("│"));
824
+ lines.push(border("│") + padLine(``) + border("│"));
825
+
826
+ // Animated content - bouncing bar
827
+ const barWidth = Math.max(12, innerW - 4); // Ensure enough space for bar
828
+ const pos = Math.max(0, Math.floor(((Math.sin(this.frame / 10) + 1) * (barWidth - 10)) / 2));
829
+ const bar = " ".repeat(pos) + th.fg("accent", "██████████") + " ".repeat(Math.max(0, barWidth - 10 - pos));
830
+ lines.push(border("│") + padLine(` ${bar}`) + border("│"));
831
+
832
+ // Spinning character
833
+ const spinChars = ["◐", "◓", "◑", "◒"];
834
+ const spin = spinChars[this.frame % spinChars.length];
835
+ lines.push(border("│") + padLine(` Spinner: ${th.fg("warning", spin!)}`) + border("│"));
836
+
837
+ // Color cycling
838
+ const hue = (this.frame * 3) % 360;
839
+ const rgb = hslToRgb(hue / 360, 0.8, 0.5);
840
+ const colorBlock = `\x1b[48;2;${rgb[0]};${rgb[1]};${rgb[2]}m${" ".repeat(10)}\x1b[0m`;
841
+ lines.push(border("│") + padLine(` Color: ${colorBlock}`) + border("│"));
842
+
843
+ lines.push(border("│") + padLine(``) + border("│"));
844
+ lines.push(border("│") + padLine(th.fg("dim", " This proves overlays can handle")) + border("│"));
845
+ lines.push(border("│") + padLine(th.fg("dim", " real-time game-like rendering.")) + border("│"));
846
+ lines.push(border("│") + padLine(th.fg("dim", " (pi-doom uses same approach)")) + border("│"));
847
+ lines.push(border("│") + padLine(``) + border("│"));
848
+ lines.push(border("│") + padLine(th.fg("dim", " Press Esc to close")) + border("│"));
849
+ lines.push(border(`╰${"─".repeat(innerW)}╯`));
850
+
851
+ return lines;
852
+ }
853
+
854
+ dispose(): void {
855
+ if (this.interval) {
856
+ clearInterval(this.interval);
857
+ this.interval = null;
858
+ }
859
+ }
860
+ }
861
+
862
+ // HSL to RGB helper for color cycling animation
863
+ function hslToRgb(h: number, s: number, l: number): [number, number, number] {
864
+ let r: number, g: number, b: number;
865
+ if (s === 0) {
866
+ r = g = b = l;
867
+ } else {
868
+ const hue2rgb = (p: number, q: number, t: number) => {
869
+ if (t < 0) t += 1;
870
+ if (t > 1) t -= 1;
871
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
872
+ if (t < 1 / 2) return q;
873
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
874
+ return p;
875
+ };
876
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
877
+ const p = 2 * l - q;
878
+ r = hue2rgb(p, q, h + 1 / 3);
879
+ g = hue2rgb(p, q, h);
880
+ b = hue2rgb(p, q, h - 1 / 3);
881
+ }
882
+ return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
883
+ }
884
+
885
+ // Toggle demo - demonstrates OverlayHandle.setHidden() via onHandle callback
886
+ class ToggleDemoComponent extends BaseOverlay {
887
+ private tui: TUI;
888
+ private toggleCount = 0;
889
+ private isToggling = false;
890
+ private done: () => void;
891
+
892
+ constructor(tui: TUI, theme: Theme, done: () => void) {
893
+ super(theme);
894
+ this.tui = tui;
895
+ this.done = done;
896
+ }
897
+
898
+ handleInput(data: string): void {
899
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
900
+ this.done();
901
+ } else if (matchesKey(data, "t") && globalToggleHandle && !this.isToggling) {
902
+ // Demonstrate toggle by hiding for 1 second then showing again
903
+ // (In real usage, a global keybinding would control visibility)
904
+ this.isToggling = true;
905
+ this.toggleCount++;
906
+ globalToggleHandle.setHidden(true);
907
+
908
+ // Auto-restore after 1 second to demonstrate the API
909
+ setTimeout(() => {
910
+ if (globalToggleHandle) {
911
+ globalToggleHandle.setHidden(false);
912
+ this.isToggling = false;
913
+ this.tui.requestRender();
914
+ }
915
+ }, 1000);
916
+ }
917
+ }
918
+
919
+ render(width: number): string[] {
920
+ const th = this.theme;
921
+ return this.box(
922
+ [
923
+ "",
924
+ th.fg("accent", " Toggle Demo"),
925
+ "",
926
+ " This overlay demonstrates the",
927
+ " onHandle callback API.",
928
+ "",
929
+ ` Toggle count: ${th.fg("accent", String(this.toggleCount))}`,
930
+ "",
931
+ th.fg("dim", " Press 't' to hide for 1 second"),
932
+ th.fg("dim", " (demonstrates setHidden API)"),
933
+ "",
934
+ th.fg("dim", " In real usage, a global keybinding"),
935
+ th.fg("dim", " would toggle visibility externally."),
936
+ "",
937
+ th.fg("dim", " Press Esc to close"),
938
+ "",
939
+ ],
940
+ width,
941
+ "Toggle Demo",
942
+ );
943
+ }
944
+ }
945
+
946
+ // === Non-capturing passive overlay demo ===
947
+
948
+ class PassiveDemoController extends BaseOverlay {
949
+ focused = false;
950
+ private tui: TUI;
951
+ private typed = "";
952
+ private timerComponent: TimerPanel;
953
+ private timerHandle: OverlayHandle | null = null;
954
+ private interval: ReturnType<typeof setInterval> | null = null;
955
+ private inputCount = 0;
956
+ private lastInputDebug = "";
957
+ private done: () => void;
958
+
959
+ constructor(tui: TUI, theme: Theme, done: () => void) {
960
+ super(theme);
961
+ this.tui = tui;
962
+ this.done = done;
963
+ this.timerComponent = new TimerPanel(theme);
964
+ this.timerHandle = this.tui.showOverlay(this.timerComponent, {
965
+ nonCapturing: true,
966
+ anchor: "top-right",
967
+ width: 22,
968
+ margin: { top: 1, right: 2 },
969
+ });
970
+ this.interval = setInterval(() => {
971
+ this.timerComponent.tick();
972
+ this.tui.requestRender();
973
+ }, 1000);
974
+ }
975
+
976
+ handleInput(data: string): void {
977
+ this.inputCount++;
978
+ this.lastInputDebug = `len=${data.length} c0=${data.charCodeAt(0)}`;
979
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
980
+ this.cleanup();
981
+ this.done();
982
+ } else if (matchesKey(data, "backspace")) {
983
+ this.typed = this.typed.slice(0, -1);
984
+ } else if (data.length === 1 && data.charCodeAt(0) >= 32) {
985
+ this.typed += data;
986
+ }
987
+ }
988
+
989
+ render(width: number): string[] {
990
+ const th = this.theme;
991
+ const display = this.typed.length > 0 ? this.typed : th.fg("dim", "(type here)");
992
+ return this.box(
993
+ [
994
+ "",
995
+ ` ${th.fg("dim", `focused=${this.focused} inputs=${this.inputCount}`)}`,
996
+ ` ${th.fg("dim", `last: ${this.lastInputDebug || "none"}`)}`,
997
+ "",
998
+ ` > ${display}`,
999
+ "",
1000
+ th.fg("dim", " Type to prove input goes here."),
1001
+ th.fg("dim", " Press Esc to close both."),
1002
+ "",
1003
+ ],
1004
+ width,
1005
+ "Non-Capturing Demo",
1006
+ );
1007
+ }
1008
+
1009
+ private cleanup(): void {
1010
+ if (this.interval) {
1011
+ clearInterval(this.interval);
1012
+ this.interval = null;
1013
+ }
1014
+ this.timerHandle?.hide();
1015
+ this.timerHandle = null;
1016
+ }
1017
+
1018
+ override dispose(): void {
1019
+ this.cleanup();
1020
+ }
1021
+ }
1022
+
1023
+ class TimerPanel extends BaseOverlay {
1024
+ private seconds = 0;
1025
+
1026
+ tick(): void {
1027
+ this.seconds++;
1028
+ }
1029
+
1030
+ render(width: number): string[] {
1031
+ const th = this.theme;
1032
+ const mins = Math.floor(this.seconds / 60);
1033
+ const secs = this.seconds % 60;
1034
+ const time = `${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
1035
+ return this.box([` ${th.fg("accent", time)}`, th.fg("dim", " nonCapturing: true")], width, "Timer");
1036
+ }
1037
+ }
1038
+
1039
+ // === Focus cycling demo ===
1040
+
1041
+ class FocusDemoController extends BaseOverlay {
1042
+ private tui: TUI;
1043
+ private panels: FocusPanel[] = [];
1044
+ private handles: OverlayHandle[] = [];
1045
+ private focusIndex = -1;
1046
+ private done: () => void;
1047
+
1048
+ constructor(tui: TUI, theme: Theme, done: () => void) {
1049
+ super(theme);
1050
+ this.tui = tui;
1051
+ this.done = done;
1052
+ const colors = ["error", "success", "accent"] as const;
1053
+ const labels = ["Alpha", "Beta", "Gamma"];
1054
+
1055
+ for (let i = 0; i < 3; i++) {
1056
+ const panel = new FocusPanel(
1057
+ theme,
1058
+ labels[i]!,
1059
+ colors[i]!,
1060
+ () => this.cycleFocus(),
1061
+ () => this.close(),
1062
+ );
1063
+ const handle = this.tui.showOverlay(panel, {
1064
+ nonCapturing: true,
1065
+ row: 2,
1066
+ col: 5 + i * 6,
1067
+ width: 28,
1068
+ });
1069
+ panel.handle = handle;
1070
+ this.panels.push(panel);
1071
+ this.handles.push(handle);
1072
+ }
1073
+ }
1074
+
1075
+ private cycleFocus(): void {
1076
+ if (this.focusIndex >= 0 && this.focusIndex < this.handles.length) {
1077
+ this.handles[this.focusIndex]!.unfocus();
1078
+ }
1079
+ this.focusIndex++;
1080
+ if (this.focusIndex >= this.handles.length) {
1081
+ this.focusIndex = -1;
1082
+ } else {
1083
+ this.handles[this.focusIndex]!.focus();
1084
+ }
1085
+ this.tui.requestRender();
1086
+ }
1087
+
1088
+ private close(): void {
1089
+ for (const handle of this.handles) handle.hide();
1090
+ this.handles = [];
1091
+ this.panels = [];
1092
+ this.done();
1093
+ }
1094
+
1095
+ handleInput(data: string): void {
1096
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
1097
+ this.close();
1098
+ } else if (matchesKey(data, "tab")) {
1099
+ this.cycleFocus();
1100
+ }
1101
+ }
1102
+
1103
+ render(width: number): string[] {
1104
+ const th = this.theme;
1105
+ const focused = this.focusIndex === -1 ? "Controller" : (this.panels[this.focusIndex]?.label ?? "?");
1106
+ return this.box(
1107
+ [
1108
+ "",
1109
+ ` Current focus: ${th.fg("accent", focused)}`,
1110
+ "",
1111
+ " Three overlapping panels above are",
1112
+ ` all ${th.fg("accent", "nonCapturing")}. Press Tab to`,
1113
+ " cycle focus() between them.",
1114
+ "",
1115
+ " Focused panel renders on top",
1116
+ " (focus-based rendering order).",
1117
+ "",
1118
+ th.fg("dim", " Tab = cycle focus | Esc = close"),
1119
+ "",
1120
+ ],
1121
+ width,
1122
+ "Focus Demo",
1123
+ );
1124
+ }
1125
+
1126
+ override dispose(): void {
1127
+ for (const handle of this.handles) handle.hide();
1128
+ }
1129
+ }
1130
+
1131
+ class FocusPanel extends BaseOverlay {
1132
+ handle: OverlayHandle | null = null;
1133
+ readonly label: string;
1134
+ private color: OverlayPanelColor;
1135
+ private onTab: () => void;
1136
+ private onClose: () => void;
1137
+
1138
+ constructor(theme: Theme, label: string, color: OverlayPanelColor, onTab: () => void, onClose: () => void) {
1139
+ super(theme);
1140
+ this.label = label;
1141
+ this.color = color;
1142
+ this.onTab = onTab;
1143
+ this.onClose = onClose;
1144
+ }
1145
+
1146
+ handleInput(data: string): void {
1147
+ if (matchesKey(data, "tab")) {
1148
+ this.onTab();
1149
+ } else if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
1150
+ this.onClose();
1151
+ }
1152
+ }
1153
+
1154
+ render(width: number): string[] {
1155
+ const th = this.theme;
1156
+ const focused = this.handle?.isFocused() ?? false;
1157
+ const innerW = Math.max(1, width - 2);
1158
+ const border = (c: string) => th.fg(this.color, c);
1159
+ const padLine = (s: string) => truncateToWidth(s, innerW, "...", true);
1160
+ const lines: string[] = [];
1161
+
1162
+ lines.push(border(`╭${"─".repeat(innerW)}╮`));
1163
+ lines.push(border("│") + padLine(` ${th.fg("accent", this.label)}`) + border("│"));
1164
+ lines.push(border("│") + padLine("") + border("│"));
1165
+ if (focused) {
1166
+ lines.push(border("│") + padLine(th.fg("success", " ● FOCUSED")) + border("│"));
1167
+ lines.push(border("│") + padLine(th.fg("dim", " (receiving input)")) + border("│"));
1168
+ } else {
1169
+ lines.push(border("│") + padLine(th.fg("dim", " ○ unfocused")) + border("│"));
1170
+ lines.push(border("│") + padLine(th.fg("dim", " (passive)")) + border("│"));
1171
+ }
1172
+ lines.push(border("│") + padLine("") + border("│"));
1173
+ lines.push(border(`╰${"─".repeat(innerW)}╯`));
1174
+
1175
+ return lines;
1176
+ }
1177
+ }
1178
+
1179
+ // === Streaming input panel test (/overlay-streaming) ===
1180
+
1181
+ class StreamingInputController extends BaseOverlay {
1182
+ private tui: TUI;
1183
+ private panels: StreamingInputPanel[] = [];
1184
+ private handles: OverlayHandle[] = [];
1185
+ private focusIndex = -1; // -1 = controller focused, 0-2 = panel focused
1186
+ private streamLines: string[] = [];
1187
+ private streamInterval: ReturnType<typeof setInterval> | null = null;
1188
+ private lineCount = 0;
1189
+ private done: () => void;
1190
+
1191
+ constructor(tui: TUI, theme: Theme, done: () => void) {
1192
+ super(theme);
1193
+ this.tui = tui;
1194
+ this.done = done;
1195
+
1196
+ // Create 3 input panels as non-capturing overlays
1197
+ const colors = ["error", "success", "accent"] as const;
1198
+ const labels = ["Panel A", "Panel B", "Panel C"];
1199
+
1200
+ for (let i = 0; i < 3; i++) {
1201
+ const panel = new StreamingInputPanel(
1202
+ theme,
1203
+ labels[i]!,
1204
+ colors[i]!,
1205
+ () => this.cycleFocus(),
1206
+ () => this.close(),
1207
+ );
1208
+ const handle = this.tui.showOverlay(panel, {
1209
+ nonCapturing: true,
1210
+ row: 1 + i * 9,
1211
+ col: 2,
1212
+ width: 35,
1213
+ });
1214
+ panel.handle = handle;
1215
+ this.panels.push(panel);
1216
+ this.handles.push(handle);
1217
+ }
1218
+
1219
+ // Start with controller focused (focusIndex = -1)
1220
+
1221
+ // Start simulated streaming
1222
+ this.streamInterval = setInterval(() => {
1223
+ this.lineCount++;
1224
+ const timestamp = new Date().toLocaleTimeString();
1225
+ this.streamLines.push(`[${timestamp}] Streaming line ${this.lineCount}...`);
1226
+ if (this.streamLines.length > 8) {
1227
+ this.streamLines.shift();
1228
+ }
1229
+ this.tui.requestRender();
1230
+ }, 500);
1231
+ }
1232
+
1233
+ private cycleFocus(): void {
1234
+ // Unfocus current panel if any
1235
+ if (this.focusIndex >= 0 && this.focusIndex < this.handles.length) {
1236
+ this.handles[this.focusIndex]!.unfocus();
1237
+ }
1238
+
1239
+ // Cycle: -1 (controller) → 0 → 1 → 2 → -1 ...
1240
+ this.focusIndex++;
1241
+ if (this.focusIndex >= this.handles.length) {
1242
+ this.focusIndex = -1; // Back to controller
1243
+ }
1244
+
1245
+ // Focus new panel if any
1246
+ if (this.focusIndex >= 0) {
1247
+ this.handles[this.focusIndex]!.focus();
1248
+ }
1249
+
1250
+ this.tui.requestRender();
1251
+ }
1252
+
1253
+ private close(): void {
1254
+ if (this.streamInterval) {
1255
+ clearInterval(this.streamInterval);
1256
+ this.streamInterval = null;
1257
+ }
1258
+ for (const handle of this.handles) handle.hide();
1259
+ this.handles = [];
1260
+ this.panels = [];
1261
+ this.done();
1262
+ }
1263
+
1264
+ handleInput(data: string): void {
1265
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
1266
+ this.close();
1267
+ } else if (matchesKey(data, "tab")) {
1268
+ this.cycleFocus();
1269
+ }
1270
+ }
1271
+
1272
+ render(width: number): string[] {
1273
+ const th = this.theme;
1274
+ const focusedLabel =
1275
+ this.focusIndex === -1
1276
+ ? th.fg("success", "Controller (this panel)")
1277
+ : (this.panels[this.focusIndex]?.label ?? "?");
1278
+
1279
+ const lines = [
1280
+ "",
1281
+ ` Current focus: ${th.fg("accent", focusedLabel)}`,
1282
+ "",
1283
+ " Simulated streaming output:",
1284
+ th.fg("dim", " ─".repeat((width - 2) / 2)),
1285
+ ];
1286
+
1287
+ for (const line of this.streamLines) {
1288
+ lines.push(` ${th.fg("dim", line)}`);
1289
+ }
1290
+
1291
+ while (lines.length < 12) {
1292
+ lines.push("");
1293
+ }
1294
+
1295
+ lines.push(th.fg("dim", " ─".repeat((width - 2) / 2)));
1296
+ lines.push("");
1297
+ lines.push(` Three ${th.fg("accent", "nonCapturing")} input panels on the left.`);
1298
+ lines.push(" Tab cycles: Controller → Panel A → B → C → Controller");
1299
+ lines.push(" Type in each panel to test input routing.");
1300
+ lines.push("");
1301
+ lines.push(th.fg("dim", " Tab = cycle focus | Esc = close all"));
1302
+ lines.push("");
1303
+
1304
+ return this.box(lines, width, "Streaming + Input Test");
1305
+ }
1306
+
1307
+ override dispose(): void {
1308
+ this.close();
1309
+ }
1310
+ }
1311
+
1312
+ class StreamingInputPanel implements Component {
1313
+ handle: OverlayHandle | null = null;
1314
+ private theme: Theme;
1315
+ private typed = "";
1316
+ readonly label: string;
1317
+ private color: OverlayPanelColor;
1318
+ private onTab: () => void;
1319
+ private onClose: () => void;
1320
+
1321
+ constructor(theme: Theme, label: string, color: OverlayPanelColor, onTab: () => void, onClose: () => void) {
1322
+ this.theme = theme;
1323
+ this.label = label;
1324
+ this.color = color;
1325
+ this.onTab = onTab;
1326
+ this.onClose = onClose;
1327
+ }
1328
+
1329
+ handleInput(data: string): void {
1330
+ if (matchesKey(data, "tab")) {
1331
+ this.onTab();
1332
+ } else if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
1333
+ this.onClose();
1334
+ } else if (matchesKey(data, "backspace")) {
1335
+ this.typed = this.typed.slice(0, -1);
1336
+ } else if (data.length === 1 && data.charCodeAt(0) >= 32) {
1337
+ this.typed += data;
1338
+ }
1339
+ }
1340
+
1341
+ render(width: number): string[] {
1342
+ const th = this.theme;
1343
+ const focused = this.handle?.isFocused() ?? false;
1344
+ const innerW = Math.max(1, width - 2);
1345
+ const border = (c: string) => th.fg(this.color, c);
1346
+ const padLine = (s: string) => {
1347
+ const w = visibleWidth(s);
1348
+ return s + " ".repeat(Math.max(0, innerW - w));
1349
+ };
1350
+
1351
+ const inputDisplay = this.typed.length > 0 ? this.typed : th.fg("dim", "(type here)");
1352
+ const truncatedInput = truncateToWidth(` > ${inputDisplay}`, innerW, "...", true);
1353
+
1354
+ const lines: string[] = [];
1355
+ lines.push(border(`╭${"─".repeat(innerW)}╮`));
1356
+ lines.push(border("│") + padLine(` ${th.fg("accent", this.label)}`) + border("│"));
1357
+ lines.push(border("│") + padLine("") + border("│"));
1358
+ if (focused) {
1359
+ lines.push(border("│") + padLine(th.fg("success", " ● FOCUSED")) + border("│"));
1360
+ lines.push(border("│") + padLine(th.fg("dim", " (receiving input)")) + border("│"));
1361
+ } else {
1362
+ lines.push(border("│") + padLine(th.fg("dim", " ○ unfocused")) + border("│"));
1363
+ lines.push(border("│") + padLine("") + border("│"));
1364
+ }
1365
+ lines.push(border("│") + padLine(truncatedInput) + border("│"));
1366
+ lines.push(border("│") + padLine("") + border("│"));
1367
+ lines.push(border("│") + padLine(th.fg("dim", " Tab | Esc")) + border("│"));
1368
+ lines.push(border(`╰${"─".repeat(innerW)}╯`));
1369
+
1370
+ return lines;
1371
+ }
1372
+
1373
+ invalidate(): void {}
1374
+ }