@tuan_son.dinh/gsd 2.6.2 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1024) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +24 -10
  3. package/dist/loader.js +21 -3
  4. package/dist/logo.d.ts +3 -3
  5. package/dist/logo.js +2 -2
  6. package/dist/onboarding.d.ts +3 -3
  7. package/dist/onboarding.js +3 -4
  8. package/dist/pi-migration.d.ts +5 -1
  9. package/dist/pi-migration.js +19 -2
  10. package/dist/resource-loader.d.ts +2 -1
  11. package/dist/resource-loader.js +60 -4
  12. package/dist/wizard.d.ts +1 -1
  13. package/package.json +12 -6
  14. package/packages/pi-agent-core/dist/agent-loop.d.ts +21 -0
  15. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -0
  16. package/packages/pi-agent-core/dist/agent-loop.js +308 -0
  17. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -0
  18. package/packages/pi-agent-core/dist/agent.d.ts +162 -0
  19. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -0
  20. package/packages/pi-agent-core/dist/agent.js +399 -0
  21. package/packages/pi-agent-core/dist/agent.js.map +1 -0
  22. package/packages/pi-agent-core/dist/index.d.ts +5 -0
  23. package/packages/pi-agent-core/dist/index.d.ts.map +1 -0
  24. package/packages/pi-agent-core/dist/index.js +9 -0
  25. package/packages/pi-agent-core/dist/index.js.map +1 -0
  26. package/packages/pi-agent-core/dist/proxy.d.ts +85 -0
  27. package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -0
  28. package/packages/pi-agent-core/dist/proxy.js +268 -0
  29. package/packages/pi-agent-core/dist/proxy.js.map +1 -0
  30. package/packages/pi-agent-core/dist/types.d.ts +178 -0
  31. package/packages/pi-agent-core/dist/types.d.ts.map +1 -0
  32. package/packages/pi-agent-core/dist/types.js +2 -0
  33. package/packages/pi-agent-core/dist/types.js.map +1 -0
  34. package/packages/pi-agent-core/package.json +14 -0
  35. package/packages/pi-agent-core/src/agent-loop.ts +417 -0
  36. package/packages/pi-agent-core/src/agent.ts +568 -0
  37. package/packages/pi-agent-core/src/index.ts +8 -0
  38. package/packages/pi-agent-core/src/proxy.ts +340 -0
  39. package/packages/pi-agent-core/src/types.ts +194 -0
  40. package/packages/pi-agent-core/tsconfig.json +27 -0
  41. package/packages/pi-ai/bedrock-provider.d.ts +1 -0
  42. package/packages/pi-ai/bedrock-provider.js +1 -0
  43. package/packages/pi-ai/dist/api-registry.d.ts +20 -0
  44. package/packages/pi-ai/dist/api-registry.d.ts.map +1 -0
  45. package/packages/pi-ai/dist/api-registry.js +44 -0
  46. package/packages/pi-ai/dist/api-registry.js.map +1 -0
  47. package/packages/pi-ai/dist/bedrock-provider.d.ts +5 -0
  48. package/packages/pi-ai/dist/bedrock-provider.d.ts.map +1 -0
  49. package/packages/pi-ai/dist/bedrock-provider.js +6 -0
  50. package/packages/pi-ai/dist/bedrock-provider.js.map +1 -0
  51. package/packages/pi-ai/dist/cli.d.ts +3 -0
  52. package/packages/pi-ai/dist/cli.d.ts.map +1 -0
  53. package/packages/pi-ai/dist/cli.js +116 -0
  54. package/packages/pi-ai/dist/cli.js.map +1 -0
  55. package/packages/pi-ai/dist/env-api-keys.d.ts +9 -0
  56. package/packages/pi-ai/dist/env-api-keys.d.ts.map +1 -0
  57. package/packages/pi-ai/dist/env-api-keys.js +104 -0
  58. package/packages/pi-ai/dist/env-api-keys.js.map +1 -0
  59. package/packages/pi-ai/dist/index.d.ts +23 -0
  60. package/packages/pi-ai/dist/index.d.ts.map +1 -0
  61. package/packages/pi-ai/dist/index.js +21 -0
  62. package/packages/pi-ai/dist/index.js.map +1 -0
  63. package/packages/pi-ai/dist/models.d.ts +24 -0
  64. package/packages/pi-ai/dist/models.d.ts.map +1 -0
  65. package/packages/pi-ai/dist/models.generated.d.ts +13572 -0
  66. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -0
  67. package/packages/pi-ai/dist/models.generated.js +13368 -0
  68. package/packages/pi-ai/dist/models.generated.js.map +1 -0
  69. package/packages/pi-ai/dist/models.js +55 -0
  70. package/packages/pi-ai/dist/models.js.map +1 -0
  71. package/packages/pi-ai/dist/oauth.d.ts +2 -0
  72. package/packages/pi-ai/dist/oauth.d.ts.map +1 -0
  73. package/packages/pi-ai/dist/oauth.js +2 -0
  74. package/packages/pi-ai/dist/oauth.js.map +1 -0
  75. package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts +15 -0
  76. package/packages/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
  77. package/packages/pi-ai/dist/providers/amazon-bedrock.js +600 -0
  78. package/packages/pi-ai/dist/providers/amazon-bedrock.js.map +1 -0
  79. package/packages/pi-ai/dist/providers/anthropic.d.ts +33 -0
  80. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -0
  81. package/packages/pi-ai/dist/providers/anthropic.js +732 -0
  82. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -0
  83. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts +15 -0
  84. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
  85. package/packages/pi-ai/dist/providers/azure-openai-responses.js +187 -0
  86. package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -0
  87. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +8 -0
  88. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
  89. package/packages/pi-ai/dist/providers/github-copilot-headers.js +29 -0
  90. package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -0
  91. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +74 -0
  92. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -0
  93. package/packages/pi-ai/dist/providers/google-gemini-cli.js +757 -0
  94. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -0
  95. package/packages/pi-ai/dist/providers/google-shared.d.ts +65 -0
  96. package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -0
  97. package/packages/pi-ai/dist/providers/google-shared.js +300 -0
  98. package/packages/pi-ai/dist/providers/google-shared.js.map +1 -0
  99. package/packages/pi-ai/dist/providers/google-vertex.d.ts +15 -0
  100. package/packages/pi-ai/dist/providers/google-vertex.d.ts.map +1 -0
  101. package/packages/pi-ai/dist/providers/google-vertex.js +374 -0
  102. package/packages/pi-ai/dist/providers/google-vertex.js.map +1 -0
  103. package/packages/pi-ai/dist/providers/google.d.ts +13 -0
  104. package/packages/pi-ai/dist/providers/google.d.ts.map +1 -0
  105. package/packages/pi-ai/dist/providers/google.js +355 -0
  106. package/packages/pi-ai/dist/providers/google.js.map +1 -0
  107. package/packages/pi-ai/dist/providers/mistral.d.ts +22 -0
  108. package/packages/pi-ai/dist/providers/mistral.d.ts.map +1 -0
  109. package/packages/pi-ai/dist/providers/mistral.js +498 -0
  110. package/packages/pi-ai/dist/providers/mistral.js.map +1 -0
  111. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts +9 -0
  112. package/packages/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
  113. package/packages/pi-ai/dist/providers/openai-codex-responses.js +704 -0
  114. package/packages/pi-ai/dist/providers/openai-codex-responses.js.map +1 -0
  115. package/packages/pi-ai/dist/providers/openai-completions.d.ts +15 -0
  116. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -0
  117. package/packages/pi-ai/dist/providers/openai-completions.js +705 -0
  118. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -0
  119. package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts +17 -0
  120. package/packages/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
  121. package/packages/pi-ai/dist/providers/openai-responses-shared.js +442 -0
  122. package/packages/pi-ai/dist/providers/openai-responses-shared.js.map +1 -0
  123. package/packages/pi-ai/dist/providers/openai-responses.d.ts +13 -0
  124. package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -0
  125. package/packages/pi-ai/dist/providers/openai-responses.js +201 -0
  126. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -0
  127. package/packages/pi-ai/dist/providers/register-builtins.d.ts +11 -0
  128. package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -0
  129. package/packages/pi-ai/dist/providers/register-builtins.js +138 -0
  130. package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -0
  131. package/packages/pi-ai/dist/providers/simple-options.d.ts +8 -0
  132. package/packages/pi-ai/dist/providers/simple-options.d.ts.map +1 -0
  133. package/packages/pi-ai/dist/providers/simple-options.js +35 -0
  134. package/packages/pi-ai/dist/providers/simple-options.js.map +1 -0
  135. package/packages/pi-ai/dist/providers/transform-messages.d.ts +8 -0
  136. package/packages/pi-ai/dist/providers/transform-messages.d.ts.map +1 -0
  137. package/packages/pi-ai/dist/providers/transform-messages.js +155 -0
  138. package/packages/pi-ai/dist/providers/transform-messages.js.map +1 -0
  139. package/packages/pi-ai/dist/stream.d.ts +8 -0
  140. package/packages/pi-ai/dist/stream.d.ts.map +1 -0
  141. package/packages/pi-ai/dist/stream.js +27 -0
  142. package/packages/pi-ai/dist/stream.js.map +1 -0
  143. package/packages/pi-ai/dist/types.d.ts +285 -0
  144. package/packages/pi-ai/dist/types.d.ts.map +1 -0
  145. package/packages/pi-ai/dist/types.js +2 -0
  146. package/packages/pi-ai/dist/types.js.map +1 -0
  147. package/packages/pi-ai/dist/utils/event-stream.d.ts +21 -0
  148. package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -0
  149. package/packages/pi-ai/dist/utils/event-stream.js +77 -0
  150. package/packages/pi-ai/dist/utils/event-stream.js.map +1 -0
  151. package/packages/pi-ai/dist/utils/hash.d.ts +3 -0
  152. package/packages/pi-ai/dist/utils/hash.d.ts.map +1 -0
  153. package/packages/pi-ai/dist/utils/hash.js +14 -0
  154. package/packages/pi-ai/dist/utils/hash.js.map +1 -0
  155. package/packages/pi-ai/dist/utils/json-parse.d.ts +9 -0
  156. package/packages/pi-ai/dist/utils/json-parse.d.ts.map +1 -0
  157. package/packages/pi-ai/dist/utils/json-parse.js +29 -0
  158. package/packages/pi-ai/dist/utils/json-parse.js.map +1 -0
  159. package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts +17 -0
  160. package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
  161. package/packages/pi-ai/dist/utils/oauth/anthropic.js +104 -0
  162. package/packages/pi-ai/dist/utils/oauth/anthropic.js.map +1 -0
  163. package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
  164. package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
  165. package/packages/pi-ai/dist/utils/oauth/github-copilot.js +281 -0
  166. package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -0
  167. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts +26 -0
  168. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -0
  169. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +373 -0
  170. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -0
  171. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts +26 -0
  172. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -0
  173. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +478 -0
  174. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -0
  175. package/packages/pi-ai/dist/utils/oauth/index.d.ts +61 -0
  176. package/packages/pi-ai/dist/utils/oauth/index.d.ts.map +1 -0
  177. package/packages/pi-ai/dist/utils/oauth/index.js +131 -0
  178. package/packages/pi-ai/dist/utils/oauth/index.js.map +1 -0
  179. package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts +34 -0
  180. package/packages/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
  181. package/packages/pi-ai/dist/utils/oauth/openai-codex.js +380 -0
  182. package/packages/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -0
  183. package/packages/pi-ai/dist/utils/oauth/pkce.d.ts +13 -0
  184. package/packages/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
  185. package/packages/pi-ai/dist/utils/oauth/pkce.js +31 -0
  186. package/packages/pi-ai/dist/utils/oauth/pkce.js.map +1 -0
  187. package/packages/pi-ai/dist/utils/oauth/types.d.ts +47 -0
  188. package/packages/pi-ai/dist/utils/oauth/types.d.ts.map +1 -0
  189. package/packages/pi-ai/dist/utils/oauth/types.js +2 -0
  190. package/packages/pi-ai/dist/utils/oauth/types.js.map +1 -0
  191. package/packages/pi-ai/dist/utils/overflow.d.ts +52 -0
  192. package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -0
  193. package/packages/pi-ai/dist/utils/overflow.js +117 -0
  194. package/packages/pi-ai/dist/utils/overflow.js.map +1 -0
  195. package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts +22 -0
  196. package/packages/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
  197. package/packages/pi-ai/dist/utils/sanitize-unicode.js +26 -0
  198. package/packages/pi-ai/dist/utils/sanitize-unicode.js.map +1 -0
  199. package/packages/pi-ai/dist/utils/typebox-helpers.d.ts +17 -0
  200. package/packages/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
  201. package/packages/pi-ai/dist/utils/typebox-helpers.js +21 -0
  202. package/packages/pi-ai/dist/utils/typebox-helpers.js.map +1 -0
  203. package/packages/pi-ai/dist/utils/validation.d.ts +18 -0
  204. package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -0
  205. package/packages/pi-ai/dist/utils/validation.js +72 -0
  206. package/packages/pi-ai/dist/utils/validation.js.map +1 -0
  207. package/packages/pi-ai/package.json +40 -0
  208. package/packages/pi-ai/src/api-registry.ts +98 -0
  209. package/packages/pi-ai/src/bedrock-provider.ts +6 -0
  210. package/packages/pi-ai/src/cli.ts +133 -0
  211. package/packages/pi-ai/src/env-api-keys.ts +129 -0
  212. package/packages/pi-ai/src/index.ts +32 -0
  213. package/packages/pi-ai/src/models.generated.ts +13370 -0
  214. package/packages/pi-ai/src/models.ts +77 -0
  215. package/packages/pi-ai/src/oauth.ts +1 -0
  216. package/packages/pi-ai/src/providers/amazon-bedrock.ts +751 -0
  217. package/packages/pi-ai/src/providers/anthropic.ts +883 -0
  218. package/packages/pi-ai/src/providers/azure-openai-responses.ts +259 -0
  219. package/packages/pi-ai/src/providers/github-copilot-headers.ts +37 -0
  220. package/packages/pi-ai/src/providers/google-gemini-cli.ts +967 -0
  221. package/packages/pi-ai/src/providers/google-shared.ts +313 -0
  222. package/packages/pi-ai/src/providers/google-vertex.ts +485 -0
  223. package/packages/pi-ai/src/providers/google.ts +455 -0
  224. package/packages/pi-ai/src/providers/mistral.ts +582 -0
  225. package/packages/pi-ai/src/providers/openai-codex-responses.ts +875 -0
  226. package/packages/pi-ai/src/providers/openai-completions.ts +820 -0
  227. package/packages/pi-ai/src/providers/openai-responses-shared.ts +496 -0
  228. package/packages/pi-ai/src/providers/openai-responses.ts +262 -0
  229. package/packages/pi-ai/src/providers/register-builtins.ts +186 -0
  230. package/packages/pi-ai/src/providers/simple-options.ts +46 -0
  231. package/packages/pi-ai/src/providers/transform-messages.ts +172 -0
  232. package/packages/pi-ai/src/stream.ts +59 -0
  233. package/packages/pi-ai/src/types.ts +321 -0
  234. package/packages/pi-ai/src/utils/event-stream.ts +87 -0
  235. package/packages/pi-ai/src/utils/hash.ts +13 -0
  236. package/packages/pi-ai/src/utils/json-parse.ts +28 -0
  237. package/packages/pi-ai/src/utils/oauth/anthropic.ts +138 -0
  238. package/packages/pi-ai/src/utils/oauth/github-copilot.ts +381 -0
  239. package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +457 -0
  240. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +599 -0
  241. package/packages/pi-ai/src/utils/oauth/index.ts +162 -0
  242. package/packages/pi-ai/src/utils/oauth/openai-codex.ts +455 -0
  243. package/packages/pi-ai/src/utils/oauth/pkce.ts +34 -0
  244. package/packages/pi-ai/src/utils/oauth/types.ts +59 -0
  245. package/packages/pi-ai/src/utils/overflow.ts +123 -0
  246. package/packages/pi-ai/src/utils/sanitize-unicode.ts +25 -0
  247. package/packages/pi-ai/src/utils/typebox-helpers.ts +24 -0
  248. package/packages/pi-ai/src/utils/validation.ts +84 -0
  249. package/packages/pi-ai/tsconfig.json +27 -0
  250. package/packages/pi-coding-agent/dist/cli/args.d.ts +48 -0
  251. package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -0
  252. package/packages/pi-coding-agent/dist/cli/args.js +299 -0
  253. package/packages/pi-coding-agent/dist/cli/args.js.map +1 -0
  254. package/packages/pi-coding-agent/dist/cli/config-selector.d.ts +14 -0
  255. package/packages/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -0
  256. package/packages/pi-coding-agent/dist/cli/config-selector.js +31 -0
  257. package/packages/pi-coding-agent/dist/cli/config-selector.js.map +1 -0
  258. package/packages/pi-coding-agent/dist/cli/file-processor.d.ts +15 -0
  259. package/packages/pi-coding-agent/dist/cli/file-processor.d.ts.map +1 -0
  260. package/packages/pi-coding-agent/dist/cli/file-processor.js +79 -0
  261. package/packages/pi-coding-agent/dist/cli/file-processor.js.map +1 -0
  262. package/packages/pi-coding-agent/dist/cli/list-models.d.ts +9 -0
  263. package/packages/pi-coding-agent/dist/cli/list-models.d.ts.map +1 -0
  264. package/packages/pi-coding-agent/dist/cli/list-models.js +92 -0
  265. package/packages/pi-coding-agent/dist/cli/list-models.js.map +1 -0
  266. package/packages/pi-coding-agent/dist/cli/session-picker.d.ts +9 -0
  267. package/packages/pi-coding-agent/dist/cli/session-picker.d.ts.map +1 -0
  268. package/packages/pi-coding-agent/dist/cli/session-picker.js +34 -0
  269. package/packages/pi-coding-agent/dist/cli/session-picker.js.map +1 -0
  270. package/packages/pi-coding-agent/dist/cli.d.ts +3 -0
  271. package/packages/pi-coding-agent/dist/cli.d.ts.map +1 -0
  272. package/packages/pi-coding-agent/dist/cli.js +16 -0
  273. package/packages/pi-coding-agent/dist/cli.js.map +1 -0
  274. package/packages/pi-coding-agent/dist/config.d.ts +68 -0
  275. package/packages/pi-coding-agent/dist/config.d.ts.map +1 -0
  276. package/packages/pi-coding-agent/dist/config.js +203 -0
  277. package/packages/pi-coding-agent/dist/config.js.map +1 -0
  278. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +618 -0
  279. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -0
  280. package/packages/pi-coding-agent/dist/core/agent-session.js +2481 -0
  281. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -0
  282. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +134 -0
  283. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -0
  284. package/packages/pi-coding-agent/dist/core/auth-storage.js +415 -0
  285. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -0
  286. package/packages/pi-coding-agent/dist/core/bash-executor.d.ts +47 -0
  287. package/packages/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -0
  288. package/packages/pi-coding-agent/dist/core/bash-executor.js +212 -0
  289. package/packages/pi-coding-agent/dist/core/bash-executor.js.map +1 -0
  290. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts +86 -0
  291. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  292. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +242 -0
  293. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -0
  294. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts +121 -0
  295. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -0
  296. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +610 -0
  297. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -0
  298. package/packages/pi-coding-agent/dist/core/compaction/index.d.ts +7 -0
  299. package/packages/pi-coding-agent/dist/core/compaction/index.d.ts.map +1 -0
  300. package/packages/pi-coding-agent/dist/core/compaction/index.js +7 -0
  301. package/packages/pi-coding-agent/dist/core/compaction/index.js.map +1 -0
  302. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +38 -0
  303. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -0
  304. package/packages/pi-coding-agent/dist/core/compaction/utils.js +153 -0
  305. package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -0
  306. package/packages/pi-coding-agent/dist/core/defaults.d.ts +3 -0
  307. package/packages/pi-coding-agent/dist/core/defaults.d.ts.map +1 -0
  308. package/packages/pi-coding-agent/dist/core/defaults.js +2 -0
  309. package/packages/pi-coding-agent/dist/core/defaults.js.map +1 -0
  310. package/packages/pi-coding-agent/dist/core/diagnostics.d.ts +15 -0
  311. package/packages/pi-coding-agent/dist/core/diagnostics.d.ts.map +1 -0
  312. package/packages/pi-coding-agent/dist/core/diagnostics.js +2 -0
  313. package/packages/pi-coding-agent/dist/core/diagnostics.js.map +1 -0
  314. package/packages/pi-coding-agent/dist/core/event-bus.d.ts +9 -0
  315. package/packages/pi-coding-agent/dist/core/event-bus.d.ts.map +1 -0
  316. package/packages/pi-coding-agent/dist/core/event-bus.js +25 -0
  317. package/packages/pi-coding-agent/dist/core/event-bus.js.map +1 -0
  318. package/packages/pi-coding-agent/dist/core/exec.d.ts +29 -0
  319. package/packages/pi-coding-agent/dist/core/exec.d.ts.map +1 -0
  320. package/packages/pi-coding-agent/dist/core/exec.js +71 -0
  321. package/packages/pi-coding-agent/dist/core/exec.js.map +1 -0
  322. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +22 -0
  323. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  324. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +249 -0
  325. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -0
  326. package/packages/pi-coding-agent/dist/core/export-html/index.d.ts +37 -0
  327. package/packages/pi-coding-agent/dist/core/export-html/index.d.ts.map +1 -0
  328. package/packages/pi-coding-agent/dist/core/export-html/index.js +223 -0
  329. package/packages/pi-coding-agent/dist/core/export-html/index.js.map +1 -0
  330. package/packages/pi-coding-agent/dist/core/export-html/template.css +971 -0
  331. package/packages/pi-coding-agent/dist/core/export-html/template.html +54 -0
  332. package/packages/pi-coding-agent/dist/core/export-html/template.js +1583 -0
  333. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts +38 -0
  334. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  335. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js +70 -0
  336. package/packages/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -0
  337. package/packages/pi-coding-agent/dist/core/export-html/vendor/.gitkeep +0 -0
  338. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +11 -0
  339. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -0
  340. package/packages/pi-coding-agent/dist/core/extensions/index.js +9 -0
  341. package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -0
  342. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +25 -0
  343. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -0
  344. package/packages/pi-coding-agent/dist/core/extensions/loader.js +426 -0
  345. package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -0
  346. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +147 -0
  347. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -0
  348. package/packages/pi-coding-agent/dist/core/extensions/runner.js +672 -0
  349. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -0
  350. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +1040 -0
  351. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -0
  352. package/packages/pi-coding-agent/dist/core/extensions/types.js +35 -0
  353. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -0
  354. package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts +27 -0
  355. package/packages/pi-coding-agent/dist/core/extensions/wrapper.d.ts.map +1 -0
  356. package/packages/pi-coding-agent/dist/core/extensions/wrapper.js +102 -0
  357. package/packages/pi-coding-agent/dist/core/extensions/wrapper.js.map +1 -0
  358. package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts +32 -0
  359. package/packages/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -0
  360. package/packages/pi-coding-agent/dist/core/footer-data-provider.js +134 -0
  361. package/packages/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -0
  362. package/packages/pi-coding-agent/dist/core/index.d.ts +9 -0
  363. package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -0
  364. package/packages/pi-coding-agent/dist/core/index.js +9 -0
  365. package/packages/pi-coding-agent/dist/core/index.js.map +1 -0
  366. package/packages/pi-coding-agent/dist/core/keybindings.d.ts +55 -0
  367. package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -0
  368. package/packages/pi-coding-agent/dist/core/keybindings.js +151 -0
  369. package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -0
  370. package/packages/pi-coding-agent/dist/core/messages.d.ts +77 -0
  371. package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -0
  372. package/packages/pi-coding-agent/dist/core/messages.js +123 -0
  373. package/packages/pi-coding-agent/dist/core/messages.js.map +1 -0
  374. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +113 -0
  375. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -0
  376. package/packages/pi-coding-agent/dist/core/model-registry.js +537 -0
  377. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -0
  378. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +104 -0
  379. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -0
  380. package/packages/pi-coding-agent/dist/core/model-resolver.js +462 -0
  381. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -0
  382. package/packages/pi-coding-agent/dist/core/package-manager.d.ts +156 -0
  383. package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -0
  384. package/packages/pi-coding-agent/dist/core/package-manager.js +1442 -0
  385. package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -0
  386. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +50 -0
  387. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -0
  388. package/packages/pi-coding-agent/dist/core/prompt-templates.js +251 -0
  389. package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -0
  390. package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts +17 -0
  391. package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts.map +1 -0
  392. package/packages/pi-coding-agent/dist/core/resolve-config-value.js +59 -0
  393. package/packages/pi-coding-agent/dist/core/resolve-config-value.js.map +1 -0
  394. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +184 -0
  395. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -0
  396. package/packages/pi-coding-agent/dist/core/resource-loader.js +633 -0
  397. package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -0
  398. package/packages/pi-coding-agent/dist/core/sdk.d.ts +90 -0
  399. package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -0
  400. package/packages/pi-coding-agent/dist/core/sdk.js +242 -0
  401. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -0
  402. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +323 -0
  403. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -0
  404. package/packages/pi-coding-agent/dist/core/session-manager.js +1094 -0
  405. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -0
  406. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +232 -0
  407. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -0
  408. package/packages/pi-coding-agent/dist/core/settings-manager.js +682 -0
  409. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -0
  410. package/packages/pi-coding-agent/dist/core/skills.d.ts +58 -0
  411. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -0
  412. package/packages/pi-coding-agent/dist/core/skills.js +364 -0
  413. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -0
  414. package/packages/pi-coding-agent/dist/core/slash-commands.d.ts +15 -0
  415. package/packages/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -0
  416. package/packages/pi-coding-agent/dist/core/slash-commands.js +22 -0
  417. package/packages/pi-coding-agent/dist/core/slash-commands.js.map +1 -0
  418. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +28 -0
  419. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -0
  420. package/packages/pi-coding-agent/dist/core/system-prompt.js +159 -0
  421. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -0
  422. package/packages/pi-coding-agent/dist/core/timings.d.ts +7 -0
  423. package/packages/pi-coding-agent/dist/core/timings.d.ts.map +1 -0
  424. package/packages/pi-coding-agent/dist/core/timings.js +25 -0
  425. package/packages/pi-coding-agent/dist/core/timings.js.map +1 -0
  426. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +55 -0
  427. package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -0
  428. package/packages/pi-coding-agent/dist/core/tools/bash.js +269 -0
  429. package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -0
  430. package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts +63 -0
  431. package/packages/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -0
  432. package/packages/pi-coding-agent/dist/core/tools/edit-diff.js +243 -0
  433. package/packages/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -0
  434. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts +39 -0
  435. package/packages/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -0
  436. package/packages/pi-coding-agent/dist/core/tools/edit.js +146 -0
  437. package/packages/pi-coding-agent/dist/core/tools/edit.js.map +1 -0
  438. package/packages/pi-coding-agent/dist/core/tools/find.d.ts +39 -0
  439. package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -0
  440. package/packages/pi-coding-agent/dist/core/tools/find.js +206 -0
  441. package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -0
  442. package/packages/pi-coding-agent/dist/core/tools/grep.d.ts +45 -0
  443. package/packages/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -0
  444. package/packages/pi-coding-agent/dist/core/tools/grep.js +239 -0
  445. package/packages/pi-coding-agent/dist/core/tools/grep.js.map +1 -0
  446. package/packages/pi-coding-agent/dist/core/tools/index.d.ts +73 -0
  447. package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -0
  448. package/packages/pi-coding-agent/dist/core/tools/index.js +61 -0
  449. package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -0
  450. package/packages/pi-coding-agent/dist/core/tools/ls.d.ts +40 -0
  451. package/packages/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -0
  452. package/packages/pi-coding-agent/dist/core/tools/ls.js +118 -0
  453. package/packages/pi-coding-agent/dist/core/tools/ls.js.map +1 -0
  454. package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts +8 -0
  455. package/packages/pi-coding-agent/dist/core/tools/path-utils.d.ts.map +1 -0
  456. package/packages/pi-coding-agent/dist/core/tools/path-utils.js +81 -0
  457. package/packages/pi-coding-agent/dist/core/tools/path-utils.js.map +1 -0
  458. package/packages/pi-coding-agent/dist/core/tools/read.d.ts +39 -0
  459. package/packages/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -0
  460. package/packages/pi-coding-agent/dist/core/tools/read.js +166 -0
  461. package/packages/pi-coding-agent/dist/core/tools/read.js.map +1 -0
  462. package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts +70 -0
  463. package/packages/pi-coding-agent/dist/core/tools/truncate.d.ts.map +1 -0
  464. package/packages/pi-coding-agent/dist/core/tools/truncate.js +205 -0
  465. package/packages/pi-coding-agent/dist/core/tools/truncate.js.map +1 -0
  466. package/packages/pi-coding-agent/dist/core/tools/write.d.ts +29 -0
  467. package/packages/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -0
  468. package/packages/pi-coding-agent/dist/core/tools/write.js +78 -0
  469. package/packages/pi-coding-agent/dist/core/tools/write.js.map +1 -0
  470. package/packages/pi-coding-agent/dist/index.d.ts +27 -0
  471. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -0
  472. package/packages/pi-coding-agent/dist/index.js +42 -0
  473. package/packages/pi-coding-agent/dist/index.js.map +1 -0
  474. package/packages/pi-coding-agent/dist/main.d.ts +8 -0
  475. package/packages/pi-coding-agent/dist/main.d.ts.map +1 -0
  476. package/packages/pi-coding-agent/dist/main.js +691 -0
  477. package/packages/pi-coding-agent/dist/main.js.map +1 -0
  478. package/packages/pi-coding-agent/dist/migrations.d.ts +33 -0
  479. package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -0
  480. package/packages/pi-coding-agent/dist/migrations.js +261 -0
  481. package/packages/pi-coding-agent/dist/migrations.js.map +1 -0
  482. package/packages/pi-coding-agent/dist/modes/index.d.ts +9 -0
  483. package/packages/pi-coding-agent/dist/modes/index.d.ts.map +1 -0
  484. package/packages/pi-coding-agent/dist/modes/index.js +8 -0
  485. package/packages/pi-coding-agent/dist/modes/index.js.map +1 -0
  486. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts +34 -0
  487. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.d.ts.map +1 -0
  488. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js +329 -0
  489. package/packages/pi-coding-agent/dist/modes/interactive/components/armin.js.map +1 -0
  490. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +16 -0
  491. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  492. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +92 -0
  493. package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -0
  494. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +35 -0
  495. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  496. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +156 -0
  497. package/packages/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -0
  498. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  499. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  500. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js +48 -0
  501. package/packages/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  502. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  503. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  504. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +42 -0
  505. package/packages/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  506. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  507. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  508. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +43 -0
  509. package/packages/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  510. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +71 -0
  511. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  512. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js +470 -0
  513. package/packages/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -0
  514. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  515. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  516. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +28 -0
  517. package/packages/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  518. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  519. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  520. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js +63 -0
  521. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-editor.js.map +1 -0
  522. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts +20 -0
  523. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  524. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js +74 -0
  525. package/packages/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -0
  526. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  527. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  528. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +138 -0
  529. package/packages/pi-coding-agent/dist/modes/interactive/components/daxnuts.js.map +1 -0
  530. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts +12 -0
  531. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -0
  532. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js +133 -0
  533. package/packages/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -0
  534. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  535. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  536. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +20 -0
  537. package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  538. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts +20 -0
  539. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  540. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +106 -0
  541. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -0
  542. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts +23 -0
  543. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  544. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js +55 -0
  545. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -0
  546. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts +24 -0
  547. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  548. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js +71 -0
  549. package/packages/pi-coding-agent/dist/modes/interactive/components/extension-selector.js.map +1 -0
  550. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +26 -0
  551. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -0
  552. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +196 -0
  553. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -0
  554. package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts +32 -0
  555. package/packages/pi-coding-agent/dist/modes/interactive/components/index.d.ts.map +1 -0
  556. package/packages/pi-coding-agent/dist/modes/interactive/components/index.js +33 -0
  557. package/packages/pi-coding-agent/dist/modes/interactive/components/index.js.map +1 -0
  558. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
  559. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  560. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +61 -0
  561. package/packages/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  562. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +42 -0
  563. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  564. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +139 -0
  565. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -0
  566. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +47 -0
  567. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  568. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +259 -0
  569. package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -0
  570. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
  571. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  572. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js +92 -0
  573. package/packages/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  574. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
  575. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  576. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js +271 -0
  577. package/packages/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  578. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  579. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  580. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +155 -0
  581. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  582. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +95 -0
  583. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  584. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +825 -0
  585. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -0
  586. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +58 -0
  587. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  588. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +295 -0
  589. package/packages/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -0
  590. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  591. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  592. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js +34 -0
  593. package/packages/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  594. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  595. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  596. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +45 -0
  597. package/packages/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  598. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  599. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  600. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js +44 -0
  601. package/packages/pi-coding-agent/dist/modes/interactive/components/theme-selector.js.map +1 -0
  602. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  603. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  604. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +46 -0
  605. package/packages/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  606. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +77 -0
  607. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  608. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +773 -0
  609. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -0
  610. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts +87 -0
  611. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  612. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +1026 -0
  613. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -0
  614. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  615. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  616. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js +110 -0
  617. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  618. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts +9 -0
  619. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  620. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js +27 -0
  621. package/packages/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -0
  622. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  623. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  624. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js +33 -0
  625. package/packages/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  626. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +330 -0
  627. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  628. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +3755 -0
  629. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -0
  630. package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +86 -0
  631. package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +85 -0
  632. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +335 -0
  633. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +78 -0
  634. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  635. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +944 -0
  636. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -0
  637. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts +28 -0
  638. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -0
  639. package/packages/pi-coding-agent/dist/modes/print-mode.js +101 -0
  640. package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -0
  641. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts +17 -0
  642. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.d.ts.map +1 -0
  643. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js +49 -0
  644. package/packages/pi-coding-agent/dist/modes/rpc/jsonl.js.map +1 -0
  645. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts +217 -0
  646. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  647. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js +400 -0
  648. package/packages/pi-coding-agent/dist/modes/rpc/rpc-client.js.map +1 -0
  649. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts +20 -0
  650. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  651. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +509 -0
  652. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -0
  653. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +409 -0
  654. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  655. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js +8 -0
  656. package/packages/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -0
  657. package/packages/pi-coding-agent/dist/utils/changelog.d.ts +21 -0
  658. package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -0
  659. package/packages/pi-coding-agent/dist/utils/changelog.js +87 -0
  660. package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -0
  661. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +11 -0
  662. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -0
  663. package/packages/pi-coding-agent/dist/utils/clipboard-image.js +162 -0
  664. package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -0
  665. package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts +7 -0
  666. package/packages/pi-coding-agent/dist/utils/clipboard-native.d.ts.map +1 -0
  667. package/packages/pi-coding-agent/dist/utils/clipboard-native.js +14 -0
  668. package/packages/pi-coding-agent/dist/utils/clipboard-native.js.map +1 -0
  669. package/packages/pi-coding-agent/dist/utils/clipboard.d.ts +2 -0
  670. package/packages/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -0
  671. package/packages/pi-coding-agent/dist/utils/clipboard.js +67 -0
  672. package/packages/pi-coding-agent/dist/utils/clipboard.js.map +1 -0
  673. package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts +8 -0
  674. package/packages/pi-coding-agent/dist/utils/frontmatter.d.ts.map +1 -0
  675. package/packages/pi-coding-agent/dist/utils/frontmatter.js +26 -0
  676. package/packages/pi-coding-agent/dist/utils/frontmatter.js.map +1 -0
  677. package/packages/pi-coding-agent/dist/utils/git.d.ts +26 -0
  678. package/packages/pi-coding-agent/dist/utils/git.d.ts.map +1 -0
  679. package/packages/pi-coding-agent/dist/utils/git.js +163 -0
  680. package/packages/pi-coding-agent/dist/utils/git.js.map +1 -0
  681. package/packages/pi-coding-agent/dist/utils/image-convert.d.ts +9 -0
  682. package/packages/pi-coding-agent/dist/utils/image-convert.d.ts.map +1 -0
  683. package/packages/pi-coding-agent/dist/utils/image-convert.js +35 -0
  684. package/packages/pi-coding-agent/dist/utils/image-convert.js.map +1 -0
  685. package/packages/pi-coding-agent/dist/utils/image-resize.d.ts +36 -0
  686. package/packages/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -0
  687. package/packages/pi-coding-agent/dist/utils/image-resize.js +181 -0
  688. package/packages/pi-coding-agent/dist/utils/image-resize.js.map +1 -0
  689. package/packages/pi-coding-agent/dist/utils/mime.d.ts +2 -0
  690. package/packages/pi-coding-agent/dist/utils/mime.d.ts.map +1 -0
  691. package/packages/pi-coding-agent/dist/utils/mime.js +26 -0
  692. package/packages/pi-coding-agent/dist/utils/mime.js.map +1 -0
  693. package/packages/pi-coding-agent/dist/utils/photon.d.ts +21 -0
  694. package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -0
  695. package/packages/pi-coding-agent/dist/utils/photon.js +121 -0
  696. package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -0
  697. package/packages/pi-coding-agent/dist/utils/shell.d.ts +26 -0
  698. package/packages/pi-coding-agent/dist/utils/shell.d.ts.map +1 -0
  699. package/packages/pi-coding-agent/dist/utils/shell.js +186 -0
  700. package/packages/pi-coding-agent/dist/utils/shell.js.map +1 -0
  701. package/packages/pi-coding-agent/dist/utils/sleep.d.ts +5 -0
  702. package/packages/pi-coding-agent/dist/utils/sleep.d.ts.map +1 -0
  703. package/packages/pi-coding-agent/dist/utils/sleep.js +17 -0
  704. package/packages/pi-coding-agent/dist/utils/sleep.js.map +1 -0
  705. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +3 -0
  706. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -0
  707. package/packages/pi-coding-agent/dist/utils/tools-manager.js +251 -0
  708. package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -0
  709. package/packages/pi-coding-agent/package.json +55 -0
  710. package/packages/pi-coding-agent/src/cli/args.ts +316 -0
  711. package/packages/pi-coding-agent/src/cli/config-selector.ts +52 -0
  712. package/packages/pi-coding-agent/src/cli/file-processor.ts +96 -0
  713. package/packages/pi-coding-agent/src/cli/list-models.ts +104 -0
  714. package/packages/pi-coding-agent/src/cli/session-picker.ts +51 -0
  715. package/packages/pi-coding-agent/src/cli.ts +18 -0
  716. package/packages/pi-coding-agent/src/config.ts +241 -0
  717. package/packages/pi-coding-agent/src/core/agent-session.ts +3050 -0
  718. package/packages/pi-coding-agent/src/core/auth-storage.ts +489 -0
  719. package/packages/pi-coding-agent/src/core/bash-executor.ts +278 -0
  720. package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +352 -0
  721. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +813 -0
  722. package/packages/pi-coding-agent/src/core/compaction/index.ts +7 -0
  723. package/packages/pi-coding-agent/src/core/compaction/utils.ts +170 -0
  724. package/packages/pi-coding-agent/src/core/defaults.ts +3 -0
  725. package/packages/pi-coding-agent/src/core/diagnostics.ts +15 -0
  726. package/packages/pi-coding-agent/src/core/event-bus.ts +33 -0
  727. package/packages/pi-coding-agent/src/core/exec.ts +104 -0
  728. package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
  729. package/packages/pi-coding-agent/src/core/export-html/index.ts +306 -0
  730. package/packages/pi-coding-agent/src/core/export-html/template.css +971 -0
  731. package/packages/pi-coding-agent/src/core/export-html/template.html +54 -0
  732. package/packages/pi-coding-agent/src/core/export-html/template.js +1583 -0
  733. package/packages/pi-coding-agent/src/core/export-html/tool-renderer.ts +114 -0
  734. package/packages/pi-coding-agent/src/core/export-html/vendor/.gitkeep +0 -0
  735. package/packages/pi-coding-agent/src/core/extensions/index.ts +171 -0
  736. package/packages/pi-coding-agent/src/core/extensions/loader.ts +545 -0
  737. package/packages/pi-coding-agent/src/core/extensions/runner.ts +884 -0
  738. package/packages/pi-coding-agent/src/core/extensions/types.ts +1411 -0
  739. package/packages/pi-coding-agent/src/core/extensions/wrapper.ts +118 -0
  740. package/packages/pi-coding-agent/src/core/footer-data-provider.ts +144 -0
  741. package/packages/pi-coding-agent/src/core/index.ts +61 -0
  742. package/packages/pi-coding-agent/src/core/keybindings.ts +211 -0
  743. package/packages/pi-coding-agent/src/core/messages.ts +195 -0
  744. package/packages/pi-coding-agent/src/core/model-registry.ts +694 -0
  745. package/packages/pi-coding-agent/src/core/model-resolver.ts +594 -0
  746. package/packages/pi-coding-agent/src/core/package-manager.ts +1794 -0
  747. package/packages/pi-coding-agent/src/core/prompt-templates.ts +299 -0
  748. package/packages/pi-coding-agent/src/core/resolve-config-value.ts +64 -0
  749. package/packages/pi-coding-agent/src/core/resource-loader.ts +868 -0
  750. package/packages/pi-coding-agent/src/core/sdk.ts +373 -0
  751. package/packages/pi-coding-agent/src/core/session-manager.ts +1410 -0
  752. package/packages/pi-coding-agent/src/core/settings-manager.ts +942 -0
  753. package/packages/pi-coding-agent/src/core/skills.ts +459 -0
  754. package/packages/pi-coding-agent/src/core/slash-commands.ts +38 -0
  755. package/packages/pi-coding-agent/src/core/system-prompt.ts +218 -0
  756. package/packages/pi-coding-agent/src/core/timings.ts +25 -0
  757. package/packages/pi-coding-agent/src/core/tools/bash.ts +347 -0
  758. package/packages/pi-coding-agent/src/core/tools/edit-diff.ts +308 -0
  759. package/packages/pi-coding-agent/src/core/tools/edit.ts +227 -0
  760. package/packages/pi-coding-agent/src/core/tools/find.ts +273 -0
  761. package/packages/pi-coding-agent/src/core/tools/grep.ts +346 -0
  762. package/packages/pi-coding-agent/src/core/tools/index.ts +139 -0
  763. package/packages/pi-coding-agent/src/core/tools/ls.ts +170 -0
  764. package/packages/pi-coding-agent/src/core/tools/path-utils.ts +94 -0
  765. package/packages/pi-coding-agent/src/core/tools/read.ts +222 -0
  766. package/packages/pi-coding-agent/src/core/tools/truncate.ts +265 -0
  767. package/packages/pi-coding-agent/src/core/tools/write.ts +118 -0
  768. package/packages/pi-coding-agent/src/index.ts +333 -0
  769. package/packages/pi-coding-agent/src/main.ts +821 -0
  770. package/packages/pi-coding-agent/src/migrations.ts +295 -0
  771. package/packages/pi-coding-agent/src/modes/index.ts +9 -0
  772. package/packages/pi-coding-agent/src/modes/interactive/components/armin.ts +382 -0
  773. package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +115 -0
  774. package/packages/pi-coding-agent/src/modes/interactive/components/bash-execution.ts +210 -0
  775. package/packages/pi-coding-agent/src/modes/interactive/components/bordered-loader.ts +66 -0
  776. package/packages/pi-coding-agent/src/modes/interactive/components/branch-summary-message.ts +58 -0
  777. package/packages/pi-coding-agent/src/modes/interactive/components/compaction-summary-message.ts +59 -0
  778. package/packages/pi-coding-agent/src/modes/interactive/components/config-selector.ts +592 -0
  779. package/packages/pi-coding-agent/src/modes/interactive/components/countdown-timer.ts +38 -0
  780. package/packages/pi-coding-agent/src/modes/interactive/components/custom-editor.ts +80 -0
  781. package/packages/pi-coding-agent/src/modes/interactive/components/custom-message.ts +99 -0
  782. package/packages/pi-coding-agent/src/modes/interactive/components/daxnuts.ts +164 -0
  783. package/packages/pi-coding-agent/src/modes/interactive/components/diff.ts +147 -0
  784. package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +25 -0
  785. package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +147 -0
  786. package/packages/pi-coding-agent/src/modes/interactive/components/extension-input.ts +85 -0
  787. package/packages/pi-coding-agent/src/modes/interactive/components/extension-selector.ts +107 -0
  788. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +216 -0
  789. package/packages/pi-coding-agent/src/modes/interactive/components/index.ts +32 -0
  790. package/packages/pi-coding-agent/src/modes/interactive/components/keybinding-hints.ts +66 -0
  791. package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +174 -0
  792. package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +329 -0
  793. package/packages/pi-coding-agent/src/modes/interactive/components/oauth-selector.ts +121 -0
  794. package/packages/pi-coding-agent/src/modes/interactive/components/scoped-models-selector.ts +346 -0
  795. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
  796. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +1019 -0
  797. package/packages/pi-coding-agent/src/modes/interactive/components/settings-selector.ts +421 -0
  798. package/packages/pi-coding-agent/src/modes/interactive/components/show-images-selector.ts +45 -0
  799. package/packages/pi-coding-agent/src/modes/interactive/components/skill-invocation-message.ts +55 -0
  800. package/packages/pi-coding-agent/src/modes/interactive/components/theme-selector.ts +62 -0
  801. package/packages/pi-coding-agent/src/modes/interactive/components/thinking-selector.ts +64 -0
  802. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +916 -0
  803. package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +1184 -0
  804. package/packages/pi-coding-agent/src/modes/interactive/components/user-message-selector.ts +143 -0
  805. package/packages/pi-coding-agent/src/modes/interactive/components/user-message.ts +32 -0
  806. package/packages/pi-coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
  807. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +4464 -0
  808. package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +86 -0
  809. package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +85 -0
  810. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +335 -0
  811. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +1105 -0
  812. package/packages/pi-coding-agent/src/modes/print-mode.ts +124 -0
  813. package/packages/pi-coding-agent/src/modes/rpc/jsonl.ts +58 -0
  814. package/packages/pi-coding-agent/src/modes/rpc/rpc-client.ts +505 -0
  815. package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +638 -0
  816. package/packages/pi-coding-agent/src/modes/rpc/rpc-types.ts +263 -0
  817. package/packages/pi-coding-agent/src/utils/changelog.ts +99 -0
  818. package/packages/pi-coding-agent/src/utils/clipboard-image.ts +207 -0
  819. package/packages/pi-coding-agent/src/utils/clipboard-native.ts +21 -0
  820. package/packages/pi-coding-agent/src/utils/clipboard.ts +62 -0
  821. package/packages/pi-coding-agent/src/utils/frontmatter.ts +39 -0
  822. package/packages/pi-coding-agent/src/utils/git.ts +192 -0
  823. package/packages/pi-coding-agent/src/utils/image-convert.ts +38 -0
  824. package/packages/pi-coding-agent/src/utils/image-resize.ts +231 -0
  825. package/packages/pi-coding-agent/src/utils/mime.ts +30 -0
  826. package/packages/pi-coding-agent/src/utils/photon.ts +139 -0
  827. package/packages/pi-coding-agent/src/utils/shell.ts +202 -0
  828. package/packages/pi-coding-agent/src/utils/sleep.ts +18 -0
  829. package/packages/pi-coding-agent/src/utils/tools-manager.ts +286 -0
  830. package/packages/pi-coding-agent/tsconfig.json +27 -0
  831. package/packages/pi-tui/dist/autocomplete.d.ts +50 -0
  832. package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -0
  833. package/packages/pi-tui/dist/autocomplete.js +593 -0
  834. package/packages/pi-tui/dist/autocomplete.js.map +1 -0
  835. package/packages/pi-tui/dist/components/box.d.ts +22 -0
  836. package/packages/pi-tui/dist/components/box.d.ts.map +1 -0
  837. package/packages/pi-tui/dist/components/box.js +99 -0
  838. package/packages/pi-tui/dist/components/box.js.map +1 -0
  839. package/packages/pi-tui/dist/components/cancellable-loader.d.ts +22 -0
  840. package/packages/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -0
  841. package/packages/pi-tui/dist/components/cancellable-loader.js +36 -0
  842. package/packages/pi-tui/dist/components/cancellable-loader.js.map +1 -0
  843. package/packages/pi-tui/dist/components/editor.d.ts +219 -0
  844. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -0
  845. package/packages/pi-tui/dist/components/editor.js +1693 -0
  846. package/packages/pi-tui/dist/components/editor.js.map +1 -0
  847. package/packages/pi-tui/dist/components/image.d.ts +28 -0
  848. package/packages/pi-tui/dist/components/image.d.ts.map +1 -0
  849. package/packages/pi-tui/dist/components/image.js +61 -0
  850. package/packages/pi-tui/dist/components/image.js.map +1 -0
  851. package/packages/pi-tui/dist/components/input.d.ts +37 -0
  852. package/packages/pi-tui/dist/components/input.d.ts.map +1 -0
  853. package/packages/pi-tui/dist/components/input.js +443 -0
  854. package/packages/pi-tui/dist/components/input.js.map +1 -0
  855. package/packages/pi-tui/dist/components/loader.d.ts +21 -0
  856. package/packages/pi-tui/dist/components/loader.d.ts.map +1 -0
  857. package/packages/pi-tui/dist/components/loader.js +46 -0
  858. package/packages/pi-tui/dist/components/loader.js.map +1 -0
  859. package/packages/pi-tui/dist/components/markdown.d.ts +95 -0
  860. package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -0
  861. package/packages/pi-tui/dist/components/markdown.js +641 -0
  862. package/packages/pi-tui/dist/components/markdown.js.map +1 -0
  863. package/packages/pi-tui/dist/components/select-list.d.ts +32 -0
  864. package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -0
  865. package/packages/pi-tui/dist/components/select-list.js +148 -0
  866. package/packages/pi-tui/dist/components/select-list.js.map +1 -0
  867. package/packages/pi-tui/dist/components/settings-list.d.ts +50 -0
  868. package/packages/pi-tui/dist/components/settings-list.d.ts.map +1 -0
  869. package/packages/pi-tui/dist/components/settings-list.js +177 -0
  870. package/packages/pi-tui/dist/components/settings-list.js.map +1 -0
  871. package/packages/pi-tui/dist/components/spacer.d.ts +12 -0
  872. package/packages/pi-tui/dist/components/spacer.d.ts.map +1 -0
  873. package/packages/pi-tui/dist/components/spacer.js +22 -0
  874. package/packages/pi-tui/dist/components/spacer.js.map +1 -0
  875. package/packages/pi-tui/dist/components/text.d.ts +19 -0
  876. package/packages/pi-tui/dist/components/text.d.ts.map +1 -0
  877. package/packages/pi-tui/dist/components/text.js +81 -0
  878. package/packages/pi-tui/dist/components/text.js.map +1 -0
  879. package/packages/pi-tui/dist/components/truncated-text.d.ts +13 -0
  880. package/packages/pi-tui/dist/components/truncated-text.d.ts.map +1 -0
  881. package/packages/pi-tui/dist/components/truncated-text.js +48 -0
  882. package/packages/pi-tui/dist/components/truncated-text.js.map +1 -0
  883. package/packages/pi-tui/dist/editor-component.d.ts +39 -0
  884. package/packages/pi-tui/dist/editor-component.d.ts.map +1 -0
  885. package/packages/pi-tui/dist/editor-component.js +2 -0
  886. package/packages/pi-tui/dist/editor-component.js.map +1 -0
  887. package/packages/pi-tui/dist/fuzzy.d.ts +16 -0
  888. package/packages/pi-tui/dist/fuzzy.d.ts.map +1 -0
  889. package/packages/pi-tui/dist/fuzzy.js +107 -0
  890. package/packages/pi-tui/dist/fuzzy.js.map +1 -0
  891. package/packages/pi-tui/dist/index.d.ts +23 -0
  892. package/packages/pi-tui/dist/index.d.ts.map +1 -0
  893. package/packages/pi-tui/dist/index.js +32 -0
  894. package/packages/pi-tui/dist/index.js.map +1 -0
  895. package/packages/pi-tui/dist/keybindings.d.ts +39 -0
  896. package/packages/pi-tui/dist/keybindings.d.ts.map +1 -0
  897. package/packages/pi-tui/dist/keybindings.js +116 -0
  898. package/packages/pi-tui/dist/keybindings.js.map +1 -0
  899. package/packages/pi-tui/dist/keys.d.ts +170 -0
  900. package/packages/pi-tui/dist/keys.d.ts.map +1 -0
  901. package/packages/pi-tui/dist/keys.js +1046 -0
  902. package/packages/pi-tui/dist/keys.js.map +1 -0
  903. package/packages/pi-tui/dist/kill-ring.d.ts +28 -0
  904. package/packages/pi-tui/dist/kill-ring.d.ts.map +1 -0
  905. package/packages/pi-tui/dist/kill-ring.js +46 -0
  906. package/packages/pi-tui/dist/kill-ring.js.map +1 -0
  907. package/packages/pi-tui/dist/stdin-buffer.d.ts +48 -0
  908. package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -0
  909. package/packages/pi-tui/dist/stdin-buffer.js +316 -0
  910. package/packages/pi-tui/dist/stdin-buffer.js.map +1 -0
  911. package/packages/pi-tui/dist/terminal-image.d.ts +68 -0
  912. package/packages/pi-tui/dist/terminal-image.d.ts.map +1 -0
  913. package/packages/pi-tui/dist/terminal-image.js +288 -0
  914. package/packages/pi-tui/dist/terminal-image.js.map +1 -0
  915. package/packages/pi-tui/dist/terminal.d.ts +85 -0
  916. package/packages/pi-tui/dist/terminal.d.ts.map +1 -0
  917. package/packages/pi-tui/dist/terminal.js +271 -0
  918. package/packages/pi-tui/dist/terminal.js.map +1 -0
  919. package/packages/pi-tui/dist/tui.d.ts +220 -0
  920. package/packages/pi-tui/dist/tui.d.ts.map +1 -0
  921. package/packages/pi-tui/dist/tui.js +976 -0
  922. package/packages/pi-tui/dist/tui.js.map +1 -0
  923. package/packages/pi-tui/dist/undo-stack.d.ts +17 -0
  924. package/packages/pi-tui/dist/undo-stack.d.ts.map +1 -0
  925. package/packages/pi-tui/dist/undo-stack.js +27 -0
  926. package/packages/pi-tui/dist/undo-stack.js.map +1 -0
  927. package/packages/pi-tui/dist/utils.d.ts +78 -0
  928. package/packages/pi-tui/dist/utils.d.ts.map +1 -0
  929. package/packages/pi-tui/dist/utils.js +817 -0
  930. package/packages/pi-tui/dist/utils.js.map +1 -0
  931. package/packages/pi-tui/package.json +21 -0
  932. package/packages/pi-tui/src/autocomplete.ts +736 -0
  933. package/packages/pi-tui/src/components/box.ts +137 -0
  934. package/packages/pi-tui/src/components/cancellable-loader.ts +40 -0
  935. package/packages/pi-tui/src/components/editor.ts +2035 -0
  936. package/packages/pi-tui/src/components/image.ts +104 -0
  937. package/packages/pi-tui/src/components/input.ts +521 -0
  938. package/packages/pi-tui/src/components/loader.ts +55 -0
  939. package/packages/pi-tui/src/components/markdown.ts +806 -0
  940. package/packages/pi-tui/src/components/select-list.ts +188 -0
  941. package/packages/pi-tui/src/components/settings-list.ts +250 -0
  942. package/packages/pi-tui/src/components/spacer.ts +28 -0
  943. package/packages/pi-tui/src/components/text.ts +106 -0
  944. package/packages/pi-tui/src/components/truncated-text.ts +65 -0
  945. package/packages/pi-tui/src/editor-component.ts +74 -0
  946. package/packages/pi-tui/src/fuzzy.ts +133 -0
  947. package/packages/pi-tui/src/index.ts +93 -0
  948. package/packages/pi-tui/src/keybindings.ts +189 -0
  949. package/packages/pi-tui/src/keys.ts +1255 -0
  950. package/packages/pi-tui/src/kill-ring.ts +46 -0
  951. package/packages/pi-tui/src/stdin-buffer.ts +386 -0
  952. package/packages/pi-tui/src/terminal-image.ts +381 -0
  953. package/packages/pi-tui/src/terminal.ts +349 -0
  954. package/packages/pi-tui/src/tui.ts +1212 -0
  955. package/packages/pi-tui/src/undo-stack.ts +28 -0
  956. package/packages/pi-tui/src/utils.ts +905 -0
  957. package/packages/pi-tui/tsconfig.json +27 -0
  958. package/pkg/dist/modes/interactive/theme/dark.json +6 -6
  959. package/pkg/dist/modes/interactive/theme/light.json +6 -5
  960. package/pkg/dist/modes/interactive/theme/theme.d.ts +2 -2
  961. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  962. package/pkg/dist/modes/interactive/theme/theme.js +1 -6
  963. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  964. package/scripts/postinstall.js +2 -17
  965. package/src/resources/extensions/ask-user-questions.ts +2 -2
  966. package/src/resources/extensions/bg-shell/index.ts +4 -4
  967. package/src/resources/extensions/browser-tools/index.ts +3 -3
  968. package/src/resources/extensions/context7/index.ts +3 -3
  969. package/src/resources/extensions/get-secrets-from-user.ts +331 -59
  970. package/src/resources/extensions/google-search/index.ts +20 -7
  971. package/src/resources/extensions/gsd/activity-log.ts +1 -1
  972. package/src/resources/extensions/gsd/auto.ts +106 -21
  973. package/src/resources/extensions/gsd/commands.ts +2 -2
  974. package/src/resources/extensions/gsd/dashboard-overlay.ts +2 -2
  975. package/src/resources/extensions/gsd/docs/preferences-reference.md +45 -1
  976. package/src/resources/extensions/gsd/doctor.ts +23 -4
  977. package/src/resources/extensions/gsd/files.ts +115 -1
  978. package/src/resources/extensions/gsd/git-service.ts +64 -111
  979. package/src/resources/extensions/gsd/guided-flow.ts +3 -2
  980. package/src/resources/extensions/gsd/index.ts +18 -7
  981. package/src/resources/extensions/gsd/metrics.ts +1 -1
  982. package/src/resources/extensions/gsd/migrate/command.ts +1 -1
  983. package/src/resources/extensions/gsd/preferences.ts +72 -10
  984. package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -0
  985. package/src/resources/extensions/gsd/prompts/plan-milestone.md +17 -0
  986. package/src/resources/extensions/gsd/session-forensics.ts +19 -6
  987. package/src/resources/extensions/gsd/skill-discovery.ts +1 -1
  988. package/src/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
  989. package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
  990. package/src/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
  991. package/src/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
  992. package/src/resources/extensions/gsd/tests/git-service.test.ts +43 -0
  993. package/src/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
  994. package/src/resources/extensions/gsd/tests/parsers.test.ts +401 -65
  995. package/src/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +2 -1
  996. package/src/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
  997. package/src/resources/extensions/gsd/types.ts +27 -0
  998. package/src/resources/extensions/gsd/worktree-command.ts +2 -2
  999. package/src/resources/extensions/mac-tools/index.ts +2 -2
  1000. package/src/resources/extensions/mcporter/index.ts +3 -3
  1001. package/src/resources/extensions/remote-questions/remote-command.ts +3 -3
  1002. package/src/resources/extensions/search-the-web/command-search-provider.ts +2 -2
  1003. package/src/resources/extensions/search-the-web/index.ts +1 -1
  1004. package/src/resources/extensions/search-the-web/provider.ts +1 -1
  1005. package/src/resources/extensions/search-the-web/tool-fetch-page.ts +3 -3
  1006. package/src/resources/extensions/search-the-web/tool-llm-context.ts +4 -4
  1007. package/src/resources/extensions/search-the-web/tool-search.ts +4 -4
  1008. package/src/resources/extensions/shared/confirm-ui.ts +3 -3
  1009. package/src/resources/extensions/shared/interview-ui.ts +3 -3
  1010. package/src/resources/extensions/shared/next-action-ui.ts +3 -3
  1011. package/src/resources/extensions/shared/progress-widget.ts +2 -2
  1012. package/src/resources/extensions/shared/thinking-widget.ts +3 -3
  1013. package/src/resources/extensions/shared/ui.ts +4 -4
  1014. package/src/resources/extensions/shared/wizard-ui.ts +4 -4
  1015. package/src/resources/extensions/slash-commands/audit.ts +1 -1
  1016. package/src/resources/extensions/slash-commands/clear.ts +1 -1
  1017. package/src/resources/extensions/slash-commands/create-extension.ts +2 -2
  1018. package/src/resources/extensions/slash-commands/create-slash-command.ts +2 -2
  1019. package/src/resources/extensions/slash-commands/index.ts +1 -1
  1020. package/src/resources/extensions/subagent/agents.ts +1 -1
  1021. package/src/resources/extensions/subagent/index.ts +5 -5
  1022. package/src/resources/extensions/voice/index.ts +3 -3
  1023. package/patches/@mariozechner+pi-coding-agent+0.57.1.patch +0 -78
  1024. package/patches/@mariozechner+pi-tui+0.57.1.patch +0 -47
@@ -0,0 +1,1693 @@
1
+ import { getEditorKeybindings } from "../keybindings.js";
2
+ import { decodeKittyPrintable, matchesKey } from "../keys.js";
3
+ import { KillRing } from "../kill-ring.js";
4
+ import { CURSOR_MARKER } from "../tui.js";
5
+ import { UndoStack } from "../undo-stack.js";
6
+ import { getSegmenter, isPunctuationChar, isWhitespaceChar, visibleWidth } from "../utils.js";
7
+ import { SelectList } from "./select-list.js";
8
+ const segmenter = getSegmenter();
9
+ /**
10
+ * Split a line into word-wrapped chunks.
11
+ * Wraps at word boundaries when possible, falling back to character-level
12
+ * wrapping for words longer than the available width.
13
+ *
14
+ * @param line - The text line to wrap
15
+ * @param maxWidth - Maximum visible width per chunk
16
+ * @returns Array of chunks with text and position information
17
+ */
18
+ export function wordWrapLine(line, maxWidth) {
19
+ if (!line || maxWidth <= 0) {
20
+ return [{ text: "", startIndex: 0, endIndex: 0 }];
21
+ }
22
+ const lineWidth = visibleWidth(line);
23
+ if (lineWidth <= maxWidth) {
24
+ return [{ text: line, startIndex: 0, endIndex: line.length }];
25
+ }
26
+ const chunks = [];
27
+ const segments = [...segmenter.segment(line)];
28
+ let currentWidth = 0;
29
+ let chunkStart = 0;
30
+ // Wrap opportunity: the position after the last whitespace before a non-whitespace
31
+ // grapheme, i.e. where a line break is allowed.
32
+ let wrapOppIndex = -1;
33
+ let wrapOppWidth = 0;
34
+ for (let i = 0; i < segments.length; i++) {
35
+ const seg = segments[i];
36
+ const grapheme = seg.segment;
37
+ const gWidth = visibleWidth(grapheme);
38
+ const charIndex = seg.index;
39
+ const isWs = isWhitespaceChar(grapheme);
40
+ // Overflow check before advancing.
41
+ if (currentWidth + gWidth > maxWidth) {
42
+ if (wrapOppIndex >= 0) {
43
+ // Backtrack to last wrap opportunity.
44
+ chunks.push({ text: line.slice(chunkStart, wrapOppIndex), startIndex: chunkStart, endIndex: wrapOppIndex });
45
+ chunkStart = wrapOppIndex;
46
+ currentWidth -= wrapOppWidth;
47
+ }
48
+ else if (chunkStart < charIndex) {
49
+ // No wrap opportunity: force-break at current position.
50
+ chunks.push({ text: line.slice(chunkStart, charIndex), startIndex: chunkStart, endIndex: charIndex });
51
+ chunkStart = charIndex;
52
+ currentWidth = 0;
53
+ }
54
+ wrapOppIndex = -1;
55
+ }
56
+ // Advance.
57
+ currentWidth += gWidth;
58
+ // Record wrap opportunity: whitespace followed by non-whitespace.
59
+ // Multiple spaces join (no break between them); the break point is
60
+ // after the last space before the next word.
61
+ const next = segments[i + 1];
62
+ if (isWs && next && !isWhitespaceChar(next.segment)) {
63
+ wrapOppIndex = next.index;
64
+ wrapOppWidth = currentWidth;
65
+ }
66
+ }
67
+ // Push final chunk.
68
+ chunks.push({ text: line.slice(chunkStart), startIndex: chunkStart, endIndex: line.length });
69
+ return chunks;
70
+ }
71
+ export class Editor {
72
+ constructor(tui, theme, options = {}) {
73
+ this.state = {
74
+ lines: [""],
75
+ cursorLine: 0,
76
+ cursorCol: 0,
77
+ };
78
+ /** Focusable interface - set by TUI when focus changes */
79
+ this.focused = false;
80
+ this.paddingX = 0;
81
+ // Store last render width for cursor navigation
82
+ this.lastWidth = 80;
83
+ // Vertical scrolling support
84
+ this.scrollOffset = 0;
85
+ this.autocompleteState = null;
86
+ this.autocompletePrefix = "";
87
+ this.autocompleteMaxVisible = 5;
88
+ // Paste tracking for large pastes
89
+ this.pastes = new Map();
90
+ this.pasteCounter = 0;
91
+ // Bracketed paste mode buffering
92
+ this.pasteBuffer = "";
93
+ this.isInPaste = false;
94
+ // Prompt history for up/down navigation
95
+ this.history = [];
96
+ this.historyIndex = -1; // -1 = not browsing, 0 = most recent, 1 = older, etc.
97
+ // Kill ring for Emacs-style kill/yank operations
98
+ this.killRing = new KillRing();
99
+ this.lastAction = null;
100
+ // Character jump mode
101
+ this.jumpMode = null;
102
+ // Preferred visual column for vertical cursor movement (sticky column)
103
+ this.preferredVisualCol = null;
104
+ // Undo support
105
+ this.undoStack = new UndoStack();
106
+ this.disableSubmit = false;
107
+ this.tui = tui;
108
+ this.theme = theme;
109
+ this.borderColor = theme.borderColor;
110
+ const paddingX = options.paddingX ?? 0;
111
+ this.paddingX = Number.isFinite(paddingX) ? Math.max(0, Math.floor(paddingX)) : 0;
112
+ const maxVisible = options.autocompleteMaxVisible ?? 5;
113
+ this.autocompleteMaxVisible = Number.isFinite(maxVisible) ? Math.max(3, Math.min(20, Math.floor(maxVisible))) : 5;
114
+ }
115
+ getPaddingX() {
116
+ return this.paddingX;
117
+ }
118
+ setPaddingX(padding) {
119
+ const newPadding = Number.isFinite(padding) ? Math.max(0, Math.floor(padding)) : 0;
120
+ if (this.paddingX !== newPadding) {
121
+ this.paddingX = newPadding;
122
+ this.tui.requestRender();
123
+ }
124
+ }
125
+ getAutocompleteMaxVisible() {
126
+ return this.autocompleteMaxVisible;
127
+ }
128
+ setAutocompleteMaxVisible(maxVisible) {
129
+ const newMaxVisible = Number.isFinite(maxVisible) ? Math.max(3, Math.min(20, Math.floor(maxVisible))) : 5;
130
+ if (this.autocompleteMaxVisible !== newMaxVisible) {
131
+ this.autocompleteMaxVisible = newMaxVisible;
132
+ this.tui.requestRender();
133
+ }
134
+ }
135
+ setAutocompleteProvider(provider) {
136
+ this.autocompleteProvider = provider;
137
+ }
138
+ /**
139
+ * Add a prompt to history for up/down arrow navigation.
140
+ * Called after successful submission.
141
+ */
142
+ addToHistory(text) {
143
+ const trimmed = text.trim();
144
+ if (!trimmed)
145
+ return;
146
+ // Don't add consecutive duplicates
147
+ if (this.history.length > 0 && this.history[0] === trimmed)
148
+ return;
149
+ this.history.unshift(trimmed);
150
+ // Limit history size
151
+ if (this.history.length > 100) {
152
+ this.history.pop();
153
+ }
154
+ }
155
+ isEditorEmpty() {
156
+ return this.state.lines.length === 1 && this.state.lines[0] === "";
157
+ }
158
+ isOnFirstVisualLine() {
159
+ const visualLines = this.buildVisualLineMap(this.lastWidth);
160
+ const currentVisualLine = this.findCurrentVisualLine(visualLines);
161
+ return currentVisualLine === 0;
162
+ }
163
+ isOnLastVisualLine() {
164
+ const visualLines = this.buildVisualLineMap(this.lastWidth);
165
+ const currentVisualLine = this.findCurrentVisualLine(visualLines);
166
+ return currentVisualLine === visualLines.length - 1;
167
+ }
168
+ navigateHistory(direction) {
169
+ this.lastAction = null;
170
+ if (this.history.length === 0)
171
+ return;
172
+ const newIndex = this.historyIndex - direction; // Up(-1) increases index, Down(1) decreases
173
+ if (newIndex < -1 || newIndex >= this.history.length)
174
+ return;
175
+ // Capture state when first entering history browsing mode
176
+ if (this.historyIndex === -1 && newIndex >= 0) {
177
+ this.pushUndoSnapshot();
178
+ }
179
+ this.historyIndex = newIndex;
180
+ if (this.historyIndex === -1) {
181
+ // Returned to "current" state - clear editor
182
+ this.setTextInternal("");
183
+ }
184
+ else {
185
+ this.setTextInternal(this.history[this.historyIndex] || "");
186
+ }
187
+ }
188
+ /** Internal setText that doesn't reset history state - used by navigateHistory */
189
+ setTextInternal(text) {
190
+ const lines = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
191
+ this.state.lines = lines.length === 0 ? [""] : lines;
192
+ this.state.cursorLine = this.state.lines.length - 1;
193
+ this.setCursorCol(this.state.lines[this.state.cursorLine]?.length || 0);
194
+ // Reset scroll - render() will adjust to show cursor
195
+ this.scrollOffset = 0;
196
+ if (this.onChange) {
197
+ this.onChange(this.getText());
198
+ }
199
+ }
200
+ invalidate() {
201
+ // No cached state to invalidate currently
202
+ }
203
+ render(width) {
204
+ const maxPadding = Math.max(0, Math.floor((width - 1) / 2));
205
+ const paddingX = Math.min(this.paddingX, maxPadding);
206
+ const contentWidth = Math.max(1, width - paddingX * 2);
207
+ // Layout width: with padding the cursor can overflow into it,
208
+ // without padding we reserve 1 column for the cursor.
209
+ const layoutWidth = Math.max(1, contentWidth - (paddingX ? 0 : 1));
210
+ // Store for cursor navigation (must match wrapping width)
211
+ this.lastWidth = layoutWidth;
212
+ const horizontal = this.borderColor("─");
213
+ // Layout the text
214
+ const layoutLines = this.layoutText(layoutWidth);
215
+ // Calculate max visible lines: 30% of terminal height, minimum 5 lines
216
+ const terminalRows = this.tui.terminal.rows;
217
+ const maxVisibleLines = Math.max(5, Math.floor(terminalRows * 0.3));
218
+ // Find the cursor line index in layoutLines
219
+ let cursorLineIndex = layoutLines.findIndex((line) => line.hasCursor);
220
+ if (cursorLineIndex === -1)
221
+ cursorLineIndex = 0;
222
+ // Adjust scroll offset to keep cursor visible
223
+ if (cursorLineIndex < this.scrollOffset) {
224
+ this.scrollOffset = cursorLineIndex;
225
+ }
226
+ else if (cursorLineIndex >= this.scrollOffset + maxVisibleLines) {
227
+ this.scrollOffset = cursorLineIndex - maxVisibleLines + 1;
228
+ }
229
+ // Clamp scroll offset to valid range
230
+ const maxScrollOffset = Math.max(0, layoutLines.length - maxVisibleLines);
231
+ this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, maxScrollOffset));
232
+ // Get visible lines slice
233
+ const visibleLines = layoutLines.slice(this.scrollOffset, this.scrollOffset + maxVisibleLines);
234
+ const result = [];
235
+ const leftPadding = " ".repeat(paddingX);
236
+ const rightPadding = leftPadding;
237
+ // Render top border (with scroll indicator if scrolled down)
238
+ if (this.scrollOffset > 0) {
239
+ const indicator = `─── ↑ ${this.scrollOffset} more `;
240
+ const remaining = width - visibleWidth(indicator);
241
+ result.push(this.borderColor(indicator + "─".repeat(Math.max(0, remaining))));
242
+ }
243
+ else {
244
+ result.push(horizontal.repeat(width));
245
+ }
246
+ // Render each visible layout line
247
+ // Emit hardware cursor marker only when focused and not showing autocomplete
248
+ const emitCursorMarker = this.focused && !this.autocompleteState;
249
+ for (const layoutLine of visibleLines) {
250
+ let displayText = layoutLine.text;
251
+ let lineVisibleWidth = visibleWidth(layoutLine.text);
252
+ let cursorInPadding = false;
253
+ // Add cursor if this line has it
254
+ if (layoutLine.hasCursor && layoutLine.cursorPos !== undefined) {
255
+ const before = displayText.slice(0, layoutLine.cursorPos);
256
+ const after = displayText.slice(layoutLine.cursorPos);
257
+ // Hardware cursor marker (zero-width, emitted before fake cursor for IME positioning)
258
+ const marker = emitCursorMarker ? CURSOR_MARKER : "";
259
+ if (after.length > 0) {
260
+ // Cursor is on a character (grapheme) - replace it with highlighted version
261
+ // Get the first grapheme from 'after'
262
+ const afterGraphemes = [...segmenter.segment(after)];
263
+ const firstGrapheme = afterGraphemes[0]?.segment || "";
264
+ const restAfter = after.slice(firstGrapheme.length);
265
+ const cursor = `\x1b[7m${firstGrapheme}\x1b[0m`;
266
+ displayText = before + marker + cursor + restAfter;
267
+ // lineVisibleWidth stays the same - we're replacing, not adding
268
+ }
269
+ else {
270
+ // Cursor is at the end - add highlighted space
271
+ const cursor = "\x1b[7m \x1b[0m";
272
+ displayText = before + marker + cursor;
273
+ lineVisibleWidth = lineVisibleWidth + 1;
274
+ // If cursor overflows content width into the padding, flag it
275
+ if (lineVisibleWidth > contentWidth && paddingX > 0) {
276
+ cursorInPadding = true;
277
+ }
278
+ }
279
+ }
280
+ // Calculate padding based on actual visible width
281
+ const padding = " ".repeat(Math.max(0, contentWidth - lineVisibleWidth));
282
+ const lineRightPadding = cursorInPadding ? rightPadding.slice(1) : rightPadding;
283
+ // Render the line (no side borders, just horizontal lines above and below)
284
+ result.push(`${leftPadding}${displayText}${padding}${lineRightPadding}`);
285
+ }
286
+ // Render bottom border (with scroll indicator if more content below)
287
+ const linesBelow = layoutLines.length - (this.scrollOffset + visibleLines.length);
288
+ if (linesBelow > 0) {
289
+ const indicator = `─── ↓ ${linesBelow} more `;
290
+ const remaining = width - visibleWidth(indicator);
291
+ result.push(this.borderColor(indicator + "─".repeat(Math.max(0, remaining))));
292
+ }
293
+ else {
294
+ result.push(horizontal.repeat(width));
295
+ }
296
+ // Add autocomplete list if active
297
+ if (this.autocompleteState && this.autocompleteList) {
298
+ const autocompleteResult = this.autocompleteList.render(contentWidth);
299
+ for (const line of autocompleteResult) {
300
+ const lineWidth = visibleWidth(line);
301
+ const linePadding = " ".repeat(Math.max(0, contentWidth - lineWidth));
302
+ result.push(`${leftPadding}${line}${linePadding}${rightPadding}`);
303
+ }
304
+ }
305
+ return result;
306
+ }
307
+ handleInput(data) {
308
+ const kb = getEditorKeybindings();
309
+ // Handle character jump mode (awaiting next character to jump to)
310
+ if (this.jumpMode !== null) {
311
+ // Cancel if the hotkey is pressed again
312
+ if (kb.matches(data, "jumpForward") || kb.matches(data, "jumpBackward")) {
313
+ this.jumpMode = null;
314
+ return;
315
+ }
316
+ if (data.charCodeAt(0) >= 32) {
317
+ // Printable character - perform the jump
318
+ const direction = this.jumpMode;
319
+ this.jumpMode = null;
320
+ this.jumpToChar(data, direction);
321
+ return;
322
+ }
323
+ // Control character - cancel and fall through to normal handling
324
+ this.jumpMode = null;
325
+ }
326
+ // Handle bracketed paste mode
327
+ if (data.includes("\x1b[200~")) {
328
+ this.isInPaste = true;
329
+ this.pasteBuffer = "";
330
+ data = data.replace("\x1b[200~", "");
331
+ }
332
+ if (this.isInPaste) {
333
+ this.pasteBuffer += data;
334
+ const endIndex = this.pasteBuffer.indexOf("\x1b[201~");
335
+ if (endIndex !== -1) {
336
+ const pasteContent = this.pasteBuffer.substring(0, endIndex);
337
+ if (pasteContent.length > 0) {
338
+ this.handlePaste(pasteContent);
339
+ }
340
+ this.isInPaste = false;
341
+ const remaining = this.pasteBuffer.substring(endIndex + 6);
342
+ this.pasteBuffer = "";
343
+ if (remaining.length > 0) {
344
+ this.handleInput(remaining);
345
+ }
346
+ return;
347
+ }
348
+ return;
349
+ }
350
+ // Ctrl+C - let parent handle (exit/clear)
351
+ if (kb.matches(data, "copy")) {
352
+ return;
353
+ }
354
+ // Undo
355
+ if (kb.matches(data, "undo")) {
356
+ this.undo();
357
+ return;
358
+ }
359
+ // Handle autocomplete mode
360
+ if (this.autocompleteState && this.autocompleteList) {
361
+ if (kb.matches(data, "selectCancel")) {
362
+ this.cancelAutocomplete();
363
+ return;
364
+ }
365
+ if (kb.matches(data, "selectUp") || kb.matches(data, "selectDown")) {
366
+ this.autocompleteList.handleInput(data);
367
+ return;
368
+ }
369
+ if (kb.matches(data, "tab")) {
370
+ const selected = this.autocompleteList.getSelectedItem();
371
+ if (selected && this.autocompleteProvider) {
372
+ const shouldChainSlashArgumentAutocomplete = this.shouldChainSlashArgumentAutocompleteOnTabSelection();
373
+ this.pushUndoSnapshot();
374
+ this.lastAction = null;
375
+ const result = this.autocompleteProvider.applyCompletion(this.state.lines, this.state.cursorLine, this.state.cursorCol, selected, this.autocompletePrefix);
376
+ this.state.lines = result.lines;
377
+ this.state.cursorLine = result.cursorLine;
378
+ this.setCursorCol(result.cursorCol);
379
+ this.cancelAutocomplete();
380
+ if (this.onChange)
381
+ this.onChange(this.getText());
382
+ if (shouldChainSlashArgumentAutocomplete && this.isBareCompletedSlashCommandAtCursor()) {
383
+ this.tryTriggerAutocomplete();
384
+ }
385
+ }
386
+ return;
387
+ }
388
+ if (kb.matches(data, "selectConfirm")) {
389
+ const selected = this.autocompleteList.getSelectedItem();
390
+ if (selected && this.autocompleteProvider) {
391
+ this.pushUndoSnapshot();
392
+ this.lastAction = null;
393
+ const result = this.autocompleteProvider.applyCompletion(this.state.lines, this.state.cursorLine, this.state.cursorCol, selected, this.autocompletePrefix);
394
+ this.state.lines = result.lines;
395
+ this.state.cursorLine = result.cursorLine;
396
+ this.setCursorCol(result.cursorCol);
397
+ if (this.autocompletePrefix.startsWith("/")) {
398
+ this.cancelAutocomplete();
399
+ // Fall through to submit
400
+ }
401
+ else {
402
+ this.cancelAutocomplete();
403
+ if (this.onChange)
404
+ this.onChange(this.getText());
405
+ return;
406
+ }
407
+ }
408
+ }
409
+ }
410
+ // Tab - trigger completion
411
+ if (kb.matches(data, "tab") && !this.autocompleteState) {
412
+ this.handleTabCompletion();
413
+ return;
414
+ }
415
+ // Deletion actions
416
+ if (kb.matches(data, "deleteToLineEnd")) {
417
+ this.deleteToEndOfLine();
418
+ return;
419
+ }
420
+ if (kb.matches(data, "deleteToLineStart")) {
421
+ this.deleteToStartOfLine();
422
+ return;
423
+ }
424
+ if (kb.matches(data, "deleteWordBackward")) {
425
+ this.deleteWordBackwards();
426
+ return;
427
+ }
428
+ if (kb.matches(data, "deleteWordForward")) {
429
+ this.deleteWordForward();
430
+ return;
431
+ }
432
+ if (kb.matches(data, "deleteCharBackward") || matchesKey(data, "shift+backspace")) {
433
+ this.handleBackspace();
434
+ return;
435
+ }
436
+ if (kb.matches(data, "deleteCharForward") || matchesKey(data, "shift+delete")) {
437
+ this.handleForwardDelete();
438
+ return;
439
+ }
440
+ // Kill ring actions
441
+ if (kb.matches(data, "yank")) {
442
+ this.yank();
443
+ return;
444
+ }
445
+ if (kb.matches(data, "yankPop")) {
446
+ this.yankPop();
447
+ return;
448
+ }
449
+ // Cursor movement actions
450
+ if (kb.matches(data, "cursorLineStart")) {
451
+ this.moveToLineStart();
452
+ return;
453
+ }
454
+ if (kb.matches(data, "cursorLineEnd")) {
455
+ this.moveToLineEnd();
456
+ return;
457
+ }
458
+ if (kb.matches(data, "cursorWordLeft")) {
459
+ this.moveWordBackwards();
460
+ return;
461
+ }
462
+ if (kb.matches(data, "cursorWordRight")) {
463
+ this.moveWordForwards();
464
+ return;
465
+ }
466
+ // New line
467
+ if (kb.matches(data, "newLine") ||
468
+ (data.charCodeAt(0) === 10 && data.length > 1) ||
469
+ data === "\x1b\r" ||
470
+ data === "\x1b[13;2~" ||
471
+ (data.length > 1 && data.includes("\x1b") && data.includes("\r")) ||
472
+ (data === "\n" && data.length === 1)) {
473
+ if (this.shouldSubmitOnBackslashEnter(data, kb)) {
474
+ this.handleBackspace();
475
+ this.submitValue();
476
+ return;
477
+ }
478
+ this.addNewLine();
479
+ return;
480
+ }
481
+ // Submit (Enter)
482
+ if (kb.matches(data, "submit")) {
483
+ if (this.disableSubmit)
484
+ return;
485
+ // Workaround for terminals without Shift+Enter support:
486
+ // If char before cursor is \, delete it and insert newline instead of submitting.
487
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
488
+ if (this.state.cursorCol > 0 && currentLine[this.state.cursorCol - 1] === "\\") {
489
+ this.handleBackspace();
490
+ this.addNewLine();
491
+ return;
492
+ }
493
+ this.submitValue();
494
+ return;
495
+ }
496
+ // Arrow key navigation (with history support)
497
+ if (kb.matches(data, "cursorUp")) {
498
+ if (this.isEditorEmpty()) {
499
+ this.navigateHistory(-1);
500
+ }
501
+ else if (this.historyIndex > -1 && this.isOnFirstVisualLine()) {
502
+ this.navigateHistory(-1);
503
+ }
504
+ else if (this.isOnFirstVisualLine()) {
505
+ // Already at top - jump to start of line
506
+ this.moveToLineStart();
507
+ }
508
+ else {
509
+ this.moveCursor(-1, 0);
510
+ }
511
+ return;
512
+ }
513
+ if (kb.matches(data, "cursorDown")) {
514
+ if (this.historyIndex > -1 && this.isOnLastVisualLine()) {
515
+ this.navigateHistory(1);
516
+ }
517
+ else if (this.isOnLastVisualLine()) {
518
+ // Already at bottom - jump to end of line
519
+ this.moveToLineEnd();
520
+ }
521
+ else {
522
+ this.moveCursor(1, 0);
523
+ }
524
+ return;
525
+ }
526
+ if (kb.matches(data, "cursorRight")) {
527
+ this.moveCursor(0, 1);
528
+ return;
529
+ }
530
+ if (kb.matches(data, "cursorLeft")) {
531
+ this.moveCursor(0, -1);
532
+ return;
533
+ }
534
+ // Page up/down - scroll by page and move cursor
535
+ if (kb.matches(data, "pageUp")) {
536
+ this.pageScroll(-1);
537
+ return;
538
+ }
539
+ if (kb.matches(data, "pageDown")) {
540
+ this.pageScroll(1);
541
+ return;
542
+ }
543
+ // Character jump mode triggers
544
+ if (kb.matches(data, "jumpForward")) {
545
+ this.jumpMode = "forward";
546
+ return;
547
+ }
548
+ if (kb.matches(data, "jumpBackward")) {
549
+ this.jumpMode = "backward";
550
+ return;
551
+ }
552
+ // Shift+Space - insert regular space
553
+ if (matchesKey(data, "shift+space")) {
554
+ this.insertCharacter(" ");
555
+ return;
556
+ }
557
+ const kittyPrintable = decodeKittyPrintable(data);
558
+ if (kittyPrintable !== undefined) {
559
+ this.insertCharacter(kittyPrintable);
560
+ return;
561
+ }
562
+ // Regular characters
563
+ if (data.charCodeAt(0) >= 32) {
564
+ this.insertCharacter(data);
565
+ }
566
+ }
567
+ layoutText(contentWidth) {
568
+ const layoutLines = [];
569
+ if (this.state.lines.length === 0 || (this.state.lines.length === 1 && this.state.lines[0] === "")) {
570
+ // Empty editor
571
+ layoutLines.push({
572
+ text: "",
573
+ hasCursor: true,
574
+ cursorPos: 0,
575
+ });
576
+ return layoutLines;
577
+ }
578
+ // Process each logical line
579
+ for (let i = 0; i < this.state.lines.length; i++) {
580
+ const line = this.state.lines[i] || "";
581
+ const isCurrentLine = i === this.state.cursorLine;
582
+ const lineVisibleWidth = visibleWidth(line);
583
+ if (lineVisibleWidth <= contentWidth) {
584
+ // Line fits in one layout line
585
+ if (isCurrentLine) {
586
+ layoutLines.push({
587
+ text: line,
588
+ hasCursor: true,
589
+ cursorPos: this.state.cursorCol,
590
+ });
591
+ }
592
+ else {
593
+ layoutLines.push({
594
+ text: line,
595
+ hasCursor: false,
596
+ });
597
+ }
598
+ }
599
+ else {
600
+ // Line needs wrapping - use word-aware wrapping
601
+ const chunks = wordWrapLine(line, contentWidth);
602
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
603
+ const chunk = chunks[chunkIndex];
604
+ if (!chunk)
605
+ continue;
606
+ const cursorPos = this.state.cursorCol;
607
+ const isLastChunk = chunkIndex === chunks.length - 1;
608
+ // Determine if cursor is in this chunk
609
+ // For word-wrapped chunks, we need to handle the case where
610
+ // cursor might be in trimmed whitespace at end of chunk
611
+ let hasCursorInChunk = false;
612
+ let adjustedCursorPos = 0;
613
+ if (isCurrentLine) {
614
+ if (isLastChunk) {
615
+ // Last chunk: cursor belongs here if >= startIndex
616
+ hasCursorInChunk = cursorPos >= chunk.startIndex;
617
+ adjustedCursorPos = cursorPos - chunk.startIndex;
618
+ }
619
+ else {
620
+ // Non-last chunk: cursor belongs here if in range [startIndex, endIndex)
621
+ // But we need to handle the visual position in the trimmed text
622
+ hasCursorInChunk = cursorPos >= chunk.startIndex && cursorPos < chunk.endIndex;
623
+ if (hasCursorInChunk) {
624
+ adjustedCursorPos = cursorPos - chunk.startIndex;
625
+ // Clamp to text length (in case cursor was in trimmed whitespace)
626
+ if (adjustedCursorPos > chunk.text.length) {
627
+ adjustedCursorPos = chunk.text.length;
628
+ }
629
+ }
630
+ }
631
+ }
632
+ if (hasCursorInChunk) {
633
+ layoutLines.push({
634
+ text: chunk.text,
635
+ hasCursor: true,
636
+ cursorPos: adjustedCursorPos,
637
+ });
638
+ }
639
+ else {
640
+ layoutLines.push({
641
+ text: chunk.text,
642
+ hasCursor: false,
643
+ });
644
+ }
645
+ }
646
+ }
647
+ }
648
+ return layoutLines;
649
+ }
650
+ getText() {
651
+ return this.state.lines.join("\n");
652
+ }
653
+ /**
654
+ * Get text with paste markers expanded to their actual content.
655
+ * Use this when you need the full content (e.g., for external editor).
656
+ */
657
+ getExpandedText() {
658
+ let result = this.state.lines.join("\n");
659
+ for (const [pasteId, pasteContent] of this.pastes) {
660
+ const markerRegex = new RegExp(`\\[paste #${pasteId}( (\\+\\d+ lines|\\d+ chars))?\\]`, "g");
661
+ result = result.replace(markerRegex, pasteContent);
662
+ }
663
+ return result;
664
+ }
665
+ getLines() {
666
+ return [...this.state.lines];
667
+ }
668
+ getCursor() {
669
+ return { line: this.state.cursorLine, col: this.state.cursorCol };
670
+ }
671
+ setText(text) {
672
+ this.lastAction = null;
673
+ this.historyIndex = -1; // Exit history browsing mode
674
+ // Push undo snapshot if content differs (makes programmatic changes undoable)
675
+ if (this.getText() !== text) {
676
+ this.pushUndoSnapshot();
677
+ }
678
+ this.setTextInternal(text);
679
+ }
680
+ /**
681
+ * Insert text at the current cursor position.
682
+ * Used for programmatic insertion (e.g., clipboard image markers).
683
+ * This is atomic for undo - single undo restores entire pre-insert state.
684
+ */
685
+ insertTextAtCursor(text) {
686
+ if (!text)
687
+ return;
688
+ this.pushUndoSnapshot();
689
+ this.lastAction = null;
690
+ this.historyIndex = -1;
691
+ this.insertTextAtCursorInternal(text);
692
+ }
693
+ /**
694
+ * Internal text insertion at cursor. Handles single and multi-line text.
695
+ * Does not push undo snapshots or trigger autocomplete - caller is responsible.
696
+ * Normalizes line endings and calls onChange once at the end.
697
+ */
698
+ insertTextAtCursorInternal(text) {
699
+ if (!text)
700
+ return;
701
+ // Normalize line endings
702
+ const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
703
+ const insertedLines = normalized.split("\n");
704
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
705
+ const beforeCursor = currentLine.slice(0, this.state.cursorCol);
706
+ const afterCursor = currentLine.slice(this.state.cursorCol);
707
+ if (insertedLines.length === 1) {
708
+ // Single line - insert at cursor position
709
+ this.state.lines[this.state.cursorLine] = beforeCursor + normalized + afterCursor;
710
+ this.setCursorCol(this.state.cursorCol + normalized.length);
711
+ }
712
+ else {
713
+ // Multi-line insertion
714
+ this.state.lines = [
715
+ // All lines before current line
716
+ ...this.state.lines.slice(0, this.state.cursorLine),
717
+ // The first inserted line merged with text before cursor
718
+ beforeCursor + insertedLines[0],
719
+ // All middle inserted lines
720
+ ...insertedLines.slice(1, -1),
721
+ // The last inserted line with text after cursor
722
+ insertedLines[insertedLines.length - 1] + afterCursor,
723
+ // All lines after current line
724
+ ...this.state.lines.slice(this.state.cursorLine + 1),
725
+ ];
726
+ this.state.cursorLine += insertedLines.length - 1;
727
+ this.setCursorCol((insertedLines[insertedLines.length - 1] || "").length);
728
+ }
729
+ if (this.onChange) {
730
+ this.onChange(this.getText());
731
+ }
732
+ }
733
+ // All the editor methods from before...
734
+ insertCharacter(char, skipUndoCoalescing) {
735
+ this.historyIndex = -1; // Exit history browsing mode
736
+ // Undo coalescing (fish-style):
737
+ // - Consecutive word chars coalesce into one undo unit
738
+ // - Space captures state before itself (so undo removes space+following word together)
739
+ // - Each space is separately undoable
740
+ // Skip coalescing when called from atomic operations (e.g., handlePaste)
741
+ if (!skipUndoCoalescing) {
742
+ if (isWhitespaceChar(char) || this.lastAction !== "type-word") {
743
+ this.pushUndoSnapshot();
744
+ }
745
+ this.lastAction = "type-word";
746
+ }
747
+ const line = this.state.lines[this.state.cursorLine] || "";
748
+ const before = line.slice(0, this.state.cursorCol);
749
+ const after = line.slice(this.state.cursorCol);
750
+ this.state.lines[this.state.cursorLine] = before + char + after;
751
+ this.setCursorCol(this.state.cursorCol + char.length);
752
+ if (this.onChange) {
753
+ this.onChange(this.getText());
754
+ }
755
+ // Check if we should trigger or update autocomplete
756
+ if (!this.autocompleteState) {
757
+ // Auto-trigger for "/" at the start of a line (slash commands)
758
+ if (char === "/" && this.isAtStartOfMessage()) {
759
+ this.tryTriggerAutocomplete();
760
+ }
761
+ // Auto-trigger for "@" file reference (fuzzy search)
762
+ else if (char === "@") {
763
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
764
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
765
+ // Only trigger if @ is after whitespace or at start of line
766
+ const charBeforeAt = textBeforeCursor[textBeforeCursor.length - 2];
767
+ if (textBeforeCursor.length === 1 || charBeforeAt === " " || charBeforeAt === "\t") {
768
+ this.tryTriggerAutocomplete();
769
+ }
770
+ }
771
+ // Also auto-trigger when typing letters in a slash command context
772
+ else if (/[a-zA-Z0-9.\-_]/.test(char)) {
773
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
774
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
775
+ // Check if we're in a slash command (with or without space for arguments)
776
+ if (this.isInSlashCommandContext(textBeforeCursor)) {
777
+ this.tryTriggerAutocomplete();
778
+ }
779
+ // Check if we're in an @ file reference context
780
+ else if (textBeforeCursor.match(/(?:^|[\s])@[^\s]*$/)) {
781
+ this.tryTriggerAutocomplete();
782
+ }
783
+ }
784
+ }
785
+ else {
786
+ this.updateAutocomplete();
787
+ }
788
+ }
789
+ handlePaste(pastedText) {
790
+ this.historyIndex = -1; // Exit history browsing mode
791
+ this.lastAction = null;
792
+ this.pushUndoSnapshot();
793
+ // Clean the pasted text
794
+ const cleanText = pastedText.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
795
+ // Convert tabs to spaces (4 spaces per tab)
796
+ const tabExpandedText = cleanText.replace(/\t/g, " ");
797
+ // Filter out non-printable characters except newlines
798
+ let filteredText = tabExpandedText
799
+ .split("")
800
+ .filter((char) => char === "\n" || char.charCodeAt(0) >= 32)
801
+ .join("");
802
+ // If pasting a file path (starts with /, ~, or .) and the character before
803
+ // the cursor is a word character, prepend a space for better readability
804
+ if (/^[/~.]/.test(filteredText)) {
805
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
806
+ const charBeforeCursor = this.state.cursorCol > 0 ? currentLine[this.state.cursorCol - 1] : "";
807
+ if (charBeforeCursor && /\w/.test(charBeforeCursor)) {
808
+ filteredText = ` ${filteredText}`;
809
+ }
810
+ }
811
+ // Split into lines to check for large paste
812
+ const pastedLines = filteredText.split("\n");
813
+ // Check if this is a large paste (> 10 lines or > 1000 characters)
814
+ const totalChars = filteredText.length;
815
+ if (pastedLines.length > 10 || totalChars > 1000) {
816
+ // Store the paste and insert a marker
817
+ this.pasteCounter++;
818
+ const pasteId = this.pasteCounter;
819
+ this.pastes.set(pasteId, filteredText);
820
+ // Insert marker like "[paste #1 +123 lines]" or "[paste #1 1234 chars]"
821
+ const marker = pastedLines.length > 10
822
+ ? `[paste #${pasteId} +${pastedLines.length} lines]`
823
+ : `[paste #${pasteId} ${totalChars} chars]`;
824
+ this.insertTextAtCursorInternal(marker);
825
+ return;
826
+ }
827
+ if (pastedLines.length === 1) {
828
+ // Single line - insert atomically (do not trigger autocomplete during paste)
829
+ this.insertTextAtCursorInternal(filteredText);
830
+ return;
831
+ }
832
+ // Multi-line paste - use direct state manipulation
833
+ this.insertTextAtCursorInternal(filteredText);
834
+ }
835
+ addNewLine() {
836
+ this.historyIndex = -1; // Exit history browsing mode
837
+ this.lastAction = null;
838
+ this.pushUndoSnapshot();
839
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
840
+ const before = currentLine.slice(0, this.state.cursorCol);
841
+ const after = currentLine.slice(this.state.cursorCol);
842
+ // Split current line
843
+ this.state.lines[this.state.cursorLine] = before;
844
+ this.state.lines.splice(this.state.cursorLine + 1, 0, after);
845
+ // Move cursor to start of new line
846
+ this.state.cursorLine++;
847
+ this.setCursorCol(0);
848
+ if (this.onChange) {
849
+ this.onChange(this.getText());
850
+ }
851
+ }
852
+ shouldSubmitOnBackslashEnter(data, kb) {
853
+ if (this.disableSubmit)
854
+ return false;
855
+ if (!matchesKey(data, "enter"))
856
+ return false;
857
+ const submitKeys = kb.getKeys("submit");
858
+ const hasShiftEnter = submitKeys.includes("shift+enter") || submitKeys.includes("shift+return");
859
+ if (!hasShiftEnter)
860
+ return false;
861
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
862
+ return this.state.cursorCol > 0 && currentLine[this.state.cursorCol - 1] === "\\";
863
+ }
864
+ submitValue() {
865
+ let result = this.state.lines.join("\n").trim();
866
+ for (const [pasteId, pasteContent] of this.pastes) {
867
+ const markerRegex = new RegExp(`\\[paste #${pasteId}( (\\+\\d+ lines|\\d+ chars))?\\]`, "g");
868
+ result = result.replace(markerRegex, pasteContent);
869
+ }
870
+ this.state = { lines: [""], cursorLine: 0, cursorCol: 0 };
871
+ this.pastes.clear();
872
+ this.pasteCounter = 0;
873
+ this.historyIndex = -1;
874
+ this.scrollOffset = 0;
875
+ this.undoStack.clear();
876
+ this.lastAction = null;
877
+ if (this.onChange)
878
+ this.onChange("");
879
+ if (this.onSubmit)
880
+ this.onSubmit(result);
881
+ }
882
+ handleBackspace() {
883
+ this.historyIndex = -1; // Exit history browsing mode
884
+ this.lastAction = null;
885
+ if (this.state.cursorCol > 0) {
886
+ this.pushUndoSnapshot();
887
+ // Delete grapheme before cursor (handles emojis, combining characters, etc.)
888
+ const line = this.state.lines[this.state.cursorLine] || "";
889
+ const beforeCursor = line.slice(0, this.state.cursorCol);
890
+ // Find the last grapheme in the text before cursor
891
+ const graphemes = [...segmenter.segment(beforeCursor)];
892
+ const lastGrapheme = graphemes[graphemes.length - 1];
893
+ const graphemeLength = lastGrapheme ? lastGrapheme.segment.length : 1;
894
+ const before = line.slice(0, this.state.cursorCol - graphemeLength);
895
+ const after = line.slice(this.state.cursorCol);
896
+ this.state.lines[this.state.cursorLine] = before + after;
897
+ this.setCursorCol(this.state.cursorCol - graphemeLength);
898
+ }
899
+ else if (this.state.cursorLine > 0) {
900
+ this.pushUndoSnapshot();
901
+ // Merge with previous line
902
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
903
+ const previousLine = this.state.lines[this.state.cursorLine - 1] || "";
904
+ this.state.lines[this.state.cursorLine - 1] = previousLine + currentLine;
905
+ this.state.lines.splice(this.state.cursorLine, 1);
906
+ this.state.cursorLine--;
907
+ this.setCursorCol(previousLine.length);
908
+ }
909
+ if (this.onChange) {
910
+ this.onChange(this.getText());
911
+ }
912
+ // Update or re-trigger autocomplete after backspace
913
+ if (this.autocompleteState) {
914
+ this.updateAutocomplete();
915
+ }
916
+ else {
917
+ // If autocomplete was cancelled (no matches), re-trigger if we're in a completable context
918
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
919
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
920
+ // Slash command context
921
+ if (this.isInSlashCommandContext(textBeforeCursor)) {
922
+ this.tryTriggerAutocomplete();
923
+ }
924
+ // @ file reference context
925
+ else if (textBeforeCursor.match(/(?:^|[\s])@[^\s]*$/)) {
926
+ this.tryTriggerAutocomplete();
927
+ }
928
+ }
929
+ }
930
+ /**
931
+ * Set cursor column and clear preferredVisualCol.
932
+ * Use this for all non-vertical cursor movements to reset sticky column behavior.
933
+ */
934
+ setCursorCol(col) {
935
+ this.state.cursorCol = col;
936
+ this.preferredVisualCol = null;
937
+ }
938
+ /**
939
+ * Move cursor to a target visual line, applying sticky column logic.
940
+ * Shared by moveCursor() and pageScroll().
941
+ */
942
+ moveToVisualLine(visualLines, currentVisualLine, targetVisualLine) {
943
+ const currentVL = visualLines[currentVisualLine];
944
+ const targetVL = visualLines[targetVisualLine];
945
+ if (currentVL && targetVL) {
946
+ const currentVisualCol = this.state.cursorCol - currentVL.startCol;
947
+ // For non-last segments, clamp to length-1 to stay within the segment
948
+ const isLastSourceSegment = currentVisualLine === visualLines.length - 1 ||
949
+ visualLines[currentVisualLine + 1]?.logicalLine !== currentVL.logicalLine;
950
+ const sourceMaxVisualCol = isLastSourceSegment ? currentVL.length : Math.max(0, currentVL.length - 1);
951
+ const isLastTargetSegment = targetVisualLine === visualLines.length - 1 ||
952
+ visualLines[targetVisualLine + 1]?.logicalLine !== targetVL.logicalLine;
953
+ const targetMaxVisualCol = isLastTargetSegment ? targetVL.length : Math.max(0, targetVL.length - 1);
954
+ const moveToVisualCol = this.computeVerticalMoveColumn(currentVisualCol, sourceMaxVisualCol, targetMaxVisualCol);
955
+ // Set cursor position
956
+ this.state.cursorLine = targetVL.logicalLine;
957
+ const targetCol = targetVL.startCol + moveToVisualCol;
958
+ const logicalLine = this.state.lines[targetVL.logicalLine] || "";
959
+ this.state.cursorCol = Math.min(targetCol, logicalLine.length);
960
+ }
961
+ }
962
+ /**
963
+ * Compute the target visual column for vertical cursor movement.
964
+ * Implements the sticky column decision table:
965
+ *
966
+ * | P | S | T | U | Scenario | Set Preferred | Move To |
967
+ * |---|---|---|---| ---------------------------------------------------- |---------------|-------------|
968
+ * | 0 | * | 0 | - | Start nav, target fits | null | current |
969
+ * | 0 | * | 1 | - | Start nav, target shorter | current | target end |
970
+ * | 1 | 0 | 0 | 0 | Clamped, target fits preferred | null | preferred |
971
+ * | 1 | 0 | 0 | 1 | Clamped, target longer but still can't fit preferred | keep | target end |
972
+ * | 1 | 0 | 1 | - | Clamped, target even shorter | keep | target end |
973
+ * | 1 | 1 | 0 | - | Rewrapped, target fits current | null | current |
974
+ * | 1 | 1 | 1 | - | Rewrapped, target shorter than current | current | target end |
975
+ *
976
+ * Where:
977
+ * - P = preferred col is set
978
+ * - S = cursor in middle of source line (not clamped to end)
979
+ * - T = target line shorter than current visual col
980
+ * - U = target line shorter than preferred col
981
+ */
982
+ computeVerticalMoveColumn(currentVisualCol, sourceMaxVisualCol, targetMaxVisualCol) {
983
+ const hasPreferred = this.preferredVisualCol !== null; // P
984
+ const cursorInMiddle = currentVisualCol < sourceMaxVisualCol; // S
985
+ const targetTooShort = targetMaxVisualCol < currentVisualCol; // T
986
+ if (!hasPreferred || cursorInMiddle) {
987
+ if (targetTooShort) {
988
+ // Cases 2 and 7
989
+ this.preferredVisualCol = currentVisualCol;
990
+ return targetMaxVisualCol;
991
+ }
992
+ // Cases 1 and 6
993
+ this.preferredVisualCol = null;
994
+ return currentVisualCol;
995
+ }
996
+ const targetCantFitPreferred = targetMaxVisualCol < this.preferredVisualCol; // U
997
+ if (targetTooShort || targetCantFitPreferred) {
998
+ // Cases 4 and 5
999
+ return targetMaxVisualCol;
1000
+ }
1001
+ // Case 3
1002
+ const result = this.preferredVisualCol;
1003
+ this.preferredVisualCol = null;
1004
+ return result;
1005
+ }
1006
+ moveToLineStart() {
1007
+ this.lastAction = null;
1008
+ this.setCursorCol(0);
1009
+ }
1010
+ moveToLineEnd() {
1011
+ this.lastAction = null;
1012
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1013
+ this.setCursorCol(currentLine.length);
1014
+ }
1015
+ deleteToStartOfLine() {
1016
+ this.historyIndex = -1; // Exit history browsing mode
1017
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1018
+ if (this.state.cursorCol > 0) {
1019
+ this.pushUndoSnapshot();
1020
+ // Calculate text to be deleted and save to kill ring (backward deletion = prepend)
1021
+ const deletedText = currentLine.slice(0, this.state.cursorCol);
1022
+ this.killRing.push(deletedText, { prepend: true, accumulate: this.lastAction === "kill" });
1023
+ this.lastAction = "kill";
1024
+ // Delete from start of line up to cursor
1025
+ this.state.lines[this.state.cursorLine] = currentLine.slice(this.state.cursorCol);
1026
+ this.setCursorCol(0);
1027
+ }
1028
+ else if (this.state.cursorLine > 0) {
1029
+ this.pushUndoSnapshot();
1030
+ // At start of line - merge with previous line, treating newline as deleted text
1031
+ this.killRing.push("\n", { prepend: true, accumulate: this.lastAction === "kill" });
1032
+ this.lastAction = "kill";
1033
+ const previousLine = this.state.lines[this.state.cursorLine - 1] || "";
1034
+ this.state.lines[this.state.cursorLine - 1] = previousLine + currentLine;
1035
+ this.state.lines.splice(this.state.cursorLine, 1);
1036
+ this.state.cursorLine--;
1037
+ this.setCursorCol(previousLine.length);
1038
+ }
1039
+ if (this.onChange) {
1040
+ this.onChange(this.getText());
1041
+ }
1042
+ }
1043
+ deleteToEndOfLine() {
1044
+ this.historyIndex = -1; // Exit history browsing mode
1045
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1046
+ if (this.state.cursorCol < currentLine.length) {
1047
+ this.pushUndoSnapshot();
1048
+ // Calculate text to be deleted and save to kill ring (forward deletion = append)
1049
+ const deletedText = currentLine.slice(this.state.cursorCol);
1050
+ this.killRing.push(deletedText, { prepend: false, accumulate: this.lastAction === "kill" });
1051
+ this.lastAction = "kill";
1052
+ // Delete from cursor to end of line
1053
+ this.state.lines[this.state.cursorLine] = currentLine.slice(0, this.state.cursorCol);
1054
+ }
1055
+ else if (this.state.cursorLine < this.state.lines.length - 1) {
1056
+ this.pushUndoSnapshot();
1057
+ // At end of line - merge with next line, treating newline as deleted text
1058
+ this.killRing.push("\n", { prepend: false, accumulate: this.lastAction === "kill" });
1059
+ this.lastAction = "kill";
1060
+ const nextLine = this.state.lines[this.state.cursorLine + 1] || "";
1061
+ this.state.lines[this.state.cursorLine] = currentLine + nextLine;
1062
+ this.state.lines.splice(this.state.cursorLine + 1, 1);
1063
+ }
1064
+ if (this.onChange) {
1065
+ this.onChange(this.getText());
1066
+ }
1067
+ }
1068
+ deleteWordBackwards() {
1069
+ this.historyIndex = -1; // Exit history browsing mode
1070
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1071
+ // If at start of line, behave like backspace at column 0 (merge with previous line)
1072
+ if (this.state.cursorCol === 0) {
1073
+ if (this.state.cursorLine > 0) {
1074
+ this.pushUndoSnapshot();
1075
+ // Treat newline as deleted text (backward deletion = prepend)
1076
+ this.killRing.push("\n", { prepend: true, accumulate: this.lastAction === "kill" });
1077
+ this.lastAction = "kill";
1078
+ const previousLine = this.state.lines[this.state.cursorLine - 1] || "";
1079
+ this.state.lines[this.state.cursorLine - 1] = previousLine + currentLine;
1080
+ this.state.lines.splice(this.state.cursorLine, 1);
1081
+ this.state.cursorLine--;
1082
+ this.setCursorCol(previousLine.length);
1083
+ }
1084
+ }
1085
+ else {
1086
+ this.pushUndoSnapshot();
1087
+ // Save lastAction before cursor movement (moveWordBackwards resets it)
1088
+ const wasKill = this.lastAction === "kill";
1089
+ const oldCursorCol = this.state.cursorCol;
1090
+ this.moveWordBackwards();
1091
+ const deleteFrom = this.state.cursorCol;
1092
+ this.setCursorCol(oldCursorCol);
1093
+ const deletedText = currentLine.slice(deleteFrom, this.state.cursorCol);
1094
+ this.killRing.push(deletedText, { prepend: true, accumulate: wasKill });
1095
+ this.lastAction = "kill";
1096
+ this.state.lines[this.state.cursorLine] =
1097
+ currentLine.slice(0, deleteFrom) + currentLine.slice(this.state.cursorCol);
1098
+ this.setCursorCol(deleteFrom);
1099
+ }
1100
+ if (this.onChange) {
1101
+ this.onChange(this.getText());
1102
+ }
1103
+ }
1104
+ deleteWordForward() {
1105
+ this.historyIndex = -1; // Exit history browsing mode
1106
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1107
+ // If at end of line, merge with next line (delete the newline)
1108
+ if (this.state.cursorCol >= currentLine.length) {
1109
+ if (this.state.cursorLine < this.state.lines.length - 1) {
1110
+ this.pushUndoSnapshot();
1111
+ // Treat newline as deleted text (forward deletion = append)
1112
+ this.killRing.push("\n", { prepend: false, accumulate: this.lastAction === "kill" });
1113
+ this.lastAction = "kill";
1114
+ const nextLine = this.state.lines[this.state.cursorLine + 1] || "";
1115
+ this.state.lines[this.state.cursorLine] = currentLine + nextLine;
1116
+ this.state.lines.splice(this.state.cursorLine + 1, 1);
1117
+ }
1118
+ }
1119
+ else {
1120
+ this.pushUndoSnapshot();
1121
+ // Save lastAction before cursor movement (moveWordForwards resets it)
1122
+ const wasKill = this.lastAction === "kill";
1123
+ const oldCursorCol = this.state.cursorCol;
1124
+ this.moveWordForwards();
1125
+ const deleteTo = this.state.cursorCol;
1126
+ this.setCursorCol(oldCursorCol);
1127
+ const deletedText = currentLine.slice(this.state.cursorCol, deleteTo);
1128
+ this.killRing.push(deletedText, { prepend: false, accumulate: wasKill });
1129
+ this.lastAction = "kill";
1130
+ this.state.lines[this.state.cursorLine] =
1131
+ currentLine.slice(0, this.state.cursorCol) + currentLine.slice(deleteTo);
1132
+ }
1133
+ if (this.onChange) {
1134
+ this.onChange(this.getText());
1135
+ }
1136
+ }
1137
+ handleForwardDelete() {
1138
+ this.historyIndex = -1; // Exit history browsing mode
1139
+ this.lastAction = null;
1140
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1141
+ if (this.state.cursorCol < currentLine.length) {
1142
+ this.pushUndoSnapshot();
1143
+ // Delete grapheme at cursor position (handles emojis, combining characters, etc.)
1144
+ const afterCursor = currentLine.slice(this.state.cursorCol);
1145
+ // Find the first grapheme at cursor
1146
+ const graphemes = [...segmenter.segment(afterCursor)];
1147
+ const firstGrapheme = graphemes[0];
1148
+ const graphemeLength = firstGrapheme ? firstGrapheme.segment.length : 1;
1149
+ const before = currentLine.slice(0, this.state.cursorCol);
1150
+ const after = currentLine.slice(this.state.cursorCol + graphemeLength);
1151
+ this.state.lines[this.state.cursorLine] = before + after;
1152
+ }
1153
+ else if (this.state.cursorLine < this.state.lines.length - 1) {
1154
+ this.pushUndoSnapshot();
1155
+ // At end of line - merge with next line
1156
+ const nextLine = this.state.lines[this.state.cursorLine + 1] || "";
1157
+ this.state.lines[this.state.cursorLine] = currentLine + nextLine;
1158
+ this.state.lines.splice(this.state.cursorLine + 1, 1);
1159
+ }
1160
+ if (this.onChange) {
1161
+ this.onChange(this.getText());
1162
+ }
1163
+ // Update or re-trigger autocomplete after forward delete
1164
+ if (this.autocompleteState) {
1165
+ this.updateAutocomplete();
1166
+ }
1167
+ else {
1168
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1169
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
1170
+ // Slash command context
1171
+ if (this.isInSlashCommandContext(textBeforeCursor)) {
1172
+ this.tryTriggerAutocomplete();
1173
+ }
1174
+ // @ file reference context
1175
+ else if (textBeforeCursor.match(/(?:^|[\s])@[^\s]*$/)) {
1176
+ this.tryTriggerAutocomplete();
1177
+ }
1178
+ }
1179
+ }
1180
+ /**
1181
+ * Build a mapping from visual lines to logical positions.
1182
+ * Returns an array where each element represents a visual line with:
1183
+ * - logicalLine: index into this.state.lines
1184
+ * - startCol: starting column in the logical line
1185
+ * - length: length of this visual line segment
1186
+ */
1187
+ buildVisualLineMap(width) {
1188
+ const visualLines = [];
1189
+ for (let i = 0; i < this.state.lines.length; i++) {
1190
+ const line = this.state.lines[i] || "";
1191
+ const lineVisWidth = visibleWidth(line);
1192
+ if (line.length === 0) {
1193
+ // Empty line still takes one visual line
1194
+ visualLines.push({ logicalLine: i, startCol: 0, length: 0 });
1195
+ }
1196
+ else if (lineVisWidth <= width) {
1197
+ visualLines.push({ logicalLine: i, startCol: 0, length: line.length });
1198
+ }
1199
+ else {
1200
+ // Line needs wrapping - use word-aware wrapping
1201
+ const chunks = wordWrapLine(line, width);
1202
+ for (const chunk of chunks) {
1203
+ visualLines.push({
1204
+ logicalLine: i,
1205
+ startCol: chunk.startIndex,
1206
+ length: chunk.endIndex - chunk.startIndex,
1207
+ });
1208
+ }
1209
+ }
1210
+ }
1211
+ return visualLines;
1212
+ }
1213
+ /**
1214
+ * Find the visual line index for the current cursor position.
1215
+ */
1216
+ findCurrentVisualLine(visualLines) {
1217
+ for (let i = 0; i < visualLines.length; i++) {
1218
+ const vl = visualLines[i];
1219
+ if (!vl)
1220
+ continue;
1221
+ if (vl.logicalLine === this.state.cursorLine) {
1222
+ const colInSegment = this.state.cursorCol - vl.startCol;
1223
+ // Cursor is in this segment if it's within range
1224
+ // For the last segment of a logical line, cursor can be at length (end position)
1225
+ const isLastSegmentOfLine = i === visualLines.length - 1 || visualLines[i + 1]?.logicalLine !== vl.logicalLine;
1226
+ if (colInSegment >= 0 && (colInSegment < vl.length || (isLastSegmentOfLine && colInSegment <= vl.length))) {
1227
+ return i;
1228
+ }
1229
+ }
1230
+ }
1231
+ // Fallback: return last visual line
1232
+ return visualLines.length - 1;
1233
+ }
1234
+ moveCursor(deltaLine, deltaCol) {
1235
+ this.lastAction = null;
1236
+ const visualLines = this.buildVisualLineMap(this.lastWidth);
1237
+ const currentVisualLine = this.findCurrentVisualLine(visualLines);
1238
+ if (deltaLine !== 0) {
1239
+ const targetVisualLine = currentVisualLine + deltaLine;
1240
+ if (targetVisualLine >= 0 && targetVisualLine < visualLines.length) {
1241
+ this.moveToVisualLine(visualLines, currentVisualLine, targetVisualLine);
1242
+ }
1243
+ }
1244
+ if (deltaCol !== 0) {
1245
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1246
+ if (deltaCol > 0) {
1247
+ // Moving right - move by one grapheme (handles emojis, combining characters, etc.)
1248
+ if (this.state.cursorCol < currentLine.length) {
1249
+ const afterCursor = currentLine.slice(this.state.cursorCol);
1250
+ const graphemes = [...segmenter.segment(afterCursor)];
1251
+ const firstGrapheme = graphemes[0];
1252
+ this.setCursorCol(this.state.cursorCol + (firstGrapheme ? firstGrapheme.segment.length : 1));
1253
+ }
1254
+ else if (this.state.cursorLine < this.state.lines.length - 1) {
1255
+ // Wrap to start of next logical line
1256
+ this.state.cursorLine++;
1257
+ this.setCursorCol(0);
1258
+ }
1259
+ else {
1260
+ // At end of last line - can't move, but set preferredVisualCol for up/down navigation
1261
+ const currentVL = visualLines[currentVisualLine];
1262
+ if (currentVL) {
1263
+ this.preferredVisualCol = this.state.cursorCol - currentVL.startCol;
1264
+ }
1265
+ }
1266
+ }
1267
+ else {
1268
+ // Moving left - move by one grapheme (handles emojis, combining characters, etc.)
1269
+ if (this.state.cursorCol > 0) {
1270
+ const beforeCursor = currentLine.slice(0, this.state.cursorCol);
1271
+ const graphemes = [...segmenter.segment(beforeCursor)];
1272
+ const lastGrapheme = graphemes[graphemes.length - 1];
1273
+ this.setCursorCol(this.state.cursorCol - (lastGrapheme ? lastGrapheme.segment.length : 1));
1274
+ }
1275
+ else if (this.state.cursorLine > 0) {
1276
+ // Wrap to end of previous logical line
1277
+ this.state.cursorLine--;
1278
+ const prevLine = this.state.lines[this.state.cursorLine] || "";
1279
+ this.setCursorCol(prevLine.length);
1280
+ }
1281
+ }
1282
+ }
1283
+ }
1284
+ /**
1285
+ * Scroll by a page (direction: -1 for up, 1 for down).
1286
+ * Moves cursor by the page size while keeping it in bounds.
1287
+ */
1288
+ pageScroll(direction) {
1289
+ this.lastAction = null;
1290
+ const terminalRows = this.tui.terminal.rows;
1291
+ const pageSize = Math.max(5, Math.floor(terminalRows * 0.3));
1292
+ const visualLines = this.buildVisualLineMap(this.lastWidth);
1293
+ const currentVisualLine = this.findCurrentVisualLine(visualLines);
1294
+ const targetVisualLine = Math.max(0, Math.min(visualLines.length - 1, currentVisualLine + direction * pageSize));
1295
+ this.moveToVisualLine(visualLines, currentVisualLine, targetVisualLine);
1296
+ }
1297
+ moveWordBackwards() {
1298
+ this.lastAction = null;
1299
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1300
+ // If at start of line, move to end of previous line
1301
+ if (this.state.cursorCol === 0) {
1302
+ if (this.state.cursorLine > 0) {
1303
+ this.state.cursorLine--;
1304
+ const prevLine = this.state.lines[this.state.cursorLine] || "";
1305
+ this.setCursorCol(prevLine.length);
1306
+ }
1307
+ return;
1308
+ }
1309
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
1310
+ const graphemes = [...segmenter.segment(textBeforeCursor)];
1311
+ let newCol = this.state.cursorCol;
1312
+ // Skip trailing whitespace
1313
+ while (graphemes.length > 0 && isWhitespaceChar(graphemes[graphemes.length - 1]?.segment || "")) {
1314
+ newCol -= graphemes.pop()?.segment.length || 0;
1315
+ }
1316
+ if (graphemes.length > 0) {
1317
+ const lastGrapheme = graphemes[graphemes.length - 1]?.segment || "";
1318
+ if (isPunctuationChar(lastGrapheme)) {
1319
+ // Skip punctuation run
1320
+ while (graphemes.length > 0 && isPunctuationChar(graphemes[graphemes.length - 1]?.segment || "")) {
1321
+ newCol -= graphemes.pop()?.segment.length || 0;
1322
+ }
1323
+ }
1324
+ else {
1325
+ // Skip word run
1326
+ while (graphemes.length > 0 &&
1327
+ !isWhitespaceChar(graphemes[graphemes.length - 1]?.segment || "") &&
1328
+ !isPunctuationChar(graphemes[graphemes.length - 1]?.segment || "")) {
1329
+ newCol -= graphemes.pop()?.segment.length || 0;
1330
+ }
1331
+ }
1332
+ }
1333
+ this.setCursorCol(newCol);
1334
+ }
1335
+ /**
1336
+ * Yank (paste) the most recent kill ring entry at cursor position.
1337
+ */
1338
+ yank() {
1339
+ if (this.killRing.length === 0)
1340
+ return;
1341
+ this.pushUndoSnapshot();
1342
+ const text = this.killRing.peek();
1343
+ this.insertYankedText(text);
1344
+ this.lastAction = "yank";
1345
+ }
1346
+ /**
1347
+ * Cycle through kill ring (only works immediately after yank or yank-pop).
1348
+ * Replaces the last yanked text with the previous entry in the ring.
1349
+ */
1350
+ yankPop() {
1351
+ // Only works if we just yanked and have more than one entry
1352
+ if (this.lastAction !== "yank" || this.killRing.length <= 1)
1353
+ return;
1354
+ this.pushUndoSnapshot();
1355
+ // Delete the previously yanked text (still at end of ring before rotation)
1356
+ this.deleteYankedText();
1357
+ // Rotate the ring: move end to front
1358
+ this.killRing.rotate();
1359
+ // Insert the new most recent entry (now at end after rotation)
1360
+ const text = this.killRing.peek();
1361
+ this.insertYankedText(text);
1362
+ this.lastAction = "yank";
1363
+ }
1364
+ /**
1365
+ * Insert text at cursor position (used by yank operations).
1366
+ */
1367
+ insertYankedText(text) {
1368
+ this.historyIndex = -1; // Exit history browsing mode
1369
+ const lines = text.split("\n");
1370
+ if (lines.length === 1) {
1371
+ // Single line - insert at cursor
1372
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1373
+ const before = currentLine.slice(0, this.state.cursorCol);
1374
+ const after = currentLine.slice(this.state.cursorCol);
1375
+ this.state.lines[this.state.cursorLine] = before + text + after;
1376
+ this.setCursorCol(this.state.cursorCol + text.length);
1377
+ }
1378
+ else {
1379
+ // Multi-line insert
1380
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1381
+ const before = currentLine.slice(0, this.state.cursorCol);
1382
+ const after = currentLine.slice(this.state.cursorCol);
1383
+ // First line merges with text before cursor
1384
+ this.state.lines[this.state.cursorLine] = before + (lines[0] || "");
1385
+ // Insert middle lines
1386
+ for (let i = 1; i < lines.length - 1; i++) {
1387
+ this.state.lines.splice(this.state.cursorLine + i, 0, lines[i] || "");
1388
+ }
1389
+ // Last line merges with text after cursor
1390
+ const lastLineIndex = this.state.cursorLine + lines.length - 1;
1391
+ this.state.lines.splice(lastLineIndex, 0, (lines[lines.length - 1] || "") + after);
1392
+ // Update cursor position
1393
+ this.state.cursorLine = lastLineIndex;
1394
+ this.setCursorCol((lines[lines.length - 1] || "").length);
1395
+ }
1396
+ if (this.onChange) {
1397
+ this.onChange(this.getText());
1398
+ }
1399
+ }
1400
+ /**
1401
+ * Delete the previously yanked text (used by yank-pop).
1402
+ * The yanked text is derived from killRing[end] since it hasn't been rotated yet.
1403
+ */
1404
+ deleteYankedText() {
1405
+ const yankedText = this.killRing.peek();
1406
+ if (!yankedText)
1407
+ return;
1408
+ const yankLines = yankedText.split("\n");
1409
+ if (yankLines.length === 1) {
1410
+ // Single line - delete backward from cursor
1411
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1412
+ const deleteLen = yankedText.length;
1413
+ const before = currentLine.slice(0, this.state.cursorCol - deleteLen);
1414
+ const after = currentLine.slice(this.state.cursorCol);
1415
+ this.state.lines[this.state.cursorLine] = before + after;
1416
+ this.setCursorCol(this.state.cursorCol - deleteLen);
1417
+ }
1418
+ else {
1419
+ // Multi-line delete - cursor is at end of last yanked line
1420
+ const startLine = this.state.cursorLine - (yankLines.length - 1);
1421
+ const startCol = (this.state.lines[startLine] || "").length - (yankLines[0] || "").length;
1422
+ // Get text after cursor on current line
1423
+ const afterCursor = (this.state.lines[this.state.cursorLine] || "").slice(this.state.cursorCol);
1424
+ // Get text before yank start position
1425
+ const beforeYank = (this.state.lines[startLine] || "").slice(0, startCol);
1426
+ // Remove all lines from startLine to cursorLine and replace with merged line
1427
+ this.state.lines.splice(startLine, yankLines.length, beforeYank + afterCursor);
1428
+ // Update cursor
1429
+ this.state.cursorLine = startLine;
1430
+ this.setCursorCol(startCol);
1431
+ }
1432
+ if (this.onChange) {
1433
+ this.onChange(this.getText());
1434
+ }
1435
+ }
1436
+ pushUndoSnapshot() {
1437
+ this.undoStack.push(this.state);
1438
+ }
1439
+ undo() {
1440
+ this.historyIndex = -1; // Exit history browsing mode
1441
+ const snapshot = this.undoStack.pop();
1442
+ if (!snapshot)
1443
+ return;
1444
+ Object.assign(this.state, snapshot);
1445
+ this.lastAction = null;
1446
+ this.preferredVisualCol = null;
1447
+ if (this.onChange) {
1448
+ this.onChange(this.getText());
1449
+ }
1450
+ }
1451
+ /**
1452
+ * Jump to the first occurrence of a character in the specified direction.
1453
+ * Multi-line search. Case-sensitive. Skips the current cursor position.
1454
+ */
1455
+ jumpToChar(char, direction) {
1456
+ this.lastAction = null;
1457
+ const isForward = direction === "forward";
1458
+ const lines = this.state.lines;
1459
+ const end = isForward ? lines.length : -1;
1460
+ const step = isForward ? 1 : -1;
1461
+ for (let lineIdx = this.state.cursorLine; lineIdx !== end; lineIdx += step) {
1462
+ const line = lines[lineIdx] || "";
1463
+ const isCurrentLine = lineIdx === this.state.cursorLine;
1464
+ // Current line: start after/before cursor; other lines: search full line
1465
+ const searchFrom = isCurrentLine
1466
+ ? isForward
1467
+ ? this.state.cursorCol + 1
1468
+ : this.state.cursorCol - 1
1469
+ : undefined;
1470
+ const idx = isForward ? line.indexOf(char, searchFrom) : line.lastIndexOf(char, searchFrom);
1471
+ if (idx !== -1) {
1472
+ this.state.cursorLine = lineIdx;
1473
+ this.setCursorCol(idx);
1474
+ return;
1475
+ }
1476
+ }
1477
+ // No match found - cursor stays in place
1478
+ }
1479
+ moveWordForwards() {
1480
+ this.lastAction = null;
1481
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1482
+ // If at end of line, move to start of next line
1483
+ if (this.state.cursorCol >= currentLine.length) {
1484
+ if (this.state.cursorLine < this.state.lines.length - 1) {
1485
+ this.state.cursorLine++;
1486
+ this.setCursorCol(0);
1487
+ }
1488
+ return;
1489
+ }
1490
+ const textAfterCursor = currentLine.slice(this.state.cursorCol);
1491
+ const segments = segmenter.segment(textAfterCursor);
1492
+ const iterator = segments[Symbol.iterator]();
1493
+ let next = iterator.next();
1494
+ let newCol = this.state.cursorCol;
1495
+ // Skip leading whitespace
1496
+ while (!next.done && isWhitespaceChar(next.value.segment)) {
1497
+ newCol += next.value.segment.length;
1498
+ next = iterator.next();
1499
+ }
1500
+ if (!next.done) {
1501
+ const firstGrapheme = next.value.segment;
1502
+ if (isPunctuationChar(firstGrapheme)) {
1503
+ // Skip punctuation run
1504
+ while (!next.done && isPunctuationChar(next.value.segment)) {
1505
+ newCol += next.value.segment.length;
1506
+ next = iterator.next();
1507
+ }
1508
+ }
1509
+ else {
1510
+ // Skip word run
1511
+ while (!next.done && !isWhitespaceChar(next.value.segment) && !isPunctuationChar(next.value.segment)) {
1512
+ newCol += next.value.segment.length;
1513
+ next = iterator.next();
1514
+ }
1515
+ }
1516
+ }
1517
+ this.setCursorCol(newCol);
1518
+ }
1519
+ // Slash menu only allowed on the first line of the editor
1520
+ isSlashMenuAllowed() {
1521
+ return this.state.cursorLine === 0;
1522
+ }
1523
+ // Helper method to check if cursor is at start of message (for slash command detection)
1524
+ isAtStartOfMessage() {
1525
+ if (!this.isSlashMenuAllowed())
1526
+ return false;
1527
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1528
+ const beforeCursor = currentLine.slice(0, this.state.cursorCol);
1529
+ return beforeCursor.trim() === "" || beforeCursor.trim() === "/";
1530
+ }
1531
+ isInSlashCommandContext(textBeforeCursor) {
1532
+ return this.isSlashMenuAllowed() && textBeforeCursor.trimStart().startsWith("/");
1533
+ }
1534
+ shouldChainSlashArgumentAutocompleteOnTabSelection() {
1535
+ if (this.autocompleteState !== "regular") {
1536
+ return false;
1537
+ }
1538
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1539
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol);
1540
+ return this.isInSlashCommandContext(textBeforeCursor) && !textBeforeCursor.trimStart().includes(" ");
1541
+ }
1542
+ isBareCompletedSlashCommandAtCursor() {
1543
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1544
+ if (this.state.cursorCol !== currentLine.length) {
1545
+ return false;
1546
+ }
1547
+ const textBeforeCursor = currentLine.slice(0, this.state.cursorCol).trimStart();
1548
+ return /^\/\S+ $/.test(textBeforeCursor);
1549
+ }
1550
+ // Autocomplete methods
1551
+ /**
1552
+ * Find the best autocomplete item index for the given prefix.
1553
+ * Returns -1 if no match is found.
1554
+ *
1555
+ * Match priority:
1556
+ * 1. Exact match (prefix === item.value) -> always selected
1557
+ * 2. Prefix match -> first item whose value starts with prefix
1558
+ * 3. No match -> -1 (keep default highlight)
1559
+ *
1560
+ * Matching is case-sensitive and checks item.value only.
1561
+ */
1562
+ getBestAutocompleteMatchIndex(items, prefix) {
1563
+ if (!prefix)
1564
+ return -1;
1565
+ let firstPrefixIndex = -1;
1566
+ for (let i = 0; i < items.length; i++) {
1567
+ const value = items[i].value;
1568
+ if (value === prefix) {
1569
+ return i; // Exact match always wins
1570
+ }
1571
+ if (firstPrefixIndex === -1 && value.startsWith(prefix)) {
1572
+ firstPrefixIndex = i;
1573
+ }
1574
+ }
1575
+ return firstPrefixIndex;
1576
+ }
1577
+ tryTriggerAutocomplete(explicitTab = false) {
1578
+ if (!this.autocompleteProvider)
1579
+ return;
1580
+ // Check if we should trigger file completion on Tab
1581
+ if (explicitTab) {
1582
+ const provider = this.autocompleteProvider;
1583
+ const shouldTrigger = !provider.shouldTriggerFileCompletion ||
1584
+ provider.shouldTriggerFileCompletion(this.state.lines, this.state.cursorLine, this.state.cursorCol);
1585
+ if (!shouldTrigger) {
1586
+ return;
1587
+ }
1588
+ }
1589
+ const suggestions = this.autocompleteProvider.getSuggestions(this.state.lines, this.state.cursorLine, this.state.cursorCol);
1590
+ if (suggestions && suggestions.items.length > 0) {
1591
+ this.autocompletePrefix = suggestions.prefix;
1592
+ this.autocompleteList = new SelectList(suggestions.items, this.autocompleteMaxVisible, this.theme.selectList);
1593
+ // If typed prefix exactly matches one of the suggestions, select that item
1594
+ const bestMatchIndex = this.getBestAutocompleteMatchIndex(suggestions.items, suggestions.prefix);
1595
+ if (bestMatchIndex >= 0) {
1596
+ this.autocompleteList.setSelectedIndex(bestMatchIndex);
1597
+ }
1598
+ this.autocompleteState = "regular";
1599
+ }
1600
+ else {
1601
+ this.cancelAutocomplete();
1602
+ }
1603
+ }
1604
+ handleTabCompletion() {
1605
+ if (!this.autocompleteProvider)
1606
+ return;
1607
+ const currentLine = this.state.lines[this.state.cursorLine] || "";
1608
+ const beforeCursor = currentLine.slice(0, this.state.cursorCol);
1609
+ // Check if we're in a slash command context
1610
+ if (this.isInSlashCommandContext(beforeCursor) && !beforeCursor.trimStart().includes(" ")) {
1611
+ this.handleSlashCommandCompletion();
1612
+ }
1613
+ else {
1614
+ this.forceFileAutocomplete(true);
1615
+ }
1616
+ }
1617
+ handleSlashCommandCompletion() {
1618
+ this.tryTriggerAutocomplete(true);
1619
+ }
1620
+ /*
1621
+ https://github.com/EsotericSoftware/spine-runtimes/actions/runs/19536643416/job/559322883
1622
+ 17 this job fails with https://github.com/EsotericSoftware/spine-runtimes/actions/runs/19
1623
+ 536643416/job/55932288317 havea look at .gi
1624
+ */
1625
+ forceFileAutocomplete(explicitTab = false) {
1626
+ if (!this.autocompleteProvider)
1627
+ return;
1628
+ // Check if provider supports force file suggestions via runtime check
1629
+ const provider = this.autocompleteProvider;
1630
+ if (typeof provider.getForceFileSuggestions !== "function") {
1631
+ this.tryTriggerAutocomplete(true);
1632
+ return;
1633
+ }
1634
+ const suggestions = provider.getForceFileSuggestions(this.state.lines, this.state.cursorLine, this.state.cursorCol);
1635
+ if (suggestions && suggestions.items.length > 0) {
1636
+ // If there's exactly one suggestion, apply it immediately
1637
+ if (explicitTab && suggestions.items.length === 1) {
1638
+ const item = suggestions.items[0];
1639
+ this.pushUndoSnapshot();
1640
+ this.lastAction = null;
1641
+ const result = this.autocompleteProvider.applyCompletion(this.state.lines, this.state.cursorLine, this.state.cursorCol, item, suggestions.prefix);
1642
+ this.state.lines = result.lines;
1643
+ this.state.cursorLine = result.cursorLine;
1644
+ this.setCursorCol(result.cursorCol);
1645
+ if (this.onChange)
1646
+ this.onChange(this.getText());
1647
+ return;
1648
+ }
1649
+ this.autocompletePrefix = suggestions.prefix;
1650
+ this.autocompleteList = new SelectList(suggestions.items, this.autocompleteMaxVisible, this.theme.selectList);
1651
+ // If typed prefix exactly matches one of the suggestions, select that item
1652
+ const bestMatchIndex = this.getBestAutocompleteMatchIndex(suggestions.items, suggestions.prefix);
1653
+ if (bestMatchIndex >= 0) {
1654
+ this.autocompleteList.setSelectedIndex(bestMatchIndex);
1655
+ }
1656
+ this.autocompleteState = "force";
1657
+ }
1658
+ else {
1659
+ this.cancelAutocomplete();
1660
+ }
1661
+ }
1662
+ cancelAutocomplete() {
1663
+ this.autocompleteState = null;
1664
+ this.autocompleteList = undefined;
1665
+ this.autocompletePrefix = "";
1666
+ }
1667
+ isShowingAutocomplete() {
1668
+ return this.autocompleteState !== null;
1669
+ }
1670
+ updateAutocomplete() {
1671
+ if (!this.autocompleteState || !this.autocompleteProvider)
1672
+ return;
1673
+ if (this.autocompleteState === "force") {
1674
+ this.forceFileAutocomplete();
1675
+ return;
1676
+ }
1677
+ const suggestions = this.autocompleteProvider.getSuggestions(this.state.lines, this.state.cursorLine, this.state.cursorCol);
1678
+ if (suggestions && suggestions.items.length > 0) {
1679
+ this.autocompletePrefix = suggestions.prefix;
1680
+ // Always create new SelectList to ensure update
1681
+ this.autocompleteList = new SelectList(suggestions.items, this.autocompleteMaxVisible, this.theme.selectList);
1682
+ // If typed prefix exactly matches one of the suggestions, select that item
1683
+ const bestMatchIndex = this.getBestAutocompleteMatchIndex(suggestions.items, suggestions.prefix);
1684
+ if (bestMatchIndex >= 0) {
1685
+ this.autocompleteList.setSelectedIndex(bestMatchIndex);
1686
+ }
1687
+ }
1688
+ else {
1689
+ this.cancelAutocomplete();
1690
+ }
1691
+ }
1692
+ }
1693
+ //# sourceMappingURL=editor.js.map