gsd-pi 2.34.0 → 2.35.0-dev.cd3b7ea

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 (418) hide show
  1. package/dist/resources/extensions/gsd/changelog.js +162 -0
  2. package/dist/resources/extensions/gsd/commands-bootstrap.js +1 -0
  3. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +5 -1
  4. package/dist/resources/extensions/gsd/commands.js +8 -1
  5. package/dist/resources/extensions/gsd/docs/preferences-reference.md +10 -0
  6. package/dist/resources/extensions/gsd/doctor-checks.js +113 -5
  7. package/dist/resources/extensions/gsd/doctor-proactive.js +22 -0
  8. package/dist/resources/extensions/gsd/doctor.js +36 -0
  9. package/dist/resources/extensions/gsd/guided-flow.js +4 -2
  10. package/dist/resources/extensions/gsd/preferences-validation.js +38 -0
  11. package/dist/resources/extensions/gsd/preferences.js +2 -0
  12. package/dist/resources/extensions/mcp-client/index.js +2 -1
  13. package/dist/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
  14. package/package.json +1 -1
  15. package/packages/native/dist/native.d.ts +0 -2
  16. package/packages/native/dist/native.js +0 -2
  17. package/packages/native/src/native.ts +0 -3
  18. package/packages/pi-agent-core/dist/agent-loop.d.ts +14 -0
  19. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  20. package/packages/pi-agent-core/dist/agent-loop.js +24 -27
  21. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  22. package/packages/pi-agent-core/dist/agent.d.ts +1 -0
  23. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  24. package/packages/pi-agent-core/dist/agent.js +11 -22
  25. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  26. package/packages/pi-agent-core/dist/proxy.d.ts +1 -25
  27. package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -1
  28. package/packages/pi-agent-core/dist/proxy.js +3 -9
  29. package/packages/pi-agent-core/dist/proxy.js.map +1 -1
  30. package/packages/pi-agent-core/src/agent-loop.ts +30 -27
  31. package/packages/pi-agent-core/src/agent.ts +12 -23
  32. package/packages/pi-agent-core/src/proxy.ts +3 -9
  33. package/packages/pi-ai/dist/api-registry.d.ts +0 -2
  34. package/packages/pi-ai/dist/api-registry.d.ts.map +1 -1
  35. package/packages/pi-ai/dist/api-registry.js +0 -10
  36. package/packages/pi-ai/dist/api-registry.js.map +1 -1
  37. package/packages/pi-ai/dist/providers/anthropic.d.ts +0 -8
  38. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  39. package/packages/pi-ai/dist/providers/anthropic.js +1 -1
  40. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  41. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  42. package/packages/pi-ai/dist/providers/azure-openai-responses.js +5 -41
  43. package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  44. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +0 -1
  45. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  46. package/packages/pi-ai/dist/providers/github-copilot-headers.js +1 -1
  47. package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  48. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +1 -43
  49. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  50. package/packages/pi-ai/dist/providers/google-gemini-cli.js +2 -2
  51. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  52. package/packages/pi-ai/dist/providers/google-shared.d.ts +0 -4
  53. package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  54. package/packages/pi-ai/dist/providers/google-shared.js +1 -1
  55. package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
  56. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  57. package/packages/pi-ai/dist/providers/openai-completions.js +10 -73
  58. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  59. package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  60. package/packages/pi-ai/dist/providers/openai-responses.js +8 -79
  61. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
  62. package/packages/pi-ai/dist/providers/openai-shared.d.ts +65 -0
  63. package/packages/pi-ai/dist/providers/openai-shared.d.ts.map +1 -0
  64. package/packages/pi-ai/dist/providers/openai-shared.js +146 -0
  65. package/packages/pi-ai/dist/providers/openai-shared.js.map +1 -0
  66. package/packages/pi-ai/dist/providers/register-builtins.d.ts +0 -1
  67. package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  68. package/packages/pi-ai/dist/providers/register-builtins.js +1 -1
  69. package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
  70. package/packages/pi-ai/dist/utils/event-stream.d.ts +0 -2
  71. package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  72. package/packages/pi-ai/dist/utils/event-stream.js +0 -4
  73. package/packages/pi-ai/dist/utils/event-stream.js.map +1 -1
  74. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
  75. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +7 -135
  76. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
  77. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
  78. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +7 -135
  79. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
  80. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts +46 -0
  81. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts.map +1 -0
  82. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js +160 -0
  83. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js.map +1 -0
  84. package/packages/pi-ai/dist/utils/overflow.d.ts +0 -4
  85. package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  86. package/packages/pi-ai/dist/utils/overflow.js +0 -6
  87. package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
  88. package/packages/pi-ai/dist/utils/validation.d.ts +0 -8
  89. package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -1
  90. package/packages/pi-ai/dist/utils/validation.js +0 -14
  91. package/packages/pi-ai/dist/utils/validation.js.map +1 -1
  92. package/packages/pi-ai/src/api-registry.ts +0 -12
  93. package/packages/pi-ai/src/providers/anthropic.ts +1 -1
  94. package/packages/pi-ai/src/providers/azure-openai-responses.ts +11 -45
  95. package/packages/pi-ai/src/providers/github-copilot-headers.ts +1 -1
  96. package/packages/pi-ai/src/providers/google-gemini-cli.ts +2 -2
  97. package/packages/pi-ai/src/providers/google-shared.ts +1 -1
  98. package/packages/pi-ai/src/providers/openai-completions.ts +16 -86
  99. package/packages/pi-ai/src/providers/openai-responses.ts +15 -95
  100. package/packages/pi-ai/src/providers/openai-shared.ts +193 -0
  101. package/packages/pi-ai/src/providers/register-builtins.ts +1 -1
  102. package/packages/pi-ai/src/utils/event-stream.ts +0 -5
  103. package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +14 -162
  104. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +13 -161
  105. package/packages/pi-ai/src/utils/oauth/google-oauth-utils.ts +201 -0
  106. package/packages/pi-ai/src/utils/overflow.ts +1 -8
  107. package/packages/pi-ai/src/utils/validation.ts +0 -15
  108. package/packages/pi-coding-agent/dist/config.d.ts +0 -9
  109. package/packages/pi-coding-agent/dist/config.d.ts.map +1 -1
  110. package/packages/pi-coding-agent/dist/config.js +4 -8
  111. package/packages/pi-coding-agent/dist/config.js.map +1 -1
  112. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +16 -63
  113. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  114. package/packages/pi-coding-agent/dist/core/agent-session.js +104 -641
  115. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  116. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +0 -1
  117. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  118. package/packages/pi-coding-agent/dist/core/auth-storage.js +4 -35
  119. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  120. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  121. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +5 -43
  122. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
  123. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  124. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +11 -69
  125. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  126. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +40 -0
  127. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
  128. package/packages/pi-coding-agent/dist/core/compaction/utils.js +78 -0
  129. package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
  130. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts +77 -0
  131. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -0
  132. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +331 -0
  133. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -0
  134. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +0 -4
  135. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  136. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +1 -1
  137. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -1
  138. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +2 -2
  139. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  140. package/packages/pi-coding-agent/dist/core/extensions/index.js +1 -1
  141. package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  142. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +15 -5
  143. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  144. package/packages/pi-coding-agent/dist/core/extensions/runner.js +129 -256
  145. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  146. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +49 -42
  147. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  148. package/packages/pi-coding-agent/dist/core/extensions/types.js +2 -21
  149. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  150. package/packages/pi-coding-agent/dist/core/keybindings.d.ts +0 -8
  151. package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
  152. package/packages/pi-coding-agent/dist/core/keybindings.js +2 -2
  153. package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
  154. package/packages/pi-coding-agent/dist/core/lock-utils.d.ts +39 -0
  155. package/packages/pi-coding-agent/dist/core/lock-utils.d.ts.map +1 -0
  156. package/packages/pi-coding-agent/dist/core/lock-utils.js +89 -0
  157. package/packages/pi-coding-agent/dist/core/lock-utils.js.map +1 -0
  158. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts +0 -17
  159. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
  160. package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -62
  161. package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
  162. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +1 -1
  163. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
  164. package/packages/pi-coding-agent/dist/core/lsp/config.js +2 -6
  165. package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
  166. package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts +0 -5
  167. package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts.map +1 -1
  168. package/packages/pi-coding-agent/dist/core/lsp/edits.js +1 -1
  169. package/packages/pi-coding-agent/dist/core/lsp/edits.js.map +1 -1
  170. package/packages/pi-coding-agent/dist/core/lsp/index.d.ts.map +1 -1
  171. package/packages/pi-coding-agent/dist/core/lsp/index.js +52 -107
  172. package/packages/pi-coding-agent/dist/core/lsp/index.js.map +1 -1
  173. package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts +0 -1
  174. package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts.map +1 -1
  175. package/packages/pi-coding-agent/dist/core/lsp/lspmux.js +3 -22
  176. package/packages/pi-coding-agent/dist/core/lsp/lspmux.js.map +1 -1
  177. package/packages/pi-coding-agent/dist/core/lsp/types.d.ts +0 -1
  178. package/packages/pi-coding-agent/dist/core/lsp/types.d.ts.map +1 -1
  179. package/packages/pi-coding-agent/dist/core/lsp/types.js +0 -28
  180. package/packages/pi-coding-agent/dist/core/lsp/types.js.map +1 -1
  181. package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts +1 -6
  182. package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts.map +1 -1
  183. package/packages/pi-coding-agent/dist/core/lsp/utils.js +1 -28
  184. package/packages/pi-coding-agent/dist/core/lsp/utils.js.map +1 -1
  185. package/packages/pi-coding-agent/dist/core/messages.d.ts +0 -8
  186. package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
  187. package/packages/pi-coding-agent/dist/core/messages.js +5 -5
  188. package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
  189. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +0 -3
  190. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  191. package/packages/pi-coding-agent/dist/core/model-registry.js +1 -3
  192. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  193. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +1 -26
  194. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  195. package/packages/pi-coding-agent/dist/core/model-resolver.js +3 -59
  196. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  197. package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  198. package/packages/pi-coding-agent/dist/core/package-manager.js +2 -4
  199. package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  200. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +0 -17
  201. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -1
  202. package/packages/pi-coding-agent/dist/core/prompt-templates.js +2 -2
  203. package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -1
  204. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +2 -4
  205. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  206. package/packages/pi-coding-agent/dist/core/resource-loader.js +33 -58
  207. package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  208. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +87 -0
  209. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -0
  210. package/packages/pi-coding-agent/dist/core/retry-handler.js +295 -0
  211. package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -0
  212. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +0 -5
  213. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  214. package/packages/pi-coding-agent/dist/core/session-manager.js +5 -32
  215. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  216. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +8 -12
  217. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  218. package/packages/pi-coding-agent/dist/core/settings-manager.js +78 -168
  219. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  220. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  221. package/packages/pi-coding-agent/dist/core/skills.js +1 -3
  222. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
  223. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  224. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  225. package/packages/pi-coding-agent/dist/index.js +1 -1
  226. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  227. package/packages/pi-coding-agent/dist/migrations.d.ts +0 -16
  228. package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -1
  229. package/packages/pi-coding-agent/dist/migrations.js +2 -2
  230. package/packages/pi-coding-agent/dist/migrations.js.map +1 -1
  231. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +0 -2
  232. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  233. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +2 -2
  234. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  235. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +1 -1
  236. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  237. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +9 -26
  238. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -1
  239. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  240. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -13
  241. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  242. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts +44 -0
  243. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts.map +1 -0
  244. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js +61 -0
  245. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js.map +1 -0
  246. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  247. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +6 -9
  248. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -1
  249. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +1 -24
  250. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  251. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +50 -512
  252. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  253. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts +71 -0
  254. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -0
  255. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +514 -0
  256. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -0
  257. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +65 -4
  258. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  259. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +6 -23
  260. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  261. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts +12 -0
  262. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -0
  263. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +175 -0
  264. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -0
  265. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts +6 -0
  266. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts.map +1 -0
  267. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js +15 -0
  268. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js.map +1 -0
  269. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
  270. package/packages/pi-coding-agent/dist/modes/print-mode.js +2 -30
  271. package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
  272. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  273. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +2 -28
  274. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
  275. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts +19 -0
  276. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts.map +1 -0
  277. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js +45 -0
  278. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js.map +1 -0
  279. package/packages/pi-coding-agent/dist/utils/changelog.d.ts +0 -4
  280. package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
  281. package/packages/pi-coding-agent/dist/utils/changelog.js +1 -1
  282. package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -1
  283. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +0 -1
  284. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -1
  285. package/packages/pi-coding-agent/dist/utils/clipboard-image.js +1 -1
  286. package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -1
  287. package/packages/pi-coding-agent/dist/utils/error.d.ts +5 -0
  288. package/packages/pi-coding-agent/dist/utils/error.d.ts.map +1 -0
  289. package/packages/pi-coding-agent/dist/utils/error.js +7 -0
  290. package/packages/pi-coding-agent/dist/utils/error.js.map +1 -0
  291. package/packages/pi-coding-agent/dist/utils/photon.d.ts +0 -19
  292. package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -1
  293. package/packages/pi-coding-agent/dist/utils/photon.js +1 -120
  294. package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -1
  295. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +0 -1
  296. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -1
  297. package/packages/pi-coding-agent/dist/utils/tools-manager.js +1 -1
  298. package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -1
  299. package/packages/pi-coding-agent/package.json +1 -1
  300. package/packages/pi-coding-agent/src/config.ts +5 -10
  301. package/packages/pi-coding-agent/src/core/agent-session.ts +117 -745
  302. package/packages/pi-coding-agent/src/core/auth-storage.ts +4 -38
  303. package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +7 -53
  304. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +14 -74
  305. package/packages/pi-coding-agent/src/core/compaction/utils.ts +100 -0
  306. package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +424 -0
  307. package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +1 -1
  308. package/packages/pi-coding-agent/src/core/extensions/index.ts +1 -21
  309. package/packages/pi-coding-agent/src/core/extensions/runner.ts +119 -256
  310. package/packages/pi-coding-agent/src/core/extensions/types.ts +50 -69
  311. package/packages/pi-coding-agent/src/core/keybindings.ts +2 -2
  312. package/packages/pi-coding-agent/src/core/lock-utils.ts +113 -0
  313. package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -73
  314. package/packages/pi-coding-agent/src/core/lsp/config.ts +2 -10
  315. package/packages/pi-coding-agent/src/core/lsp/edits.ts +1 -1
  316. package/packages/pi-coding-agent/src/core/lsp/index.ts +83 -152
  317. package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +3 -23
  318. package/packages/pi-coding-agent/src/core/lsp/types.ts +0 -29
  319. package/packages/pi-coding-agent/src/core/lsp/utils.ts +1 -33
  320. package/packages/pi-coding-agent/src/core/messages.ts +5 -5
  321. package/packages/pi-coding-agent/src/core/model-registry.ts +0 -2
  322. package/packages/pi-coding-agent/src/core/model-resolver.ts +3 -77
  323. package/packages/pi-coding-agent/src/core/package-manager.ts +1 -4
  324. package/packages/pi-coding-agent/src/core/prompt-templates.ts +2 -2
  325. package/packages/pi-coding-agent/src/core/resource-loader.ts +43 -67
  326. package/packages/pi-coding-agent/src/core/retry-handler.ts +359 -0
  327. package/packages/pi-coding-agent/src/core/session-manager.ts +5 -34
  328. package/packages/pi-coding-agent/src/core/settings-manager.ts +87 -166
  329. package/packages/pi-coding-agent/src/core/skills.ts +1 -4
  330. package/packages/pi-coding-agent/src/index.ts +1 -7
  331. package/packages/pi-coding-agent/src/migrations.ts +2 -2
  332. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +2 -2
  333. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +17 -29
  334. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1 -13
  335. package/packages/pi-coding-agent/src/modes/interactive/components/tree-render-utils.ts +81 -0
  336. package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +14 -19
  337. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +50 -561
  338. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +653 -0
  339. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +7 -26
  340. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +196 -0
  341. package/packages/pi-coding-agent/src/modes/interactive/utils/shorten-path.ts +14 -0
  342. package/packages/pi-coding-agent/src/modes/print-mode.ts +2 -30
  343. package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +2 -28
  344. package/packages/pi-coding-agent/src/modes/shared/command-context-actions.ts +53 -0
  345. package/packages/pi-coding-agent/src/utils/changelog.ts +1 -1
  346. package/packages/pi-coding-agent/src/utils/clipboard-image.ts +1 -1
  347. package/packages/pi-coding-agent/src/utils/error.ts +6 -0
  348. package/packages/pi-coding-agent/src/utils/photon.ts +0 -137
  349. package/packages/pi-coding-agent/src/utils/tools-manager.ts +1 -1
  350. package/packages/pi-tui/dist/components/editor.d.ts +0 -10
  351. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
  352. package/packages/pi-tui/dist/components/editor.js +1 -1
  353. package/packages/pi-tui/dist/components/editor.js.map +1 -1
  354. package/packages/pi-tui/dist/components/markdown.d.ts +5 -0
  355. package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -1
  356. package/packages/pi-tui/dist/components/markdown.js +25 -31
  357. package/packages/pi-tui/dist/components/markdown.js.map +1 -1
  358. package/packages/pi-tui/dist/keys.d.ts +0 -4
  359. package/packages/pi-tui/dist/keys.d.ts.map +1 -1
  360. package/packages/pi-tui/dist/keys.js +94 -162
  361. package/packages/pi-tui/dist/keys.js.map +1 -1
  362. package/packages/pi-tui/dist/overlay-layout.d.ts +55 -0
  363. package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -0
  364. package/packages/pi-tui/dist/overlay-layout.js +288 -0
  365. package/packages/pi-tui/dist/overlay-layout.js.map +1 -0
  366. package/packages/pi-tui/dist/tui.d.ts +0 -22
  367. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  368. package/packages/pi-tui/dist/tui.js +6 -272
  369. package/packages/pi-tui/dist/tui.js.map +1 -1
  370. package/packages/pi-tui/dist/utils.d.ts +0 -7
  371. package/packages/pi-tui/dist/utils.d.ts.map +1 -1
  372. package/packages/pi-tui/dist/utils.js +0 -44
  373. package/packages/pi-tui/dist/utils.js.map +1 -1
  374. package/packages/pi-tui/src/components/editor.ts +1 -1
  375. package/packages/pi-tui/src/components/markdown.ts +25 -29
  376. package/packages/pi-tui/src/keys.ts +94 -173
  377. package/packages/pi-tui/src/overlay-layout.ts +372 -0
  378. package/packages/pi-tui/src/tui.ts +11 -312
  379. package/packages/pi-tui/src/utils.ts +0 -43
  380. package/pkg/dist/core/export-html/ansi-to-html.d.ts +0 -4
  381. package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  382. package/pkg/dist/core/export-html/ansi-to-html.js +1 -1
  383. package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -1
  384. package/pkg/dist/modes/interactive/theme/theme.d.ts +65 -4
  385. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  386. package/pkg/dist/modes/interactive/theme/theme.js +6 -23
  387. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  388. package/pkg/dist/modes/interactive/theme/themes.d.ts +12 -0
  389. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -0
  390. package/pkg/dist/modes/interactive/theme/themes.js +175 -0
  391. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -0
  392. package/pkg/package.json +1 -1
  393. package/src/resources/extensions/gsd/changelog.ts +213 -0
  394. package/src/resources/extensions/gsd/commands-bootstrap.ts +1 -0
  395. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +5 -1
  396. package/src/resources/extensions/gsd/commands.ts +9 -1
  397. package/src/resources/extensions/gsd/docs/preferences-reference.md +10 -0
  398. package/src/resources/extensions/gsd/doctor-checks.ts +107 -5
  399. package/src/resources/extensions/gsd/doctor-proactive.ts +24 -0
  400. package/src/resources/extensions/gsd/doctor-types.ts +9 -1
  401. package/src/resources/extensions/gsd/doctor.ts +35 -0
  402. package/src/resources/extensions/gsd/guided-flow.ts +4 -2
  403. package/src/resources/extensions/gsd/preferences-validation.ts +38 -0
  404. package/src/resources/extensions/gsd/preferences.ts +2 -0
  405. package/src/resources/extensions/gsd/tests/doctor-git.test.ts +98 -2
  406. package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +59 -3
  407. package/src/resources/extensions/gsd/tests/preferences.test.ts +28 -0
  408. package/src/resources/extensions/mcp-client/index.ts +2 -1
  409. package/src/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
  410. package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +0 -85
  411. package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +0 -84
  412. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -335
  413. package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +0 -85
  414. package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +0 -84
  415. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
  416. package/pkg/dist/modes/interactive/theme/dark.json +0 -85
  417. package/pkg/dist/modes/interactive/theme/light.json +0 -84
  418. package/pkg/dist/modes/interactive/theme/theme-schema.json +0 -335
@@ -10,13 +10,6 @@ export declare function isWhitespaceChar(char: string): boolean;
10
10
  * Check if a character is punctuation.
11
11
  */
12
12
  export declare function isPunctuationChar(char: string): boolean;
13
- /**
14
- * Extract ANSI escape sequences from a string at the given position.
15
- */
16
- export declare function extractAnsiCode(str: string, pos: number): {
17
- code: string;
18
- length: number;
19
- } | null;
20
13
  /**
21
14
  * Calculate the visible width of a string in terminal columns.
22
15
  * Delegates to the native Rust implementation.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAAC,SAAS,CAE7C;AAID;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAsCjG;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtE;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAc,EACxB,GAAG,GAAE,OAAe,GAClB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,MAAM,CAEpG;AAED,kFAAkF;AAClF,w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EACxB,GAAG,GAAE,OAAe,GAClB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,MAAM,CAEpG;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,UAAQ,GACZ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAEjC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,UAAQ,GACjB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAE5E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAOzG"}
@@ -20,50 +20,6 @@ export function isWhitespaceChar(char) {
20
20
  export function isPunctuationChar(char) {
21
21
  return PUNCTUATION_REGEX.test(char);
22
22
  }
23
- /**
24
- * Extract ANSI escape sequences from a string at the given position.
25
- */
26
- export function extractAnsiCode(str, pos) {
27
- if (pos >= str.length || str[pos] !== "\x1b")
28
- return null;
29
- const next = str[pos + 1];
30
- // CSI sequence: ESC [ ... m/G/K/H/J
31
- if (next === "[") {
32
- let j = pos + 2;
33
- while (j < str.length && !/[mGKHJ]/.test(str[j]))
34
- j++;
35
- if (j < str.length)
36
- return { code: str.substring(pos, j + 1), length: j + 1 - pos };
37
- return null;
38
- }
39
- // OSC sequence: ESC ] ... BEL or ESC ] ... ST (ESC \)
40
- // Used for hyperlinks (OSC 8), window titles, etc.
41
- if (next === "]") {
42
- let j = pos + 2;
43
- while (j < str.length) {
44
- if (str[j] === "\x07")
45
- return { code: str.substring(pos, j + 1), length: j + 1 - pos };
46
- if (str[j] === "\x1b" && str[j + 1] === "\\")
47
- return { code: str.substring(pos, j + 2), length: j + 2 - pos };
48
- j++;
49
- }
50
- return null;
51
- }
52
- // APC sequence: ESC _ ... BEL or ESC _ ... ST (ESC \)
53
- // Used for cursor marker and application-specific commands
54
- if (next === "_") {
55
- let j = pos + 2;
56
- while (j < str.length) {
57
- if (str[j] === "\x07")
58
- return { code: str.substring(pos, j + 1), length: j + 1 - pos };
59
- if (str[j] === "\x1b" && str[j + 1] === "\\")
60
- return { code: str.substring(pos, j + 2), length: j + 2 - pos };
61
- j++;
62
- }
63
- return null;
64
- }
65
- return null;
66
- }
67
23
  // ---------------------------------------------------------------------------
68
24
  // Native text module wrappers
69
25
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,IAAI,kBAAkB,EAClC,gBAAgB,IAAI,sBAAsB,EAC1C,eAAe,IAAI,qBAAqB,EACxC,cAAc,IAAI,oBAAoB,EACtC,eAAe,IAAI,qBAAqB,EACxC,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAE1B,uCAAuC;AACvC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,UAAU,YAAY;IAC3B,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAA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EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAClF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAa,EAAE,IAA8B;IAChG,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAE1C,MAAM,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC;IACnC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import {\n\tvisibleWidth as nativeVisibleWidth,\n\twrapTextWithAnsi as nativeWrapTextWithAnsi,\n\ttruncateToWidth as nativeTruncateToWidth,\n\tsliceWithWidth as nativeSliceWithWidth,\n\textractSegments as nativeExtractSegments,\n\tEllipsisKind,\n} from \"@gsd/native/text\";\n\n// Grapheme segmenter (shared instance)\nconst segmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/**\n * Get the shared grapheme segmenter instance.\n */\nexport function getSegmenter(): Intl.Segmenter {\n\treturn segmenter;\n}\n\nconst PUNCTUATION_REGEX = /[(){}[\\]<>.,;:'\"!?+\\-=*/\\\\|&%^$#@~`]/;\n\n/**\n * Check if a character is whitespace.\n */\nexport function isWhitespaceChar(char: string): boolean {\n\treturn /\\s/.test(char);\n}\n\n/**\n * Check if a character is punctuation.\n */\nexport function isPunctuationChar(char: string): boolean {\n\treturn PUNCTUATION_REGEX.test(char);\n}\n\n/**\n * Extract ANSI escape sequences from a string at the given position.\n */\nexport function extractAnsiCode(str: string, pos: number): { code: string; length: number } | null {\n\tif (pos >= str.length || str[pos] !== \"\\x1b\") return null;\n\n\tconst next = str[pos + 1];\n\n\t// CSI sequence: ESC [ ... m/G/K/H/J\n\tif (next === \"[\") {\n\t\tlet j = pos + 2;\n\t\twhile (j < str.length && !/[mGKHJ]/.test(str[j]!)) j++;\n\t\tif (j < str.length) return { code: str.substring(pos, j + 1), length: j + 1 - pos };\n\t\treturn null;\n\t}\n\n\t// OSC sequence: ESC ] ... BEL or ESC ] ... ST (ESC \\)\n\t// Used for hyperlinks (OSC 8), window titles, etc.\n\tif (next === \"]\") {\n\t\tlet j = pos + 2;\n\t\twhile (j < str.length) {\n\t\t\tif (str[j] === \"\\x07\") return { code: str.substring(pos, j + 1), length: j + 1 - pos };\n\t\t\tif (str[j] === \"\\x1b\" && str[j + 1] === \"\\\\\") return { code: str.substring(pos, j + 2), length: j + 2 - pos };\n\t\t\tj++;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// APC sequence: ESC _ ... BEL or ESC _ ... ST (ESC \\)\n\t// Used for cursor marker and application-specific commands\n\tif (next === \"_\") {\n\t\tlet j = pos + 2;\n\t\twhile (j < str.length) {\n\t\t\tif (str[j] === \"\\x07\") return { code: str.substring(pos, j + 1), length: j + 1 - pos };\n\t\t\tif (str[j] === \"\\x1b\" && str[j + 1] === \"\\\\\") return { code: str.substring(pos, j + 2), length: j + 2 - pos };\n\t\t\tj++;\n\t\t}\n\t\treturn null;\n\t}\n\n\treturn null;\n}\n\n// ---------------------------------------------------------------------------\n// Native text module wrappers\n// ---------------------------------------------------------------------------\n\n/**\n * Calculate the visible width of a string in terminal columns.\n * Delegates to the native Rust implementation.\n */\nexport function visibleWidth(str: string): number {\n\treturn nativeVisibleWidth(str);\n}\n\n/**\n * Wrap text with ANSI codes preserved.\n * Delegates to the native Rust implementation.\n *\n * @param text - Text to wrap (may contain ANSI codes and newlines)\n * @param width - Maximum visible width per line\n * @returns Array of wrapped lines (NOT padded to width)\n */\nexport function wrapTextWithAnsi(text: string, width: number): string[] {\n\treturn nativeWrapTextWithAnsi(text, width);\n}\n\n/**\n * Map an ellipsis string to the native EllipsisKind enum value.\n */\nfunction ellipsisStringToKind(ellipsis: string): number {\n\tif (ellipsis === \"\\u2026\") return EllipsisKind.Unicode;\n\tif (ellipsis === \"...\" || ellipsis === undefined) return EllipsisKind.Ascii;\n\tif (ellipsis === \"\") return EllipsisKind.None;\n\t// Default: \"...\" maps to Ascii\n\treturn EllipsisKind.Ascii;\n}\n\n/**\n * Truncate text to fit within a maximum visible width, adding ellipsis if needed.\n * Optionally pad with spaces to reach exactly maxWidth.\n * Delegates to the native Rust implementation.\n *\n * @param text - Text to truncate (may contain ANSI codes)\n * @param maxWidth - Maximum visible width\n * @param ellipsis - Ellipsis string to append when truncating (default: \"...\")\n * @param pad - If true, pad result with spaces to exactly maxWidth (default: false)\n * @returns Truncated text, optionally padded to exactly maxWidth\n */\nexport function truncateToWidth(\n\ttext: string,\n\tmaxWidth: number,\n\tellipsis: string = \"...\",\n\tpad: boolean = false,\n): string {\n\treturn nativeTruncateToWidth(text, maxWidth, ellipsisStringToKind(ellipsis), pad);\n}\n\n/**\n * Extract a range of visible columns from a line. Handles ANSI codes and wide chars.\n * @param strict - If true, exclude wide chars at boundary that would extend past the range\n */\nexport function sliceByColumn(line: string, startCol: number, length: number, strict = false): string {\n\treturn sliceWithWidth(line, startCol, length, strict).text;\n}\n\n/** Like sliceByColumn but also returns the actual visible width of the result. */\nexport function sliceWithWidth(\n\tline: string,\n\tstartCol: number,\n\tlength: number,\n\tstrict = false,\n): { text: string; width: number } {\n\treturn nativeSliceWithWidth(line, startCol, length, strict);\n}\n\n/**\n * Extract \"before\" and \"after\" segments from a line in a single pass.\n * Delegates to the native Rust implementation.\n */\nexport function extractSegments(\n\tline: string,\n\tbeforeEnd: number,\n\tafterStart: number,\n\tafterLen: number,\n\tstrictAfter = false,\n): { before: string; beforeWidth: number; after: string; afterWidth: number } {\n\treturn nativeExtractSegments(line, beforeEnd, afterStart, afterLen, strictAfter);\n}\n\n/**\n * Apply background color to a line, padding to full width.\n *\n * @param line - Line of text (may contain ANSI codes)\n * @param width - Total width to pad to\n * @param bgFn - Background color function\n * @returns Line with background applied and padded to width\n */\nexport function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string {\n\tconst visibleLen = visibleWidth(line);\n\tconst paddingNeeded = Math.max(0, width - visibleLen);\n\tconst padding = \" \".repeat(paddingNeeded);\n\n\tconst withPadding = line + padding;\n\treturn bgFn(withPadding);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,IAAI,kBAAkB,EAClC,gBAAgB,IAAI,sBAAsB,EAC1C,eAAe,IAAI,qBAAqB,EACxC,cAAc,IAAI,oBAAoB,EACtC,eAAe,IAAI,qBAAqB,EACxC,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAE1B,uCAAuC;AACvC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,UAAU,YAAY;IAC3B,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC7C,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACvC,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAa;IAC3D,OAAO,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;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Y,EAAE,KAAa,EAAE,IAA8B;IAChG,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAE1C,MAAM,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC;IACnC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import {\n\tvisibleWidth as nativeVisibleWidth,\n\twrapTextWithAnsi as nativeWrapTextWithAnsi,\n\ttruncateToWidth as nativeTruncateToWidth,\n\tsliceWithWidth as nativeSliceWithWidth,\n\textractSegments as nativeExtractSegments,\n\tEllipsisKind,\n} from \"@gsd/native/text\";\n\n// Grapheme segmenter (shared instance)\nconst segmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/**\n * Get the shared grapheme segmenter instance.\n */\nexport function getSegmenter(): Intl.Segmenter {\n\treturn segmenter;\n}\n\nconst PUNCTUATION_REGEX = /[(){}[\\]<>.,;:'\"!?+\\-=*/\\\\|&%^$#@~`]/;\n\n/**\n * Check if a character is whitespace.\n */\nexport function isWhitespaceChar(char: string): boolean {\n\treturn /\\s/.test(char);\n}\n\n/**\n * Check if a character is punctuation.\n */\nexport function isPunctuationChar(char: string): boolean {\n\treturn PUNCTUATION_REGEX.test(char);\n}\n\n// ---------------------------------------------------------------------------\n// Native text module wrappers\n// ---------------------------------------------------------------------------\n\n/**\n * Calculate the visible width of a string in terminal columns.\n * Delegates to the native Rust implementation.\n */\nexport function visibleWidth(str: string): number {\n\treturn nativeVisibleWidth(str);\n}\n\n/**\n * Wrap text with ANSI codes preserved.\n * Delegates to the native Rust implementation.\n *\n * @param text - Text to wrap (may contain ANSI codes and newlines)\n * @param width - Maximum visible width per line\n * @returns Array of wrapped lines (NOT padded to width)\n */\nexport function wrapTextWithAnsi(text: string, width: number): string[] {\n\treturn nativeWrapTextWithAnsi(text, width);\n}\n\n/**\n * Map an ellipsis string to the native EllipsisKind enum value.\n */\nfunction ellipsisStringToKind(ellipsis: string): number {\n\tif (ellipsis === \"\\u2026\") return EllipsisKind.Unicode;\n\tif (ellipsis === \"...\" || ellipsis === undefined) return EllipsisKind.Ascii;\n\tif (ellipsis === \"\") return EllipsisKind.None;\n\t// Default: \"...\" maps to Ascii\n\treturn EllipsisKind.Ascii;\n}\n\n/**\n * Truncate text to fit within a maximum visible width, adding ellipsis if needed.\n * Optionally pad with spaces to reach exactly maxWidth.\n * Delegates to the native Rust implementation.\n *\n * @param text - Text to truncate (may contain ANSI codes)\n * @param maxWidth - Maximum visible width\n * @param ellipsis - Ellipsis string to append when truncating (default: \"...\")\n * @param pad - If true, pad result with spaces to exactly maxWidth (default: false)\n * @returns Truncated text, optionally padded to exactly maxWidth\n */\nexport function truncateToWidth(\n\ttext: string,\n\tmaxWidth: number,\n\tellipsis: string = \"...\",\n\tpad: boolean = false,\n): string {\n\treturn nativeTruncateToWidth(text, maxWidth, ellipsisStringToKind(ellipsis), pad);\n}\n\n/**\n * Extract a range of visible columns from a line. Handles ANSI codes and wide chars.\n * @param strict - If true, exclude wide chars at boundary that would extend past the range\n */\nexport function sliceByColumn(line: string, startCol: number, length: number, strict = false): string {\n\treturn sliceWithWidth(line, startCol, length, strict).text;\n}\n\n/** Like sliceByColumn but also returns the actual visible width of the result. */\nexport function sliceWithWidth(\n\tline: string,\n\tstartCol: number,\n\tlength: number,\n\tstrict = false,\n): { text: string; width: number } {\n\treturn nativeSliceWithWidth(line, startCol, length, strict);\n}\n\n/**\n * Extract \"before\" and \"after\" segments from a line in a single pass.\n * Delegates to the native Rust implementation.\n */\nexport function extractSegments(\n\tline: string,\n\tbeforeEnd: number,\n\tafterStart: number,\n\tafterLen: number,\n\tstrictAfter = false,\n): { before: string; beforeWidth: number; after: string; afterWidth: number } {\n\treturn nativeExtractSegments(line, beforeEnd, afterStart, afterLen, strictAfter);\n}\n\n/**\n * Apply background color to a line, padding to full width.\n *\n * @param line - Line of text (may contain ANSI codes)\n * @param width - Total width to pad to\n * @param bgFn - Background color function\n * @returns Line with background applied and padded to width\n */\nexport function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string {\n\tconst visibleLen = visibleWidth(line);\n\tconst paddingNeeded = Math.max(0, width - visibleLen);\n\tconst padding = \" \".repeat(paddingNeeded);\n\n\tconst withPadding = line + padding;\n\treturn bgFn(withPadding);\n}\n"]}
@@ -28,7 +28,7 @@ export interface TextChunk {
28
28
  * @param maxWidth - Maximum visible width per chunk
29
29
  * @returns Array of chunks with text and position information
30
30
  */
31
- export function wordWrapLine(line: string, maxWidth: number): TextChunk[] {
31
+ function wordWrapLine(line: string, maxWidth: number): TextChunk[] {
32
32
  if (!line || maxWidth <= 0) {
33
33
  return [{ text: "", startIndex: 0, endIndex: 0 }];
34
34
  }
@@ -308,21 +308,7 @@ export class Markdown implements Component {
308
308
  }
309
309
 
310
310
  case "code": {
311
- const indent = this.theme.codeBlockIndent ?? " ";
312
- lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
313
- if (this.theme.highlightCode) {
314
- const highlightedLines = this.theme.highlightCode(token.text, token.lang);
315
- for (const hlLine of highlightedLines) {
316
- lines.push(`${indent}${hlLine}`);
317
- }
318
- } else {
319
- // Split code by newlines and style each line
320
- const codeLines = token.text.split("\n");
321
- for (const codeLine of codeLines) {
322
- lines.push(`${indent}${this.theme.codeBlock(codeLine)}`);
323
- }
324
- }
325
- lines.push(this.theme.codeBlockBorder("```"));
311
+ lines.push(...this.renderCodeBlock(token.text, token.lang));
326
312
  if (nextTokenType !== "space") {
327
313
  lines.push(""); // Add spacing after code blocks (unless space token follows)
328
314
  }
@@ -589,20 +575,7 @@ export class Markdown implements Component {
589
575
  lines.push(text);
590
576
  } else if (token.type === "code") {
591
577
  // Code block in list item
592
- const indent = this.theme.codeBlockIndent ?? " ";
593
- lines.push(this.theme.codeBlockBorder(`\`\`\`${token.lang || ""}`));
594
- if (this.theme.highlightCode) {
595
- const highlightedLines = this.theme.highlightCode(token.text, token.lang);
596
- for (const hlLine of highlightedLines) {
597
- lines.push(`${indent}${hlLine}`);
598
- }
599
- } else {
600
- const codeLines = token.text.split("\n");
601
- for (const codeLine of codeLines) {
602
- lines.push(`${indent}${this.theme.codeBlock(codeLine)}`);
603
- }
604
- }
605
- lines.push(this.theme.codeBlockBorder("```"));
578
+ lines.push(...this.renderCodeBlock(token.text, token.lang));
606
579
  } else {
607
580
  // Other token types - try to render as inline
608
581
  const text = this.renderInlineTokens([token], styleContext);
@@ -615,6 +588,29 @@ export class Markdown implements Component {
615
588
  return lines;
616
589
  }
617
590
 
591
+ /**
592
+ * Render a fenced code block with syntax highlighting support.
593
+ * Used by both renderToken (top-level code blocks) and renderListItem (code blocks inside lists).
594
+ */
595
+ private renderCodeBlock(code: string, lang?: string): string[] {
596
+ const lines: string[] = [];
597
+ const indent = this.theme.codeBlockIndent ?? " ";
598
+ lines.push(this.theme.codeBlockBorder(`\`\`\`${lang || ""}`));
599
+ if (this.theme.highlightCode) {
600
+ const highlightedLines = this.theme.highlightCode(code, lang);
601
+ for (const hlLine of highlightedLines) {
602
+ lines.push(`${indent}${hlLine}`);
603
+ }
604
+ } else {
605
+ const codeLines = code.split("\n");
606
+ for (const codeLine of codeLines) {
607
+ lines.push(`${indent}${this.theme.codeBlock(codeLine)}`);
608
+ }
609
+ }
610
+ lines.push(this.theme.codeBlockBorder("```"));
611
+ return lines;
612
+ }
613
+
618
614
  /**
619
615
  * Get the visible width of the longest word in a string.
620
616
  */
@@ -325,131 +325,74 @@ const FUNCTIONAL_CODEPOINTS = {
325
325
  end: -15,
326
326
  } as const;
327
327
 
328
- const LEGACY_KEY_SEQUENCES = {
329
- up: ["\x1b[A", "\x1bOA"],
330
- down: ["\x1b[B", "\x1bOB"],
331
- right: ["\x1b[C", "\x1bOC"],
332
- left: ["\x1b[D", "\x1bOD"],
333
- home: ["\x1b[H", "\x1bOH", "\x1b[1~", "\x1b[7~"],
334
- end: ["\x1b[F", "\x1bOF", "\x1b[4~", "\x1b[8~"],
335
- insert: ["\x1b[2~"],
336
- delete: ["\x1b[3~"],
337
- pageUp: ["\x1b[5~", "\x1b[[5~"],
338
- pageDown: ["\x1b[6~", "\x1b[[6~"],
339
- clear: ["\x1b[E", "\x1bOE"],
340
- f1: ["\x1bOP", "\x1b[11~", "\x1b[[A"],
341
- f2: ["\x1bOQ", "\x1b[12~", "\x1b[[B"],
342
- f3: ["\x1bOR", "\x1b[13~", "\x1b[[C"],
343
- f4: ["\x1bOS", "\x1b[14~", "\x1b[[D"],
344
- f5: ["\x1b[15~", "\x1b[[E"],
345
- f6: ["\x1b[17~"],
346
- f7: ["\x1b[18~"],
347
- f8: ["\x1b[19~"],
348
- f9: ["\x1b[20~"],
349
- f10: ["\x1b[21~"],
350
- f11: ["\x1b[23~"],
351
- f12: ["\x1b[24~"],
352
- } as const;
353
-
354
- const LEGACY_SHIFT_SEQUENCES = {
355
- up: ["\x1b[a"],
356
- down: ["\x1b[b"],
357
- right: ["\x1b[c"],
358
- left: ["\x1b[d"],
359
- clear: ["\x1b[e"],
360
- insert: ["\x1b[2$"],
361
- delete: ["\x1b[3$"],
362
- pageUp: ["\x1b[5$"],
363
- pageDown: ["\x1b[6$"],
364
- home: ["\x1b[7$"],
365
- end: ["\x1b[8$"],
366
- } as const;
367
-
368
- const LEGACY_CTRL_SEQUENCES = {
369
- up: ["\x1bOa"],
370
- down: ["\x1bOb"],
371
- right: ["\x1bOc"],
372
- left: ["\x1bOd"],
373
- clear: ["\x1bOe"],
374
- insert: ["\x1b[2^"],
375
- delete: ["\x1b[3^"],
376
- pageUp: ["\x1b[5^"],
377
- pageDown: ["\x1b[6^"],
378
- home: ["\x1b[7^"],
379
- end: ["\x1b[8^"],
380
- } as const;
381
-
382
- const LEGACY_SEQUENCE_KEY_IDS: Record<string, KeyId> = {
383
- "\x1bOA": "up",
384
- "\x1bOB": "down",
385
- "\x1bOC": "right",
386
- "\x1bOD": "left",
387
- "\x1bOH": "home",
388
- "\x1bOF": "end",
389
- "\x1b[E": "clear",
390
- "\x1bOE": "clear",
391
- "\x1bOe": "ctrl+clear",
392
- "\x1b[e": "shift+clear",
393
- "\x1b[2~": "insert",
394
- "\x1b[2$": "shift+insert",
395
- "\x1b[2^": "ctrl+insert",
396
- "\x1b[3$": "shift+delete",
397
- "\x1b[3^": "ctrl+delete",
398
- "\x1b[[5~": "pageUp",
399
- "\x1b[[6~": "pageDown",
400
- "\x1b[a": "shift+up",
401
- "\x1b[b": "shift+down",
402
- "\x1b[c": "shift+right",
403
- "\x1b[d": "shift+left",
404
- "\x1bOa": "ctrl+up",
405
- "\x1bOb": "ctrl+down",
406
- "\x1bOc": "ctrl+right",
407
- "\x1bOd": "ctrl+left",
408
- "\x1b[5$": "shift+pageUp",
409
- "\x1b[6$": "shift+pageDown",
410
- "\x1b[7$": "shift+home",
411
- "\x1b[8$": "shift+end",
412
- "\x1b[5^": "ctrl+pageUp",
413
- "\x1b[6^": "ctrl+pageDown",
414
- "\x1b[7^": "ctrl+home",
415
- "\x1b[8^": "ctrl+end",
416
- "\x1bOP": "f1",
417
- "\x1bOQ": "f2",
418
- "\x1bOR": "f3",
419
- "\x1bOS": "f4",
420
- "\x1b[11~": "f1",
421
- "\x1b[12~": "f2",
422
- "\x1b[13~": "f3",
423
- "\x1b[14~": "f4",
424
- "\x1b[[A": "f1",
425
- "\x1b[[B": "f2",
426
- "\x1b[[C": "f3",
427
- "\x1b[[D": "f4",
428
- "\x1b[[E": "f5",
429
- "\x1b[15~": "f5",
430
- "\x1b[17~": "f6",
431
- "\x1b[18~": "f7",
432
- "\x1b[19~": "f8",
433
- "\x1b[20~": "f9",
434
- "\x1b[21~": "f10",
435
- "\x1b[23~": "f11",
436
- "\x1b[24~": "f12",
437
- "\x1bb": "alt+left",
438
- "\x1bf": "alt+right",
439
- "\x1bp": "alt+up",
440
- "\x1bn": "alt+down",
328
+ /**
329
+ * Consolidated legacy terminal key sequences.
330
+ * Each key maps to its sequences for unmodified, shift-modified, and ctrl-modified variants.
331
+ * This single structure replaces three separate maps (LEGACY_KEY_SEQUENCES,
332
+ * LEGACY_SHIFT_SEQUENCES, LEGACY_CTRL_SEQUENCES) that shared the same key sets.
333
+ */
334
+ const LEGACY_SEQUENCES: Record<string, { plain?: readonly string[]; shift?: readonly string[]; ctrl?: readonly string[] }> = {
335
+ up: { plain: ["\x1b[A", "\x1bOA"], shift: ["\x1b[a"], ctrl: ["\x1bOa"] },
336
+ down: { plain: ["\x1b[B", "\x1bOB"], shift: ["\x1b[b"], ctrl: ["\x1bOb"] },
337
+ right: { plain: ["\x1b[C", "\x1bOC"], shift: ["\x1b[c"], ctrl: ["\x1bOc"] },
338
+ left: { plain: ["\x1b[D", "\x1bOD"], shift: ["\x1b[d"], ctrl: ["\x1bOd"] },
339
+ home: { plain: ["\x1b[H", "\x1bOH", "\x1b[1~", "\x1b[7~"], shift: ["\x1b[7$"], ctrl: ["\x1b[7^"] },
340
+ end: { plain: ["\x1b[F", "\x1bOF", "\x1b[4~", "\x1b[8~"], shift: ["\x1b[8$"], ctrl: ["\x1b[8^"] },
341
+ insert: { plain: ["\x1b[2~"], shift: ["\x1b[2$"], ctrl: ["\x1b[2^"] },
342
+ delete: { plain: ["\x1b[3~"], shift: ["\x1b[3$"], ctrl: ["\x1b[3^"] },
343
+ pageUp: { plain: ["\x1b[5~", "\x1b[[5~"], shift: ["\x1b[5$"], ctrl: ["\x1b[5^"] },
344
+ pageDown: { plain: ["\x1b[6~", "\x1b[[6~"], shift: ["\x1b[6$"], ctrl: ["\x1b[6^"] },
345
+ clear: { plain: ["\x1b[E", "\x1bOE"], shift: ["\x1b[e"], ctrl: ["\x1bOe"] },
346
+ f1: { plain: ["\x1bOP", "\x1b[11~", "\x1b[[A"] },
347
+ f2: { plain: ["\x1bOQ", "\x1b[12~", "\x1b[[B"] },
348
+ f3: { plain: ["\x1bOR", "\x1b[13~", "\x1b[[C"] },
349
+ f4: { plain: ["\x1bOS", "\x1b[14~", "\x1b[[D"] },
350
+ f5: { plain: ["\x1b[15~", "\x1b[[E"] },
351
+ f6: { plain: ["\x1b[17~"] },
352
+ f7: { plain: ["\x1b[18~"] },
353
+ f8: { plain: ["\x1b[19~"] },
354
+ f9: { plain: ["\x1b[20~"] },
355
+ f10: { plain: ["\x1b[21~"] },
356
+ f11: { plain: ["\x1b[23~"] },
357
+ f12: { plain: ["\x1b[24~"] },
441
358
  } as const;
442
359
 
443
- type LegacyModifierKey = keyof typeof LEGACY_SHIFT_SEQUENCES;
360
+ /**
361
+ * Reverse lookup from escape sequence to key identifier, auto-generated from LEGACY_SEQUENCES.
362
+ * Additional non-standard sequences (alt+arrow aliases) are appended after generation.
363
+ */
364
+ const LEGACY_SEQUENCE_KEY_IDS: Record<string, KeyId> = (() => {
365
+ const map: Record<string, KeyId> = {};
366
+ for (const [key, entry] of Object.entries(LEGACY_SEQUENCES)) {
367
+ const keyId = key as KeyId;
368
+ if (entry.plain) {
369
+ for (const seq of entry.plain) map[seq] = keyId;
370
+ }
371
+ if (entry.shift) {
372
+ for (const seq of entry.shift) map[seq] = `shift+${keyId}` as KeyId;
373
+ }
374
+ if (entry.ctrl) {
375
+ for (const seq of entry.ctrl) map[seq] = `ctrl+${keyId}` as KeyId;
376
+ }
377
+ }
378
+ // Non-standard alt+arrow aliases not derivable from the table
379
+ map["\x1bb"] = "alt+left";
380
+ map["\x1bf"] = "alt+right";
381
+ map["\x1bp"] = "alt+up";
382
+ map["\x1bn"] = "alt+down";
383
+ return map;
384
+ })();
444
385
 
445
386
  const matchesLegacySequence = (data: string, sequences: readonly string[]): boolean => sequences.includes(data);
446
387
 
447
- const matchesLegacyModifierSequence = (data: string, key: LegacyModifierKey, modifier: number): boolean => {
448
- if (modifier === MODIFIERS.shift) {
449
- return matchesLegacySequence(data, LEGACY_SHIFT_SEQUENCES[key]);
388
+ const matchesLegacyModifierSequence = (data: string, key: string, modifier: number): boolean => {
389
+ const entry = LEGACY_SEQUENCES[key];
390
+ if (!entry) return false;
391
+ if (modifier === MODIFIERS.shift && entry.shift) {
392
+ return matchesLegacySequence(data, entry.shift);
450
393
  }
451
- if (modifier === MODIFIERS.ctrl) {
452
- return matchesLegacySequence(data, LEGACY_CTRL_SEQUENCES[key]);
394
+ if (modifier === MODIFIERS.ctrl && entry.ctrl) {
395
+ return matchesLegacySequence(data, entry.ctrl);
453
396
  }
454
397
  return false;
455
398
  };
@@ -481,33 +424,29 @@ interface ParsedModifyOtherKeysSequence {
481
424
  let _lastEventType: KeyEventType = "press";
482
425
 
483
426
  /**
484
- * Check if the last parsed key event was a key release.
485
- * Only meaningful when Kitty keyboard protocol with flag 2 is active.
427
+ * Check if input data contains a Kitty event type marker.
428
+ * Event type markers appear as ":<eventType>" followed by a sequence terminator (u, ~, A-D, H, F).
429
+ * Ignores bracketed paste content which may contain similar patterns.
486
430
  */
487
- export function isKeyRelease(data: string): boolean {
488
- // Don't treat bracketed paste content as key release, even if it contains
489
- // patterns like ":3F" (e.g., bluetooth MAC addresses like "90:62:3F:A5").
490
- // Terminal.ts re-wraps paste content with bracketed paste markers before
491
- // passing to TUI, so pasted data will always contain \x1b[200~.
431
+ function hasKittyEventType(data: string, eventType: number): boolean {
492
432
  if (data.includes("\x1b[200~")) {
493
433
  return false;
494
434
  }
435
+ const marker = `:${eventType}`;
436
+ return (
437
+ data.includes(`${marker}u`) ||
438
+ data.includes(`${marker}~`) ||
439
+ data.includes(`${marker}A`) ||
440
+ data.includes(`${marker}B`) ||
441
+ data.includes(`${marker}C`) ||
442
+ data.includes(`${marker}D`) ||
443
+ data.includes(`${marker}H`) ||
444
+ data.includes(`${marker}F`)
445
+ );
446
+ }
495
447
 
496
- // Quick check: release events with flag 2 contain ":3"
497
- // Format: \x1b[<codepoint>;<modifier>:3u
498
- if (
499
- data.includes(":3u") ||
500
- data.includes(":3~") ||
501
- data.includes(":3A") ||
502
- data.includes(":3B") ||
503
- data.includes(":3C") ||
504
- data.includes(":3D") ||
505
- data.includes(":3H") ||
506
- data.includes(":3F")
507
- ) {
508
- return true;
509
- }
510
- return false;
448
+ export function isKeyRelease(data: string): boolean {
449
+ return hasKittyEventType(data, 3);
511
450
  }
512
451
 
513
452
  /**
@@ -515,25 +454,7 @@ export function isKeyRelease(data: string): boolean {
515
454
  * Only meaningful when Kitty keyboard protocol with flag 2 is active.
516
455
  */
517
456
  export function isKeyRepeat(data: string): boolean {
518
- // Don't treat bracketed paste content as key repeat, even if it contains
519
- // patterns like ":2F". See isKeyRelease() for details.
520
- if (data.includes("\x1b[200~")) {
521
- return false;
522
- }
523
-
524
- if (
525
- data.includes(":2u") ||
526
- data.includes(":2~") ||
527
- data.includes(":2A") ||
528
- data.includes(":2B") ||
529
- data.includes(":2C") ||
530
- data.includes(":2D") ||
531
- data.includes(":2H") ||
532
- data.includes(":2F")
533
- ) {
534
- return true;
535
- }
536
- return false;
457
+ return hasKittyEventType(data, 2);
537
458
  }
538
459
 
539
460
  function parseEventType(eventTypeStr: string | undefined): KeyEventType {
@@ -847,7 +768,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
847
768
  case "insert":
848
769
  if (modifier === 0) {
849
770
  return (
850
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.insert) ||
771
+ matchesLegacySequence(data, LEGACY_SEQUENCES.insert.plain!) ||
851
772
  matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.insert, 0)
852
773
  );
853
774
  }
@@ -859,7 +780,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
859
780
  case "delete":
860
781
  if (modifier === 0) {
861
782
  return (
862
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.delete) ||
783
+ matchesLegacySequence(data, LEGACY_SEQUENCES.delete.plain!) ||
863
784
  matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.delete, 0)
864
785
  );
865
786
  }
@@ -870,14 +791,14 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
870
791
 
871
792
  case "clear":
872
793
  if (modifier === 0) {
873
- return matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.clear);
794
+ return matchesLegacySequence(data, LEGACY_SEQUENCES.clear.plain!);
874
795
  }
875
796
  return matchesLegacyModifierSequence(data, "clear", modifier);
876
797
 
877
798
  case "home":
878
799
  if (modifier === 0) {
879
800
  return (
880
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.home) ||
801
+ matchesLegacySequence(data, LEGACY_SEQUENCES.home.plain!) ||
881
802
  matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.home, 0)
882
803
  );
883
804
  }
@@ -889,7 +810,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
889
810
  case "end":
890
811
  if (modifier === 0) {
891
812
  return (
892
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.end) ||
813
+ matchesLegacySequence(data, LEGACY_SEQUENCES.end.plain!) ||
893
814
  matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.end, 0)
894
815
  );
895
816
  }
@@ -901,7 +822,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
901
822
  case "pageup":
902
823
  if (modifier === 0) {
903
824
  return (
904
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.pageUp) ||
825
+ matchesLegacySequence(data, LEGACY_SEQUENCES.pageUp.plain!) ||
905
826
  matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageUp, 0)
906
827
  );
907
828
  }
@@ -913,7 +834,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
913
834
  case "pagedown":
914
835
  if (modifier === 0) {
915
836
  return (
916
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.pageDown) ||
837
+ matchesLegacySequence(data, LEGACY_SEQUENCES.pageDown.plain!) ||
917
838
  matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageDown, 0)
918
839
  );
919
840
  }
@@ -928,7 +849,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
928
849
  }
929
850
  if (modifier === 0) {
930
851
  return (
931
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.up) ||
852
+ matchesLegacySequence(data, LEGACY_SEQUENCES.up.plain!) ||
932
853
  matchesKittySequence(data, ARROW_CODEPOINTS.up, 0)
933
854
  );
934
855
  }
@@ -943,7 +864,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
943
864
  }
944
865
  if (modifier === 0) {
945
866
  return (
946
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.down) ||
867
+ matchesLegacySequence(data, LEGACY_SEQUENCES.down.plain!) ||
947
868
  matchesKittySequence(data, ARROW_CODEPOINTS.down, 0)
948
869
  );
949
870
  }
@@ -970,7 +891,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
970
891
  }
971
892
  if (modifier === 0) {
972
893
  return (
973
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.left) ||
894
+ matchesLegacySequence(data, LEGACY_SEQUENCES.left.plain!) ||
974
895
  matchesKittySequence(data, ARROW_CODEPOINTS.left, 0)
975
896
  );
976
897
  }
@@ -997,7 +918,7 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
997
918
  }
998
919
  if (modifier === 0) {
999
920
  return (
1000
- matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.right) ||
921
+ matchesLegacySequence(data, LEGACY_SEQUENCES.right.plain!) ||
1001
922
  matchesKittySequence(data, ARROW_CODEPOINTS.right, 0)
1002
923
  );
1003
924
  }
@@ -1021,8 +942,8 @@ export function matchesKey(data: string, keyId: KeyId): boolean {
1021
942
  if (modifier !== 0) {
1022
943
  return false;
1023
944
  }
1024
- const functionKey = key as keyof typeof LEGACY_KEY_SEQUENCES;
1025
- return matchesLegacySequence(data, LEGACY_KEY_SEQUENCES[functionKey]);
945
+ const functionKey = key as keyof typeof LEGACY_SEQUENCES;
946
+ return matchesLegacySequence(data, LEGACY_SEQUENCES[functionKey]!.plain!);
1026
947
  }
1027
948
  }
1028
949