pi-usereq 0.48.0 → 0.50.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 (939) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -1
  3. package/scripts/lib/extension-debug-harness.ts +443 -0
  4. package/scripts/lib/recording-extension-api.ts +855 -0
  5. package/scripts/lib/sdk-smoke.ts +503 -0
  6. package/src/core/prompts.ts +4 -4
  7. package/.g.conf +0 -16
  8. package/.github/workflows/release-npm.yml +0 -134
  9. package/.gitignore +0 -274
  10. package/CHANGELOG.md +0 -699
  11. package/TODO.md +0 -20
  12. package/docs/pi.dev/agent-document-manifest.json +0 -6399
  13. package/docs/pi.dev/coding-agent-docs/compaction.md +0 -394
  14. package/docs/pi.dev/coding-agent-docs/custom-provider.md +0 -637
  15. package/docs/pi.dev/coding-agent-docs/development.md +0 -71
  16. package/docs/pi.dev/coding-agent-docs/extensions.md +0 -2536
  17. package/docs/pi.dev/coding-agent-docs/images/doom-extension.png +0 -0
  18. package/docs/pi.dev/coding-agent-docs/images/exy.png +0 -0
  19. package/docs/pi.dev/coding-agent-docs/images/interactive-mode.png +0 -0
  20. package/docs/pi.dev/coding-agent-docs/images/tree-view.png +0 -0
  21. package/docs/pi.dev/coding-agent-docs/json.md +0 -82
  22. package/docs/pi.dev/coding-agent-docs/keybindings.md +0 -197
  23. package/docs/pi.dev/coding-agent-docs/models.md +0 -395
  24. package/docs/pi.dev/coding-agent-docs/packages.md +0 -218
  25. package/docs/pi.dev/coding-agent-docs/prompt-templates.md +0 -88
  26. package/docs/pi.dev/coding-agent-docs/providers.md +0 -196
  27. package/docs/pi.dev/coding-agent-docs/rpc.md +0 -1407
  28. package/docs/pi.dev/coding-agent-docs/sdk.md +0 -1149
  29. package/docs/pi.dev/coding-agent-docs/session.md +0 -412
  30. package/docs/pi.dev/coding-agent-docs/settings.md +0 -248
  31. package/docs/pi.dev/coding-agent-docs/shell-aliases.md +0 -13
  32. package/docs/pi.dev/coding-agent-docs/skills.md +0 -232
  33. package/docs/pi.dev/coding-agent-docs/terminal-setup.md +0 -106
  34. package/docs/pi.dev/coding-agent-docs/termux.md +0 -127
  35. package/docs/pi.dev/coding-agent-docs/themes.md +0 -295
  36. package/docs/pi.dev/coding-agent-docs/tmux.md +0 -61
  37. package/docs/pi.dev/coding-agent-docs/tree.md +0 -233
  38. package/docs/pi.dev/coding-agent-docs/tui.md +0 -918
  39. package/docs/pi.dev/coding-agent-docs/windows.md +0 -17
  40. package/docs/pi.dev/mom-docs/artifacts-server.md +0 -475
  41. package/docs/pi.dev/mom-docs/events.md +0 -307
  42. package/docs/pi.dev/mom-docs/new.md +0 -970
  43. package/docs/pi.dev/mom-docs/sandbox.md +0 -153
  44. package/docs/pi.dev/mom-docs/slack-bot-minimal-guide.md +0 -399
  45. package/docs/pi.dev/mom-docs/v86.md +0 -319
  46. package/docs/pi.dev/pods-docs/gml-4.5.md +0 -189
  47. package/docs/pi.dev/pods-docs/gpt-oss.md +0 -233
  48. package/docs/pi.dev/pods-docs/implementation-plan.md +0 -183
  49. package/docs/pi.dev/pods-docs/kimi-k2.md +0 -197
  50. package/docs/pi.dev/pods-docs/models.md +0 -116
  51. package/docs/pi.dev/pods-docs/plan.md +0 -166
  52. package/docs/pi.dev/pods-docs/qwen3-coder.md +0 -132
  53. package/images/flowchart-bw.png +0 -0
  54. package/images/flowchart-bw.svg +0 -102
  55. package/images/flowchart.md +0 -100
  56. package/images/flowchart.png +0 -0
  57. package/images/flowchart.svg +0 -3
  58. package/pi-usereq/docs/REFERENCES.md +0 -5713
  59. package/pi-usereq/docs/REQUIREMENTS.md +0 -779
  60. package/pi-usereq/docs/WORKFLOW.md +0 -1341
  61. package/pi.dev-src/pi-mono/agent/src/agent-loop.ts +0 -683
  62. package/pi.dev-src/pi-mono/agent/src/agent.ts +0 -543
  63. package/pi.dev-src/pi-mono/agent/src/index.ts +0 -8
  64. package/pi.dev-src/pi-mono/agent/src/proxy.ts +0 -367
  65. package/pi.dev-src/pi-mono/agent/src/types.ts +0 -364
  66. package/pi.dev-src/pi-mono/agent/test/agent-loop.test.ts +0 -1181
  67. package/pi.dev-src/pi-mono/agent/test/agent.test.ts +0 -463
  68. package/pi.dev-src/pi-mono/agent/test/e2e.test.ts +0 -404
  69. package/pi.dev-src/pi-mono/agent/test/utils/calculate.ts +0 -32
  70. package/pi.dev-src/pi-mono/agent/test/utils/get-current-time.ts +0 -46
  71. package/pi.dev-src/pi-mono/agent/vitest.config.ts +0 -9
  72. package/pi.dev-src/pi-mono/ai/bedrock-provider.d.ts +0 -1
  73. package/pi.dev-src/pi-mono/ai/bedrock-provider.js +0 -1
  74. package/pi.dev-src/pi-mono/ai/scripts/generate-models.ts +0 -1635
  75. package/pi.dev-src/pi-mono/ai/scripts/generate-test-image.ts +0 -34
  76. package/pi.dev-src/pi-mono/ai/src/api-registry.ts +0 -98
  77. package/pi.dev-src/pi-mono/ai/src/bedrock-provider.ts +0 -6
  78. package/pi.dev-src/pi-mono/ai/src/cli.ts +0 -133
  79. package/pi.dev-src/pi-mono/ai/src/env-api-keys.ts +0 -134
  80. package/pi.dev-src/pi-mono/ai/src/index.ts +0 -35
  81. package/pi.dev-src/pi-mono/ai/src/models.generated.ts +0 -14928
  82. package/pi.dev-src/pi-mono/ai/src/models.ts +0 -82
  83. package/pi.dev-src/pi-mono/ai/src/oauth.ts +0 -1
  84. package/pi.dev-src/pi-mono/ai/src/providers/amazon-bedrock.ts +0 -929
  85. package/pi.dev-src/pi-mono/ai/src/providers/anthropic.ts +0 -1125
  86. package/pi.dev-src/pi-mono/ai/src/providers/azure-openai-responses.ts +0 -253
  87. package/pi.dev-src/pi-mono/ai/src/providers/faux.ts +0 -499
  88. package/pi.dev-src/pi-mono/ai/src/providers/github-copilot-headers.ts +0 -37
  89. package/pi.dev-src/pi-mono/ai/src/providers/google-gemini-cli.ts +0 -996
  90. package/pi.dev-src/pi-mono/ai/src/providers/google-shared.ts +0 -354
  91. package/pi.dev-src/pi-mono/ai/src/providers/google-vertex.ts +0 -543
  92. package/pi.dev-src/pi-mono/ai/src/providers/google.ts +0 -500
  93. package/pi.dev-src/pi-mono/ai/src/providers/mistral.ts +0 -629
  94. package/pi.dev-src/pi-mono/ai/src/providers/openai-codex-responses.ts +0 -984
  95. package/pi.dev-src/pi-mono/ai/src/providers/openai-completions.ts +0 -1063
  96. package/pi.dev-src/pi-mono/ai/src/providers/openai-responses-shared.ts +0 -539
  97. package/pi.dev-src/pi-mono/ai/src/providers/openai-responses.ts +0 -264
  98. package/pi.dev-src/pi-mono/ai/src/providers/register-builtins.ts +0 -433
  99. package/pi.dev-src/pi-mono/ai/src/providers/simple-options.ts +0 -47
  100. package/pi.dev-src/pi-mono/ai/src/providers/transform-messages.ts +0 -220
  101. package/pi.dev-src/pi-mono/ai/src/stream.ts +0 -59
  102. package/pi.dev-src/pi-mono/ai/src/types.ts +0 -417
  103. package/pi.dev-src/pi-mono/ai/src/utils/event-stream.ts +0 -87
  104. package/pi.dev-src/pi-mono/ai/src/utils/hash.ts +0 -13
  105. package/pi.dev-src/pi-mono/ai/src/utils/headers.ts +0 -7
  106. package/pi.dev-src/pi-mono/ai/src/utils/json-parse.ts +0 -124
  107. package/pi.dev-src/pi-mono/ai/src/utils/overflow.ts +0 -138
  108. package/pi.dev-src/pi-mono/ai/src/utils/sanitize-unicode.ts +0 -25
  109. package/pi.dev-src/pi-mono/ai/src/utils/typebox-helpers.ts +0 -24
  110. package/pi.dev-src/pi-mono/ai/src/utils/validation.ts +0 -324
  111. package/pi.dev-src/pi-mono/ai/test/abort.test.ts +0 -260
  112. package/pi.dev-src/pi-mono/ai/test/anthropic-oauth.test.ts +0 -99
  113. package/pi.dev-src/pi-mono/ai/test/anthropic-opus-4-7-smoke.test.ts +0 -72
  114. package/pi.dev-src/pi-mono/ai/test/anthropic-sse-parsing.test.ts +0 -113
  115. package/pi.dev-src/pi-mono/ai/test/anthropic-thinking-disable.test.ts +0 -152
  116. package/pi.dev-src/pi-mono/ai/test/anthropic-tool-name-normalization.test.ts +0 -205
  117. package/pi.dev-src/pi-mono/ai/test/azure-utils.ts +0 -28
  118. package/pi.dev-src/pi-mono/ai/test/bedrock-endpoint-resolution.test.ts +0 -131
  119. package/pi.dev-src/pi-mono/ai/test/bedrock-models.test.ts +0 -66
  120. package/pi.dev-src/pi-mono/ai/test/bedrock-thinking-payload.test.ts +0 -107
  121. package/pi.dev-src/pi-mono/ai/test/bedrock-utils.ts +0 -18
  122. package/pi.dev-src/pi-mono/ai/test/cache-retention.test.ts +0 -335
  123. package/pi.dev-src/pi-mono/ai/test/context-overflow.test.ts +0 -714
  124. package/pi.dev-src/pi-mono/ai/test/cross-provider-handoff.test.ts +0 -458
  125. package/pi.dev-src/pi-mono/ai/test/data/red-circle.png +0 -0
  126. package/pi.dev-src/pi-mono/ai/test/empty.test.ts +0 -742
  127. package/pi.dev-src/pi-mono/ai/test/faux-provider.test.ts +0 -597
  128. package/pi.dev-src/pi-mono/ai/test/fireworks-models.test.ts +0 -49
  129. package/pi.dev-src/pi-mono/ai/test/github-copilot-anthropic.test.ts +0 -108
  130. package/pi.dev-src/pi-mono/ai/test/github-copilot-oauth.test.ts +0 -196
  131. package/pi.dev-src/pi-mono/ai/test/google-gemini-cli-claude-thinking-header.test.ts +0 -103
  132. package/pi.dev-src/pi-mono/ai/test/google-gemini-cli-empty-stream.test.ts +0 -108
  133. package/pi.dev-src/pi-mono/ai/test/google-gemini-cli-retry-delay.test.ts +0 -53
  134. package/pi.dev-src/pi-mono/ai/test/google-shared-convert-tools.test.ts +0 -187
  135. package/pi.dev-src/pi-mono/ai/test/google-shared-gemini3-unsigned-tool-call.test.ts +0 -172
  136. package/pi.dev-src/pi-mono/ai/test/google-shared-image-tool-result-routing.test.ts +0 -124
  137. package/pi.dev-src/pi-mono/ai/test/google-thinking-disable.test.ts +0 -183
  138. package/pi.dev-src/pi-mono/ai/test/google-thinking-signature.test.ts +0 -38
  139. package/pi.dev-src/pi-mono/ai/test/google-tool-call-missing-args.test.ts +0 -105
  140. package/pi.dev-src/pi-mono/ai/test/google-vertex-api-key-resolution.test.ts +0 -144
  141. package/pi.dev-src/pi-mono/ai/test/image-tool-result.test.ts +0 -481
  142. package/pi.dev-src/pi-mono/ai/test/interleaved-thinking.test.ts +0 -145
  143. package/pi.dev-src/pi-mono/ai/test/lazy-module-load.test.ts +0 -102
  144. package/pi.dev-src/pi-mono/ai/test/mistral-reasoning-mode.test.ts +0 -66
  145. package/pi.dev-src/pi-mono/ai/test/mistral-tool-schema.test.ts +0 -61
  146. package/pi.dev-src/pi-mono/ai/test/oauth.ts +0 -89
  147. package/pi.dev-src/pi-mono/ai/test/openai-codex-cache-affinity-e2e.test.ts +0 -36
  148. package/pi.dev-src/pi-mono/ai/test/openai-codex-stream.test.ts +0 -686
  149. package/pi.dev-src/pi-mono/ai/test/openai-completions-cache-control-format.test.ts +0 -189
  150. package/pi.dev-src/pi-mono/ai/test/openai-completions-prompt-cache.test.ts +0 -198
  151. package/pi.dev-src/pi-mono/ai/test/openai-completions-thinking-as-text.test.ts +0 -214
  152. package/pi.dev-src/pi-mono/ai/test/openai-completions-tool-choice.test.ts +0 -560
  153. package/pi.dev-src/pi-mono/ai/test/openai-completions-tool-result-images.test.ts +0 -101
  154. package/pi.dev-src/pi-mono/ai/test/openai-responses-cache-affinity-e2e.test.ts +0 -32
  155. package/pi.dev-src/pi-mono/ai/test/openai-responses-copilot-provider.test.ts +0 -128
  156. package/pi.dev-src/pi-mono/ai/test/openai-responses-foreign-toolcall-id.test.ts +0 -66
  157. package/pi.dev-src/pi-mono/ai/test/openai-responses-partial-json-cleanup.test.ts +0 -101
  158. package/pi.dev-src/pi-mono/ai/test/openai-responses-reasoning-replay-e2e.test.ts +0 -292
  159. package/pi.dev-src/pi-mono/ai/test/openai-responses-tool-result-images.test.ts +0 -200
  160. package/pi.dev-src/pi-mono/ai/test/openrouter-cache-write-repro.test.ts +0 -78
  161. package/pi.dev-src/pi-mono/ai/test/overflow.test.ts +0 -64
  162. package/pi.dev-src/pi-mono/ai/test/responseid.test.ts +0 -145
  163. package/pi.dev-src/pi-mono/ai/test/stream.test.ts +0 -1405
  164. package/pi.dev-src/pi-mono/ai/test/supports-xhigh.test.ts +0 -34
  165. package/pi.dev-src/pi-mono/ai/test/tokens.test.ts +0 -304
  166. package/pi.dev-src/pi-mono/ai/test/tool-call-id-normalization.test.ts +0 -291
  167. package/pi.dev-src/pi-mono/ai/test/tool-call-without-result.test.ts +0 -313
  168. package/pi.dev-src/pi-mono/ai/test/total-tokens.test.ts +0 -695
  169. package/pi.dev-src/pi-mono/ai/test/transform-messages-copilot-openai-to-anthropic.test.ts +0 -191
  170. package/pi.dev-src/pi-mono/ai/test/unicode-surrogate.test.ts +0 -754
  171. package/pi.dev-src/pi-mono/ai/test/validation.test.ts +0 -116
  172. package/pi.dev-src/pi-mono/ai/test/xhigh.test.ts +0 -71
  173. package/pi.dev-src/pi-mono/ai/test/zen.test.ts +0 -25
  174. package/pi.dev-src/pi-mono/ai/vitest.config.ts +0 -9
  175. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/antigravity-image-gen.ts +0 -418
  176. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/auto-commit-on-exit.ts +0 -49
  177. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/bash-spawn-hook.ts +0 -30
  178. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/bookmark.ts +0 -50
  179. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/built-in-tool-renderer.ts +0 -249
  180. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/claude-rules.ts +0 -86
  181. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/commands.ts +0 -72
  182. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/confirm-destructive.ts +0 -59
  183. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-compaction.ts +0 -127
  184. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-footer.ts +0 -64
  185. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-header.ts +0 -73
  186. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-anthropic/index.ts +0 -604
  187. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  188. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -349
  189. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
  190. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-qwen-cli/index.ts +0 -345
  191. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dirty-repo-guard.ts +0 -56
  192. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom/build.sh +0 -152
  193. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
  194. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom-component.ts +0 -132
  195. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom-engine.ts +0 -173
  196. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom-keys.ts +0 -104
  197. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/index.ts +0 -74
  198. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/wad-finder.ts +0 -51
  199. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/SKILL.md +0 -8
  200. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/dynamic.json +0 -79
  201. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/dynamic.md +0 -5
  202. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/index.ts +0 -15
  203. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-tools.ts +0 -74
  204. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/event-bus.ts +0 -43
  205. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/file-trigger.ts +0 -41
  206. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/git-checkpoint.ts +0 -53
  207. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/github-issue-autocomplete.ts +0 -185
  208. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/handoff.ts +0 -153
  209. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/hello.ts +0 -26
  210. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/hidden-thinking-label.ts +0 -53
  211. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/inline-bash.ts +0 -94
  212. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/input-transform.ts +0 -43
  213. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/interactive-shell.ts +0 -196
  214. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/mac-system-theme.ts +0 -47
  215. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/message-renderer.ts +0 -59
  216. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/minimal-mode.ts +0 -426
  217. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/modal-editor.ts +0 -85
  218. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/model-status.ts +0 -31
  219. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/notify.ts +0 -55
  220. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/overlay-qa-tests.ts +0 -1348
  221. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/overlay-test.ts +0 -150
  222. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/permission-gate.ts +0 -34
  223. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/pirate.ts +0 -47
  224. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/plan-mode/index.ts +0 -340
  225. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/plan-mode/utils.ts +0 -168
  226. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/preset.ts +0 -430
  227. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/prompt-customizer.ts +0 -97
  228. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/protected-paths.ts +0 -30
  229. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/provider-payload.ts +0 -18
  230. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/qna.ts +0 -122
  231. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/question.ts +0 -264
  232. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/questionnaire.ts +0 -427
  233. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/rainbow-editor.ts +0 -88
  234. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/reload-runtime.ts +0 -37
  235. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/rpc-demo.ts +0 -118
  236. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/sandbox/index.ts +0 -321
  237. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/sandbox/package-lock.json +0 -92
  238. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/send-user-message.ts +0 -97
  239. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/session-name.ts +0 -27
  240. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/shutdown-command.ts +0 -63
  241. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/snake.ts +0 -343
  242. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/space-invaders.ts +0 -560
  243. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/ssh.ts +0 -220
  244. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/status-line.ts +0 -32
  245. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/structured-output.ts +0 -65
  246. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/planner.md +0 -37
  247. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/reviewer.md +0 -35
  248. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/scout.md +0 -50
  249. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/worker.md +0 -24
  250. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents.ts +0 -126
  251. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/index.ts +0 -987
  252. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
  253. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/prompts/implement.md +0 -10
  254. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
  255. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/summarize.ts +0 -206
  256. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/system-prompt-header.ts +0 -17
  257. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/tic-tac-toe.ts +0 -1008
  258. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/timed-confirm.ts +0 -70
  259. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/titlebar-spinner.ts +0 -58
  260. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/todo.ts +0 -297
  261. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/tool-override.ts +0 -144
  262. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/tools.ts +0 -141
  263. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/trigger-compact.ts +0 -50
  264. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/truncated-tool.ts +0 -195
  265. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/widget-placement.ts +0 -9
  266. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/with-deps/index.ts +0 -32
  267. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/with-deps/package-lock.json +0 -31
  268. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/working-indicator.ts +0 -123
  269. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/working-message-test.ts +0 -25
  270. package/pi.dev-src/pi-mono/coding-agent/examples/rpc-extension-ui.ts +0 -632
  271. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/01-minimal.ts +0 -22
  272. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/02-custom-model.ts +0 -49
  273. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/03-custom-prompt.ts +0 -62
  274. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/04-skills.ts +0 -55
  275. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/05-tools.ts +0 -44
  276. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/06-extensions.ts +0 -90
  277. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/07-context-files.ts +0 -42
  278. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/08-prompt-templates.ts +0 -51
  279. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/09-api-keys-and-oauth.ts +0 -48
  280. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/10-settings.ts +0 -53
  281. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/11-sessions.ts +0 -48
  282. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/12-full-control.ts +0 -73
  283. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/13-session-runtime.ts +0 -67
  284. package/pi.dev-src/pi-mono/coding-agent/scripts/migrate-sessions.sh +0 -93
  285. package/pi.dev-src/pi-mono/coding-agent/src/bun/cli.ts +0 -6
  286. package/pi.dev-src/pi-mono/coding-agent/src/bun/register-bedrock.ts +0 -4
  287. package/pi.dev-src/pi-mono/coding-agent/src/cli/args.ts +0 -335
  288. package/pi.dev-src/pi-mono/coding-agent/src/cli/config-selector.ts +0 -52
  289. package/pi.dev-src/pi-mono/coding-agent/src/cli/file-processor.ts +0 -100
  290. package/pi.dev-src/pi-mono/coding-agent/src/cli/initial-message.ts +0 -43
  291. package/pi.dev-src/pi-mono/coding-agent/src/cli/list-models.ts +0 -110
  292. package/pi.dev-src/pi-mono/coding-agent/src/cli/session-picker.ts +0 -52
  293. package/pi.dev-src/pi-mono/coding-agent/src/cli.ts +0 -17
  294. package/pi.dev-src/pi-mono/coding-agent/src/config.ts +0 -261
  295. package/pi.dev-src/pi-mono/coding-agent/src/core/agent-session-runtime.ts +0 -394
  296. package/pi.dev-src/pi-mono/coding-agent/src/core/agent-session-services.ts +0 -196
  297. package/pi.dev-src/pi-mono/coding-agent/src/core/agent-session.ts +0 -3096
  298. package/pi.dev-src/pi-mono/coding-agent/src/core/auth-storage.ts +0 -493
  299. package/pi.dev-src/pi-mono/coding-agent/src/core/bash-executor.ts +0 -154
  300. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/branch-summarization.ts +0 -355
  301. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/compaction.ts +0 -839
  302. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/index.ts +0 -7
  303. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/utils.ts +0 -170
  304. package/pi.dev-src/pi-mono/coding-agent/src/core/defaults.ts +0 -3
  305. package/pi.dev-src/pi-mono/coding-agent/src/core/diagnostics.ts +0 -15
  306. package/pi.dev-src/pi-mono/coding-agent/src/core/event-bus.ts +0 -33
  307. package/pi.dev-src/pi-mono/coding-agent/src/core/exec.ts +0 -107
  308. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/ansi-to-html.ts +0 -258
  309. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/index.ts +0 -314
  310. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/template.css +0 -1017
  311. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/template.html +0 -55
  312. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/template.js +0 -1770
  313. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/tool-renderer.ts +0 -158
  314. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/vendor/highlight.min.js +0 -1213
  315. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/vendor/marked.min.js +0 -6
  316. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/index.ts +0 -171
  317. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/loader.ts +0 -606
  318. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/runner.ts +0 -1019
  319. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/types.ts +0 -1542
  320. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/wrapper.ts +0 -30
  321. package/pi.dev-src/pi-mono/coding-agent/src/core/footer-data-provider.ts +0 -354
  322. package/pi.dev-src/pi-mono/coding-agent/src/core/index.ts +0 -77
  323. package/pi.dev-src/pi-mono/coding-agent/src/core/keybindings.ts +0 -370
  324. package/pi.dev-src/pi-mono/coding-agent/src/core/messages.ts +0 -195
  325. package/pi.dev-src/pi-mono/coding-agent/src/core/model-registry.ts +0 -858
  326. package/pi.dev-src/pi-mono/coding-agent/src/core/model-resolver.ts +0 -629
  327. package/pi.dev-src/pi-mono/coding-agent/src/core/output-guard.ts +0 -74
  328. package/pi.dev-src/pi-mono/coding-agent/src/core/package-manager.ts +0 -2408
  329. package/pi.dev-src/pi-mono/coding-agent/src/core/prompt-templates.ts +0 -296
  330. package/pi.dev-src/pi-mono/coding-agent/src/core/resolve-config-value.ts +0 -142
  331. package/pi.dev-src/pi-mono/coding-agent/src/core/resource-loader.ts +0 -917
  332. package/pi.dev-src/pi-mono/coding-agent/src/core/sdk.ts +0 -380
  333. package/pi.dev-src/pi-mono/coding-agent/src/core/session-cwd.ts +0 -59
  334. package/pi.dev-src/pi-mono/coding-agent/src/core/session-manager.ts +0 -1425
  335. package/pi.dev-src/pi-mono/coding-agent/src/core/settings-manager.ts +0 -999
  336. package/pi.dev-src/pi-mono/coding-agent/src/core/skills.ts +0 -508
  337. package/pi.dev-src/pi-mono/coding-agent/src/core/slash-commands.ts +0 -39
  338. package/pi.dev-src/pi-mono/coding-agent/src/core/source-info.ts +0 -40
  339. package/pi.dev-src/pi-mono/coding-agent/src/core/system-prompt.ts +0 -172
  340. package/pi.dev-src/pi-mono/coding-agent/src/core/telemetry.ts +0 -13
  341. package/pi.dev-src/pi-mono/coding-agent/src/core/timings.ts +0 -31
  342. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/bash.ts +0 -448
  343. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/edit-diff.ts +0 -445
  344. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/edit.ts +0 -487
  345. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/file-mutation-queue.ts +0 -39
  346. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/find.ts +0 -370
  347. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/grep.ts +0 -384
  348. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/index.ts +0 -196
  349. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/ls.ts +0 -229
  350. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/path-utils.ts +0 -94
  351. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/read.ts +0 -273
  352. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/render-utils.ts +0 -64
  353. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/tool-definition-wrapper.ts +0 -45
  354. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/truncate.ts +0 -265
  355. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/write.ts +0 -281
  356. package/pi.dev-src/pi-mono/coding-agent/src/index.ts +0 -352
  357. package/pi.dev-src/pi-mono/coding-agent/src/main.ts +0 -731
  358. package/pi.dev-src/pi-mono/coding-agent/src/migrations.ts +0 -314
  359. package/pi.dev-src/pi-mono/coding-agent/src/modes/index.ts +0 -9
  360. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/assets/clankolas.png +0 -0
  361. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/armin.ts +0 -382
  362. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/assistant-message.ts +0 -147
  363. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/bash-execution.ts +0 -218
  364. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/bordered-loader.ts +0 -68
  365. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/branch-summary-message.ts +0 -58
  366. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/compaction-summary-message.ts +0 -59
  367. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/config-selector.ts +0 -592
  368. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/countdown-timer.ts +0 -38
  369. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/custom-editor.ts +0 -80
  370. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/custom-message.ts +0 -99
  371. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/daxnuts.ts +0 -164
  372. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/diff.ts +0 -147
  373. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/dynamic-border.ts +0 -25
  374. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/earendil-announcement.ts +0 -53
  375. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/extension-editor.ts +0 -147
  376. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/extension-input.ts +0 -87
  377. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/extension-selector.ts +0 -107
  378. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/footer.ts +0 -220
  379. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/index.ts +0 -32
  380. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/keybinding-hints.ts +0 -24
  381. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/login-dialog.ts +0 -178
  382. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/model-selector.ts +0 -338
  383. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/oauth-selector.ts +0 -121
  384. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/scoped-models-selector.ts +0 -355
  385. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/session-selector-search.ts +0 -194
  386. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/session-selector.ts +0 -1026
  387. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/settings-selector.ts +0 -456
  388. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/show-images-selector.ts +0 -50
  389. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/skill-invocation-message.ts +0 -55
  390. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/theme-selector.ts +0 -67
  391. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/thinking-selector.ts +0 -74
  392. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/tool-execution.ts +0 -352
  393. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/tree-selector.ts +0 -1246
  394. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/user-message-selector.ts +0 -155
  395. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/user-message.ts +0 -35
  396. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/visual-truncate.ts +0 -50
  397. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/interactive-mode.ts +0 -5155
  398. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/dark.json +0 -85
  399. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/light.json +0 -84
  400. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
  401. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/theme.ts +0 -1141
  402. package/pi.dev-src/pi-mono/coding-agent/src/modes/print-mode.ts +0 -158
  403. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/jsonl.ts +0 -58
  404. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/rpc-client.ts +0 -515
  405. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/rpc-mode.ts +0 -745
  406. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/rpc-types.ts +0 -264
  407. package/pi.dev-src/pi-mono/coding-agent/src/package-manager-cli.ts +0 -270
  408. package/pi.dev-src/pi-mono/coding-agent/src/utils/changelog.ts +0 -99
  409. package/pi.dev-src/pi-mono/coding-agent/src/utils/child-process.ts +0 -86
  410. package/pi.dev-src/pi-mono/coding-agent/src/utils/clipboard-image.ts +0 -300
  411. package/pi.dev-src/pi-mono/coding-agent/src/utils/clipboard-native.ts +0 -22
  412. package/pi.dev-src/pi-mono/coding-agent/src/utils/clipboard.ts +0 -81
  413. package/pi.dev-src/pi-mono/coding-agent/src/utils/exif-orientation.ts +0 -183
  414. package/pi.dev-src/pi-mono/coding-agent/src/utils/frontmatter.ts +0 -39
  415. package/pi.dev-src/pi-mono/coding-agent/src/utils/fs-watch.ts +0 -30
  416. package/pi.dev-src/pi-mono/coding-agent/src/utils/git.ts +0 -192
  417. package/pi.dev-src/pi-mono/coding-agent/src/utils/image-convert.ts +0 -41
  418. package/pi.dev-src/pi-mono/coding-agent/src/utils/image-resize.ts +0 -176
  419. package/pi.dev-src/pi-mono/coding-agent/src/utils/mime.ts +0 -30
  420. package/pi.dev-src/pi-mono/coding-agent/src/utils/paths.ts +0 -20
  421. package/pi.dev-src/pi-mono/coding-agent/src/utils/photon.ts +0 -139
  422. package/pi.dev-src/pi-mono/coding-agent/src/utils/shell.ts +0 -210
  423. package/pi.dev-src/pi-mono/coding-agent/src/utils/sleep.ts +0 -18
  424. package/pi.dev-src/pi-mono/coding-agent/src/utils/tools-manager.ts +0 -287
  425. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-auto-compaction-queue.test.ts +0 -437
  426. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-branching.test.ts +0 -156
  427. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-compaction.test.ts +0 -208
  428. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-concurrent.test.ts +0 -618
  429. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-dynamic-provider.test.ts +0 -117
  430. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-dynamic-tools.test.ts +0 -182
  431. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-retry.test.ts +0 -318
  432. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-runtime-events.test.ts +0 -208
  433. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-stats.test.ts +0 -143
  434. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-tree-navigation.test.ts +0 -323
  435. package/pi.dev-src/pi-mono/coding-agent/test/args.test.ts +0 -328
  436. package/pi.dev-src/pi-mono/coding-agent/test/assistant-message.test.ts +0 -57
  437. package/pi.dev-src/pi-mono/coding-agent/test/auth-storage.test.ts +0 -462
  438. package/pi.dev-src/pi-mono/coding-agent/test/bash-close-hang-windows.test.ts +0 -126
  439. package/pi.dev-src/pi-mono/coding-agent/test/bash-execution-width.test.ts +0 -80
  440. package/pi.dev-src/pi-mono/coding-agent/test/block-images.test.ts +0 -120
  441. package/pi.dev-src/pi-mono/coding-agent/test/clipboard-image-bmp-conversion.test.ts +0 -88
  442. package/pi.dev-src/pi-mono/coding-agent/test/clipboard-image.test.ts +0 -136
  443. package/pi.dev-src/pi-mono/coding-agent/test/compaction-extensions-example.test.ts +0 -66
  444. package/pi.dev-src/pi-mono/coding-agent/test/compaction-extensions.test.ts +0 -415
  445. package/pi.dev-src/pi-mono/coding-agent/test/compaction-serialization.test.ts +0 -79
  446. package/pi.dev-src/pi-mono/coding-agent/test/compaction-summary-reasoning.test.ts +0 -118
  447. package/pi.dev-src/pi-mono/coding-agent/test/compaction-thinking-model.test.ts +0 -223
  448. package/pi.dev-src/pi-mono/coding-agent/test/compaction.test.ts +0 -550
  449. package/pi.dev-src/pi-mono/coding-agent/test/config.test.ts +0 -30
  450. package/pi.dev-src/pi-mono/coding-agent/test/edit-tool-legacy-input.test.ts +0 -116
  451. package/pi.dev-src/pi-mono/coding-agent/test/edit-tool-no-full-redraw.test.ts +0 -235
  452. package/pi.dev-src/pi-mono/coding-agent/test/export-html-whitespace.test.ts +0 -12
  453. package/pi.dev-src/pi-mono/coding-agent/test/export-html-xss.test.ts +0 -28
  454. package/pi.dev-src/pi-mono/coding-agent/test/extensions-discovery.test.ts +0 -463
  455. package/pi.dev-src/pi-mono/coding-agent/test/extensions-input-event.test.ts +0 -112
  456. package/pi.dev-src/pi-mono/coding-agent/test/extensions-runner.test.ts +0 -805
  457. package/pi.dev-src/pi-mono/coding-agent/test/file-mutation-queue.test.ts +0 -163
  458. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/assistant-message-with-thinking-code.json +0 -33
  459. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/before-compaction.jsonl +0 -1003
  460. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/empty-agent/.gitkeep +0 -0
  461. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/empty-cwd/.gitkeep +0 -0
  462. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/large-session.jsonl +0 -1019
  463. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/consecutive-hyphens/SKILL.md +0 -8
  464. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/disable-model-invocation/SKILL.md +0 -9
  465. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/invalid-name-chars/SKILL.md +0 -8
  466. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/invalid-yaml/SKILL.md +0 -8
  467. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/long-name/SKILL.md +0 -8
  468. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/missing-description/SKILL.md +0 -7
  469. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/multiline-description/SKILL.md +0 -11
  470. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/name-mismatch/SKILL.md +0 -8
  471. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/nested/child-skill/SKILL.md +0 -8
  472. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/no-frontmatter/SKILL.md +0 -3
  473. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/root-skill-preferred/SKILL.md +0 -3
  474. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/root-skill-preferred/nested-child/SKILL.md +0 -3
  475. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/unknown-field/SKILL.md +0 -10
  476. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/valid-skill/SKILL.md +0 -8
  477. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills-collision/first/calendar/SKILL.md +0 -8
  478. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills-collision/second/calendar/SKILL.md +0 -8
  479. package/pi.dev-src/pi-mono/coding-agent/test/footer-data-provider.test.ts +0 -265
  480. package/pi.dev-src/pi-mono/coding-agent/test/footer-width.test.ts +0 -115
  481. package/pi.dev-src/pi-mono/coding-agent/test/frontmatter.test.ts +0 -60
  482. package/pi.dev-src/pi-mono/coding-agent/test/git-ssh-url.test.ts +0 -78
  483. package/pi.dev-src/pi-mono/coding-agent/test/git-update.test.ts +0 -411
  484. package/pi.dev-src/pi-mono/coding-agent/test/image-processing.test.ts +0 -145
  485. package/pi.dev-src/pi-mono/coding-agent/test/image-resize-callers.test.ts +0 -53
  486. package/pi.dev-src/pi-mono/coding-agent/test/initial-message.test.ts +0 -48
  487. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-anthropic-warning.test.ts +0 -73
  488. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-clone-command.test.ts +0 -77
  489. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-compaction.test.ts +0 -57
  490. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-import-command.test.ts +0 -144
  491. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-status.test.ts +0 -635
  492. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-suspend.test.ts +0 -149
  493. package/pi.dev-src/pi-mono/coding-agent/test/keybindings-migration.test.ts +0 -88
  494. package/pi.dev-src/pi-mono/coding-agent/test/model-registry.test.ts +0 -1209
  495. package/pi.dev-src/pi-mono/coding-agent/test/model-resolver.test.ts +0 -436
  496. package/pi.dev-src/pi-mono/coding-agent/test/package-command-paths.test.ts +0 -144
  497. package/pi.dev-src/pi-mono/coding-agent/test/package-manager-ssh.test.ts +0 -97
  498. package/pi.dev-src/pi-mono/coding-agent/test/package-manager.test.ts +0 -1795
  499. package/pi.dev-src/pi-mono/coding-agent/test/path-utils.test.ts +0 -162
  500. package/pi.dev-src/pi-mono/coding-agent/test/plan-mode-utils.test.ts +0 -261
  501. package/pi.dev-src/pi-mono/coding-agent/test/print-mode.test.ts +0 -140
  502. package/pi.dev-src/pi-mono/coding-agent/test/prompt-templates.test.ts +0 -515
  503. package/pi.dev-src/pi-mono/coding-agent/test/resource-loader.test.ts +0 -576
  504. package/pi.dev-src/pi-mono/coding-agent/test/rpc-client-clone.test.ts +0 -29
  505. package/pi.dev-src/pi-mono/coding-agent/test/rpc-example.ts +0 -86
  506. package/pi.dev-src/pi-mono/coding-agent/test/rpc-jsonl.test.ts +0 -65
  507. package/pi.dev-src/pi-mono/coding-agent/test/rpc-prompt-response-semantics.test.ts +0 -285
  508. package/pi.dev-src/pi-mono/coding-agent/test/rpc.test.ts +0 -321
  509. package/pi.dev-src/pi-mono/coding-agent/test/sdk-codex-cache-probe-tool-loop.ts +0 -364
  510. package/pi.dev-src/pi-mono/coding-agent/test/sdk-openrouter-attribution.test.ts +0 -181
  511. package/pi.dev-src/pi-mono/coding-agent/test/sdk-session-manager.test.ts +0 -95
  512. package/pi.dev-src/pi-mono/coding-agent/test/sdk-skills.test.ts +0 -109
  513. package/pi.dev-src/pi-mono/coding-agent/test/session-cwd.test.ts +0 -91
  514. package/pi.dev-src/pi-mono/coding-agent/test/session-info-modified-timestamp.test.ts +0 -83
  515. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/build-context.test.ts +0 -268
  516. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/custom-session-id.test.ts +0 -109
  517. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/file-operations.test.ts +0 -208
  518. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/labels.test.ts +0 -198
  519. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/migration.test.ts +0 -78
  520. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/save-entry.test.ts +0 -55
  521. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/tree-traversal.test.ts +0 -533
  522. package/pi.dev-src/pi-mono/coding-agent/test/session-selector-path-delete.test.ts +0 -315
  523. package/pi.dev-src/pi-mono/coding-agent/test/session-selector-rename.test.ts +0 -111
  524. package/pi.dev-src/pi-mono/coding-agent/test/session-selector-search.test.ts +0 -195
  525. package/pi.dev-src/pi-mono/coding-agent/test/settings-manager-bug.test.ts +0 -147
  526. package/pi.dev-src/pi-mono/coding-agent/test/settings-manager.test.ts +0 -319
  527. package/pi.dev-src/pi-mono/coding-agent/test/skills.test.ts +0 -432
  528. package/pi.dev-src/pi-mono/coding-agent/test/stdout-cleanliness.test.ts +0 -103
  529. package/pi.dev-src/pi-mono/coding-agent/test/streaming-render-debug.ts +0 -97
  530. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-bash-persistence.test.ts +0 -242
  531. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-compaction.test.ts +0 -343
  532. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-model-extension.test.ts +0 -325
  533. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-prompt.test.ts +0 -323
  534. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-queue.test.ts +0 -422
  535. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-retry-events.test.ts +0 -358
  536. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-runtime.test.ts +0 -553
  537. package/pi.dev-src/pi-mono/coding-agent/test/suite/harness.ts +0 -208
  538. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2023-queued-slash-command-followup.test.ts +0 -80
  539. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2753-reload-stale-resource-settings.test.ts +0 -100
  540. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2781-skill-collision-precedence.test.ts +0 -120
  541. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2791-fswatch-error-crash.test.ts +0 -106
  542. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2835-tools-allowlist-filters-extension-tools.test.ts +0 -94
  543. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2860-replaced-session-context.test.ts +0 -274
  544. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3217-scoped-model-order.test.ts +0 -104
  545. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3302-find-path-glob.test.ts +0 -72
  546. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3303-find-nested-gitignore.test.ts +0 -83
  547. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3317-network-connection-lost-retry.test.ts +0 -33
  548. package/pi.dev-src/pi-mono/coding-agent/test/system-prompt.test.ts +0 -102
  549. package/pi.dev-src/pi-mono/coding-agent/test/test-harness.test.ts +0 -321
  550. package/pi.dev-src/pi-mono/coding-agent/test/test-harness.ts +0 -446
  551. package/pi.dev-src/pi-mono/coding-agent/test/test-theme-colors.ts +0 -246
  552. package/pi.dev-src/pi-mono/coding-agent/test/theme-export.test.ts +0 -104
  553. package/pi.dev-src/pi-mono/coding-agent/test/tool-execution-component.test.ts +0 -331
  554. package/pi.dev-src/pi-mono/coding-agent/test/tools.test.ts +0 -889
  555. package/pi.dev-src/pi-mono/coding-agent/test/tree-selector.test.ts +0 -655
  556. package/pi.dev-src/pi-mono/coding-agent/test/trigger-compact-extension.test.ts +0 -57
  557. package/pi.dev-src/pi-mono/coding-agent/test/truncate-to-width.test.ts +0 -81
  558. package/pi.dev-src/pi-mono/coding-agent/test/user-message.test.ts +0 -25
  559. package/pi.dev-src/pi-mono/coding-agent/test/utilities.ts +0 -316
  560. package/pi.dev-src/pi-mono/coding-agent/tsconfig.examples.json +0 -16
  561. package/pi.dev-src/pi-mono/coding-agent/vitest.config.ts +0 -26
  562. package/pi.dev-src/pi-mono/mom/dev.sh +0 -30
  563. package/pi.dev-src/pi-mono/mom/docker.sh +0 -95
  564. package/pi.dev-src/pi-mono/mom/scripts/migrate-timestamps.ts +0 -121
  565. package/pi.dev-src/pi-mono/mom/src/agent.ts +0 -882
  566. package/pi.dev-src/pi-mono/mom/src/context.ts +0 -180
  567. package/pi.dev-src/pi-mono/mom/src/download.ts +0 -117
  568. package/pi.dev-src/pi-mono/mom/src/events.ts +0 -442
  569. package/pi.dev-src/pi-mono/mom/src/fs-watch.ts +0 -30
  570. package/pi.dev-src/pi-mono/mom/src/log.ts +0 -271
  571. package/pi.dev-src/pi-mono/mom/src/main.ts +0 -367
  572. package/pi.dev-src/pi-mono/mom/src/sandbox.ts +0 -221
  573. package/pi.dev-src/pi-mono/mom/src/slack.ts +0 -623
  574. package/pi.dev-src/pi-mono/mom/src/store.ts +0 -234
  575. package/pi.dev-src/pi-mono/mom/src/tools/attach.ts +0 -47
  576. package/pi.dev-src/pi-mono/mom/src/tools/bash.ts +0 -97
  577. package/pi.dev-src/pi-mono/mom/src/tools/edit.ts +0 -165
  578. package/pi.dev-src/pi-mono/mom/src/tools/index.ts +0 -19
  579. package/pi.dev-src/pi-mono/mom/src/tools/read.ts +0 -159
  580. package/pi.dev-src/pi-mono/mom/src/tools/truncate.ts +0 -236
  581. package/pi.dev-src/pi-mono/mom/src/tools/write.ts +0 -45
  582. package/pi.dev-src/pi-mono/mom/test/events.test.ts +0 -50
  583. package/pi.dev-src/pi-mono/pods/scripts/model_run.sh +0 -83
  584. package/pi.dev-src/pi-mono/pods/scripts/pod_setup.sh +0 -336
  585. package/pi.dev-src/pi-mono/pods/src/cli.ts +0 -360
  586. package/pi.dev-src/pi-mono/pods/src/commands/models.ts +0 -753
  587. package/pi.dev-src/pi-mono/pods/src/commands/pods.ts +0 -205
  588. package/pi.dev-src/pi-mono/pods/src/commands/prompt.ts +0 -84
  589. package/pi.dev-src/pi-mono/pods/src/config.ts +0 -80
  590. package/pi.dev-src/pi-mono/pods/src/index.ts +0 -2
  591. package/pi.dev-src/pi-mono/pods/src/model-configs.ts +0 -111
  592. package/pi.dev-src/pi-mono/pods/src/models.json +0 -295
  593. package/pi.dev-src/pi-mono/pods/src/ssh.ts +0 -151
  594. package/pi.dev-src/pi-mono/pods/src/types.ts +0 -27
  595. package/pi.dev-src/pi-mono/tui/src/autocomplete.ts +0 -783
  596. package/pi.dev-src/pi-mono/tui/src/components/box.ts +0 -137
  597. package/pi.dev-src/pi-mono/tui/src/components/cancellable-loader.ts +0 -40
  598. package/pi.dev-src/pi-mono/tui/src/components/editor.ts +0 -2280
  599. package/pi.dev-src/pi-mono/tui/src/components/image.ts +0 -104
  600. package/pi.dev-src/pi-mono/tui/src/components/input.ts +0 -503
  601. package/pi.dev-src/pi-mono/tui/src/components/loader.ts +0 -86
  602. package/pi.dev-src/pi-mono/tui/src/components/markdown.ts +0 -852
  603. package/pi.dev-src/pi-mono/tui/src/components/select-list.ts +0 -229
  604. package/pi.dev-src/pi-mono/tui/src/components/settings-list.ts +0 -250
  605. package/pi.dev-src/pi-mono/tui/src/components/spacer.ts +0 -28
  606. package/pi.dev-src/pi-mono/tui/src/components/text.ts +0 -106
  607. package/pi.dev-src/pi-mono/tui/src/components/truncated-text.ts +0 -65
  608. package/pi.dev-src/pi-mono/tui/src/editor-component.ts +0 -74
  609. package/pi.dev-src/pi-mono/tui/src/fuzzy.ts +0 -133
  610. package/pi.dev-src/pi-mono/tui/src/index.ts +0 -106
  611. package/pi.dev-src/pi-mono/tui/src/keybindings.ts +0 -244
  612. package/pi.dev-src/pi-mono/tui/src/keys.ts +0 -1400
  613. package/pi.dev-src/pi-mono/tui/src/kill-ring.ts +0 -46
  614. package/pi.dev-src/pi-mono/tui/src/stdin-buffer.ts +0 -386
  615. package/pi.dev-src/pi-mono/tui/src/terminal-image.ts +0 -414
  616. package/pi.dev-src/pi-mono/tui/src/terminal.ts +0 -373
  617. package/pi.dev-src/pi-mono/tui/src/tui.ts +0 -1243
  618. package/pi.dev-src/pi-mono/tui/src/undo-stack.ts +0 -28
  619. package/pi.dev-src/pi-mono/tui/src/utils.ts +0 -1085
  620. package/pi.dev-src/pi-mono/tui/test/autocomplete.test.ts +0 -542
  621. package/pi.dev-src/pi-mono/tui/test/bug-regression-isimageline-startswith-bug.test.ts +0 -237
  622. package/pi.dev-src/pi-mono/tui/test/chat-simple.ts +0 -129
  623. package/pi.dev-src/pi-mono/tui/test/editor.test.ts +0 -3812
  624. package/pi.dev-src/pi-mono/tui/test/fuzzy.test.ts +0 -98
  625. package/pi.dev-src/pi-mono/tui/test/image-test.ts +0 -56
  626. package/pi.dev-src/pi-mono/tui/test/input.test.ts +0 -580
  627. package/pi.dev-src/pi-mono/tui/test/key-tester.ts +0 -105
  628. package/pi.dev-src/pi-mono/tui/test/keybindings.test.ts +0 -38
  629. package/pi.dev-src/pi-mono/tui/test/keys.test.ts +0 -614
  630. package/pi.dev-src/pi-mono/tui/test/markdown.test.ts +0 -1236
  631. package/pi.dev-src/pi-mono/tui/test/overlay-non-capturing.test.ts +0 -609
  632. package/pi.dev-src/pi-mono/tui/test/overlay-options.test.ts +0 -538
  633. package/pi.dev-src/pi-mono/tui/test/overlay-short-content.test.ts +0 -56
  634. package/pi.dev-src/pi-mono/tui/test/regression-regional-indicator-width.test.ts +0 -52
  635. package/pi.dev-src/pi-mono/tui/test/select-list.test.ts +0 -116
  636. package/pi.dev-src/pi-mono/tui/test/stdin-buffer.test.ts +0 -422
  637. package/pi.dev-src/pi-mono/tui/test/terminal-image.test.ts +0 -279
  638. package/pi.dev-src/pi-mono/tui/test/test-themes.ts +0 -38
  639. package/pi.dev-src/pi-mono/tui/test/truncate-to-width.test.ts +0 -62
  640. package/pi.dev-src/pi-mono/tui/test/truncated-text.test.ts +0 -129
  641. package/pi.dev-src/pi-mono/tui/test/tui-cell-size-input.test.ts +0 -81
  642. package/pi.dev-src/pi-mono/tui/test/tui-overlay-style-leak.test.ts +0 -72
  643. package/pi.dev-src/pi-mono/tui/test/tui-render.test.ts +0 -509
  644. package/pi.dev-src/pi-mono/tui/test/viewport-overwrite-repro.ts +0 -106
  645. package/pi.dev-src/pi-mono/tui/test/virtual-terminal.ts +0 -218
  646. package/pi.dev-src/pi-mono/tui/test/wrap-ansi.test.ts +0 -207
  647. package/pi.dev-src/pi-mono/tui/vitest.config.ts +0 -7
  648. package/pi.dev-src/pi-mono/web-ui/example/index.html +0 -13
  649. package/pi.dev-src/pi-mono/web-ui/example/src/app.css +0 -1
  650. package/pi.dev-src/pi-mono/web-ui/example/src/custom-messages.ts +0 -99
  651. package/pi.dev-src/pi-mono/web-ui/example/src/main.ts +0 -421
  652. package/pi.dev-src/pi-mono/web-ui/example/tsconfig.json +0 -23
  653. package/pi.dev-src/pi-mono/web-ui/example/vite.config.ts +0 -6
  654. package/pi.dev-src/pi-mono/web-ui/scripts/count-prompt-tokens.ts +0 -88
  655. package/pi.dev-src/pi-mono/web-ui/src/ChatPanel.ts +0 -209
  656. package/pi.dev-src/pi-mono/web-ui/src/app.css +0 -68
  657. package/pi.dev-src/pi-mono/web-ui/src/components/AgentInterface.ts +0 -403
  658. package/pi.dev-src/pi-mono/web-ui/src/components/AttachmentTile.ts +0 -107
  659. package/pi.dev-src/pi-mono/web-ui/src/components/ConsoleBlock.ts +0 -72
  660. package/pi.dev-src/pi-mono/web-ui/src/components/CustomProviderCard.ts +0 -100
  661. package/pi.dev-src/pi-mono/web-ui/src/components/ExpandableSection.ts +0 -46
  662. package/pi.dev-src/pi-mono/web-ui/src/components/Input.ts +0 -113
  663. package/pi.dev-src/pi-mono/web-ui/src/components/MessageEditor.ts +0 -405
  664. package/pi.dev-src/pi-mono/web-ui/src/components/MessageList.ts +0 -98
  665. package/pi.dev-src/pi-mono/web-ui/src/components/Messages.ts +0 -383
  666. package/pi.dev-src/pi-mono/web-ui/src/components/ProviderKeyInput.ts +0 -153
  667. package/pi.dev-src/pi-mono/web-ui/src/components/SandboxedIframe.ts +0 -626
  668. package/pi.dev-src/pi-mono/web-ui/src/components/StreamingMessageContainer.ts +0 -103
  669. package/pi.dev-src/pi-mono/web-ui/src/components/ThinkingBlock.ts +0 -43
  670. package/pi.dev-src/pi-mono/web-ui/src/components/message-renderer-registry.ts +0 -28
  671. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/ArtifactsRuntimeProvider.ts +0 -220
  672. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/AttachmentsRuntimeProvider.ts +0 -66
  673. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/ConsoleRuntimeProvider.ts +0 -186
  674. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/FileDownloadRuntimeProvider.ts +0 -110
  675. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/RuntimeMessageBridge.ts +0 -82
  676. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/RuntimeMessageRouter.ts +0 -216
  677. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/SandboxRuntimeProvider.ts +0 -52
  678. package/pi.dev-src/pi-mono/web-ui/src/dialogs/ApiKeyPromptDialog.ts +0 -75
  679. package/pi.dev-src/pi-mono/web-ui/src/dialogs/AttachmentOverlay.ts +0 -636
  680. package/pi.dev-src/pi-mono/web-ui/src/dialogs/CustomProviderDialog.ts +0 -274
  681. package/pi.dev-src/pi-mono/web-ui/src/dialogs/ModelSelector.ts +0 -370
  682. package/pi.dev-src/pi-mono/web-ui/src/dialogs/PersistentStorageDialog.ts +0 -144
  683. package/pi.dev-src/pi-mono/web-ui/src/dialogs/ProvidersModelsTab.ts +0 -212
  684. package/pi.dev-src/pi-mono/web-ui/src/dialogs/SessionListDialog.ts +0 -150
  685. package/pi.dev-src/pi-mono/web-ui/src/dialogs/SettingsDialog.ts +0 -218
  686. package/pi.dev-src/pi-mono/web-ui/src/index.ts +0 -120
  687. package/pi.dev-src/pi-mono/web-ui/src/prompts/prompts.ts +0 -282
  688. package/pi.dev-src/pi-mono/web-ui/src/storage/app-storage.ts +0 -60
  689. package/pi.dev-src/pi-mono/web-ui/src/storage/backends/indexeddb-storage-backend.ts +0 -193
  690. package/pi.dev-src/pi-mono/web-ui/src/storage/store.ts +0 -33
  691. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/custom-providers-store.ts +0 -62
  692. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/provider-keys-store.ts +0 -33
  693. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/sessions-store.ts +0 -136
  694. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/settings-store.ts +0 -34
  695. package/pi.dev-src/pi-mono/web-ui/src/storage/types.ts +0 -206
  696. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ArtifactElement.ts +0 -14
  697. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ArtifactPill.ts +0 -26
  698. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/Console.ts +0 -93
  699. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/DocxArtifact.ts +0 -213
  700. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ExcelArtifact.ts +0 -231
  701. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/GenericArtifact.ts +0 -117
  702. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/HtmlArtifact.ts +0 -195
  703. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ImageArtifact.ts +0 -116
  704. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/MarkdownArtifact.ts +0 -82
  705. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/PdfArtifact.ts +0 -201
  706. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/SvgArtifact.ts +0 -119
  707. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/TextArtifact.ts +0 -148
  708. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/artifacts-tool-renderer.ts +0 -310
  709. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/artifacts.ts +0 -713
  710. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/index.ts +0 -7
  711. package/pi.dev-src/pi-mono/web-ui/src/tools/extract-document.ts +0 -275
  712. package/pi.dev-src/pi-mono/web-ui/src/tools/index.ts +0 -46
  713. package/pi.dev-src/pi-mono/web-ui/src/tools/javascript-repl.ts +0 -293
  714. package/pi.dev-src/pi-mono/web-ui/src/tools/renderer-registry.ts +0 -130
  715. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/BashRenderer.ts +0 -52
  716. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/CalculateRenderer.ts +0 -58
  717. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/DefaultRenderer.ts +0 -103
  718. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/GetCurrentTimeRenderer.ts +0 -92
  719. package/pi.dev-src/pi-mono/web-ui/src/tools/types.ts +0 -15
  720. package/pi.dev-src/pi-mono/web-ui/src/utils/attachment-utils.ts +0 -472
  721. package/pi.dev-src/pi-mono/web-ui/src/utils/auth-token.ts +0 -22
  722. package/pi.dev-src/pi-mono/web-ui/src/utils/format.ts +0 -42
  723. package/pi.dev-src/pi-mono/web-ui/src/utils/i18n.ts +0 -653
  724. package/pi.dev-src/pi-mono/web-ui/src/utils/model-discovery.ts +0 -277
  725. package/pi.dev-src/pi-mono/web-ui/src/utils/proxy-utils.ts +0 -139
  726. package/pi.dev-src/pi-mono/web-ui/src/utils/test-sessions.ts +0 -2357
  727. package/pi.dev-src/pi-mono/web-ui/tsconfig.json +0 -7
  728. package/tests/attended-results-scenarios.ts +0 -648
  729. package/tests/attended-results.test.ts +0 -39
  730. package/tests/cli-command-option-parity.test.ts +0 -798
  731. package/tests/debug-extension-harness.test.ts +0 -466
  732. package/tests/extension-registration.test.ts +0 -6785
  733. package/tests/fixtures/fixture_c.c +0 -361
  734. package/tests/fixtures/fixture_cpp.cpp +0 -407
  735. package/tests/fixtures/fixture_csharp.cs +0 -411
  736. package/tests/fixtures/fixture_elixir.ex +0 -409
  737. package/tests/fixtures/fixture_go.go +0 -341
  738. package/tests/fixtures/fixture_haskell.hs +0 -250
  739. package/tests/fixtures/fixture_java.java +0 -430
  740. package/tests/fixtures/fixture_javascript.js +0 -383
  741. package/tests/fixtures/fixture_kotlin.kt +0 -451
  742. package/tests/fixtures/fixture_lua.lua +0 -276
  743. package/tests/fixtures/fixture_perl.pl +0 -310
  744. package/tests/fixtures/fixture_php.php +0 -433
  745. package/tests/fixtures/fixture_python.py +0 -502
  746. package/tests/fixtures/fixture_ruby.rb +0 -345
  747. package/tests/fixtures/fixture_rust.rs +0 -380
  748. package/tests/fixtures/fixture_scala.scala +0 -398
  749. package/tests/fixtures/fixture_shell.sh +0 -276
  750. package/tests/fixtures/fixture_swift.swift +0 -397
  751. package/tests/fixtures/fixture_typescript.ts +0 -434
  752. package/tests/fixtures/fixture_zig.zig +0 -295
  753. package/tests/fixtures_attended_results/project/compress-line-numbers.json +0 -5
  754. package/tests/fixtures_attended_results/project/compress.json +0 -5
  755. package/tests/fixtures_attended_results/project/enable-static-check-invalid-command.json +0 -5
  756. package/tests/fixtures_attended_results/project/enable-static-check-valid.json +0 -5
  757. package/tests/fixtures_attended_results/project/files-static-check.json +0 -5
  758. package/tests/fixtures_attended_results/project/find-line-numbers.json +0 -5
  759. package/tests/fixtures_attended_results/project/find.json +0 -5
  760. package/tests/fixtures_attended_results/project/get-base-path.json +0 -5
  761. package/tests/fixtures_attended_results/project/git-check-clean.json +0 -5
  762. package/tests/fixtures_attended_results/project/git-check-dirty.json +0 -5
  763. package/tests/fixtures_attended_results/project/git-path.json +0 -5
  764. package/tests/fixtures_attended_results/project/git-wt-create-invalid.json +0 -5
  765. package/tests/fixtures_attended_results/project/git-wt-create-valid.json +0 -5
  766. package/tests/fixtures_attended_results/project/git-wt-delete-nonexistent.json +0 -5
  767. package/tests/fixtures_attended_results/project/git-wt-delete-valid.json +0 -5
  768. package/tests/fixtures_attended_results/project/git-wt-name.json +0 -5
  769. package/tests/fixtures_attended_results/project/static-check.json +0 -5
  770. package/tests/fixtures_attended_results/project/summarize.json +0 -5
  771. package/tests/fixtures_attended_results/project/tokens.json +0 -5
  772. package/tests/fixtures_attended_results/standalone/files-compress/fixture_c.c.json +0 -5
  773. package/tests/fixtures_attended_results/standalone/files-compress/fixture_cpp.cpp.json +0 -5
  774. package/tests/fixtures_attended_results/standalone/files-compress/fixture_csharp.cs.json +0 -5
  775. package/tests/fixtures_attended_results/standalone/files-compress/fixture_elixir.ex.json +0 -5
  776. package/tests/fixtures_attended_results/standalone/files-compress/fixture_go.go.json +0 -5
  777. package/tests/fixtures_attended_results/standalone/files-compress/fixture_haskell.hs.json +0 -5
  778. package/tests/fixtures_attended_results/standalone/files-compress/fixture_java.java.json +0 -5
  779. package/tests/fixtures_attended_results/standalone/files-compress/fixture_javascript.js.json +0 -5
  780. package/tests/fixtures_attended_results/standalone/files-compress/fixture_kotlin.kt.json +0 -5
  781. package/tests/fixtures_attended_results/standalone/files-compress/fixture_lua.lua.json +0 -5
  782. package/tests/fixtures_attended_results/standalone/files-compress/fixture_perl.pl.json +0 -5
  783. package/tests/fixtures_attended_results/standalone/files-compress/fixture_php.php.json +0 -5
  784. package/tests/fixtures_attended_results/standalone/files-compress/fixture_python.py.json +0 -5
  785. package/tests/fixtures_attended_results/standalone/files-compress/fixture_ruby.rb.json +0 -5
  786. package/tests/fixtures_attended_results/standalone/files-compress/fixture_rust.rs.json +0 -5
  787. package/tests/fixtures_attended_results/standalone/files-compress/fixture_scala.scala.json +0 -5
  788. package/tests/fixtures_attended_results/standalone/files-compress/fixture_shell.sh.json +0 -5
  789. package/tests/fixtures_attended_results/standalone/files-compress/fixture_swift.swift.json +0 -5
  790. package/tests/fixtures_attended_results/standalone/files-compress/fixture_typescript.ts.json +0 -5
  791. package/tests/fixtures_attended_results/standalone/files-compress/fixture_zig.zig.json +0 -5
  792. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_c.c.json +0 -5
  793. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_cpp.cpp.json +0 -5
  794. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_csharp.cs.json +0 -5
  795. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_elixir.ex.json +0 -5
  796. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_go.go.json +0 -5
  797. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_haskell.hs.json +0 -5
  798. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_java.java.json +0 -5
  799. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_javascript.js.json +0 -5
  800. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_kotlin.kt.json +0 -5
  801. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_lua.lua.json +0 -5
  802. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_perl.pl.json +0 -5
  803. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_php.php.json +0 -5
  804. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_python.py.json +0 -5
  805. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_ruby.rb.json +0 -5
  806. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_rust.rs.json +0 -5
  807. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_scala.scala.json +0 -5
  808. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_shell.sh.json +0 -5
  809. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_swift.swift.json +0 -5
  810. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_typescript.ts.json +0 -5
  811. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_zig.zig.json +0 -5
  812. package/tests/fixtures_attended_results/standalone/files-find/fixture_c.c.json +0 -5
  813. package/tests/fixtures_attended_results/standalone/files-find/fixture_cpp.cpp.json +0 -5
  814. package/tests/fixtures_attended_results/standalone/files-find/fixture_csharp.cs.json +0 -5
  815. package/tests/fixtures_attended_results/standalone/files-find/fixture_elixir.ex.json +0 -5
  816. package/tests/fixtures_attended_results/standalone/files-find/fixture_go.go.json +0 -5
  817. package/tests/fixtures_attended_results/standalone/files-find/fixture_haskell.hs.json +0 -5
  818. package/tests/fixtures_attended_results/standalone/files-find/fixture_java.java.json +0 -5
  819. package/tests/fixtures_attended_results/standalone/files-find/fixture_javascript.js.json +0 -5
  820. package/tests/fixtures_attended_results/standalone/files-find/fixture_kotlin.kt.json +0 -5
  821. package/tests/fixtures_attended_results/standalone/files-find/fixture_lua.lua.json +0 -5
  822. package/tests/fixtures_attended_results/standalone/files-find/fixture_perl.pl.json +0 -5
  823. package/tests/fixtures_attended_results/standalone/files-find/fixture_php.php.json +0 -5
  824. package/tests/fixtures_attended_results/standalone/files-find/fixture_python.py.json +0 -5
  825. package/tests/fixtures_attended_results/standalone/files-find/fixture_ruby.rb.json +0 -5
  826. package/tests/fixtures_attended_results/standalone/files-find/fixture_rust.rs.json +0 -5
  827. package/tests/fixtures_attended_results/standalone/files-find/fixture_scala.scala.json +0 -5
  828. package/tests/fixtures_attended_results/standalone/files-find/fixture_shell.sh.json +0 -5
  829. package/tests/fixtures_attended_results/standalone/files-find/fixture_swift.swift.json +0 -5
  830. package/tests/fixtures_attended_results/standalone/files-find/fixture_typescript.ts.json +0 -5
  831. package/tests/fixtures_attended_results/standalone/files-find/fixture_zig.zig.json +0 -5
  832. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_c.c.json +0 -5
  833. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_cpp.cpp.json +0 -5
  834. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_csharp.cs.json +0 -5
  835. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_elixir.ex.json +0 -5
  836. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_go.go.json +0 -5
  837. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_haskell.hs.json +0 -5
  838. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_java.java.json +0 -5
  839. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_javascript.js.json +0 -5
  840. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_kotlin.kt.json +0 -5
  841. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_lua.lua.json +0 -5
  842. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_perl.pl.json +0 -5
  843. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_php.php.json +0 -5
  844. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_python.py.json +0 -5
  845. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_ruby.rb.json +0 -5
  846. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_rust.rs.json +0 -5
  847. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_scala.scala.json +0 -5
  848. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_shell.sh.json +0 -5
  849. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_swift.swift.json +0 -5
  850. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_typescript.ts.json +0 -5
  851. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_zig.zig.json +0 -5
  852. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_c.c.json +0 -5
  853. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_cpp.cpp.json +0 -5
  854. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_csharp.cs.json +0 -5
  855. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_elixir.ex.json +0 -5
  856. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_go.go.json +0 -5
  857. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_haskell.hs.json +0 -5
  858. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_java.java.json +0 -5
  859. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_javascript.js.json +0 -5
  860. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_kotlin.kt.json +0 -5
  861. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_lua.lua.json +0 -5
  862. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_perl.pl.json +0 -5
  863. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_php.php.json +0 -5
  864. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_python.py.json +0 -5
  865. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_ruby.rb.json +0 -5
  866. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_rust.rs.json +0 -5
  867. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_scala.scala.json +0 -5
  868. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_shell.sh.json +0 -5
  869. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_swift.swift.json +0 -5
  870. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_typescript.ts.json +0 -5
  871. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_zig.zig.json +0 -5
  872. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_c.c.json +0 -5
  873. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_cpp.cpp.json +0 -5
  874. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_csharp.cs.json +0 -5
  875. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_elixir.ex.json +0 -5
  876. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_go.go.json +0 -5
  877. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_haskell.hs.json +0 -5
  878. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_java.java.json +0 -5
  879. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_javascript.js.json +0 -5
  880. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_kotlin.kt.json +0 -5
  881. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_lua.lua.json +0 -5
  882. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_perl.pl.json +0 -5
  883. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_php.php.json +0 -5
  884. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_python.py.json +0 -5
  885. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_ruby.rb.json +0 -5
  886. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_rust.rs.json +0 -5
  887. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_scala.scala.json +0 -5
  888. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_shell.sh.json +0 -5
  889. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_swift.swift.json +0 -5
  890. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_typescript.ts.json +0 -5
  891. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_zig.zig.json +0 -5
  892. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_c.c.json +0 -5
  893. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_cpp.cpp.json +0 -5
  894. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_csharp.cs.json +0 -5
  895. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_elixir.ex.json +0 -5
  896. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_go.go.json +0 -5
  897. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_haskell.hs.json +0 -5
  898. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_java.java.json +0 -5
  899. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_javascript.js.json +0 -5
  900. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_kotlin.kt.json +0 -5
  901. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_lua.lua.json +0 -5
  902. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_perl.pl.json +0 -5
  903. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_php.php.json +0 -5
  904. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_python.py.json +0 -5
  905. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_ruby.rb.json +0 -5
  906. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_rust.rs.json +0 -5
  907. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_scala.scala.json +0 -5
  908. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_shell.sh.json +0 -5
  909. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_swift.swift.json +0 -5
  910. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_typescript.ts.json +0 -5
  911. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_zig.zig.json +0 -5
  912. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_c.c.json +0 -5
  913. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_cpp.cpp.json +0 -5
  914. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_csharp.cs.json +0 -5
  915. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_elixir.ex.json +0 -5
  916. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_go.go.json +0 -5
  917. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_haskell.hs.json +0 -5
  918. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_java.java.json +0 -5
  919. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_javascript.js.json +0 -5
  920. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_kotlin.kt.json +0 -5
  921. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_lua.lua.json +0 -5
  922. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_perl.pl.json +0 -5
  923. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_php.php.json +0 -5
  924. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_python.py.json +0 -5
  925. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_ruby.rb.json +0 -5
  926. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_rust.rs.json +0 -5
  927. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_scala.scala.json +0 -5
  928. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_shell.sh.json +0 -5
  929. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_swift.swift.json +0 -5
  930. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_typescript.ts.json +0 -5
  931. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_zig.zig.json +0 -5
  932. package/tests/helpers.ts +0 -236
  933. package/tests/oracle-project.test.ts +0 -67
  934. package/tests/oracle-standalone.test.ts +0 -68
  935. package/tests/prompt-command-summary.test.ts +0 -36
  936. package/tests/prompt-rendering.test.ts +0 -103
  937. package/tests/python_oracle_stubs/tiktoken.py +0 -76
  938. package/tests/release-workflow.test.ts +0 -195
  939. package/tests/static-check-bundled.test.ts +0 -332
@@ -1,3812 +0,0 @@
1
- import assert from "node:assert";
2
- import { describe, it } from "node:test";
3
- import { stripVTControlCharacters } from "node:util";
4
- import { type AutocompleteProvider, CombinedAutocompleteProvider } from "../src/autocomplete.js";
5
- import { Editor, wordWrapLine } from "../src/components/editor.js";
6
- import { TUI } from "../src/tui.js";
7
- import { visibleWidth } from "../src/utils.js";
8
- import { defaultEditorTheme } from "./test-themes.js";
9
- import { VirtualTerminal } from "./virtual-terminal.js";
10
-
11
- /** Create a TUI with a virtual terminal for testing */
12
- function createTestTUI(cols = 80, rows = 24): TUI {
13
- return new TUI(new VirtualTerminal(cols, rows));
14
- }
15
-
16
- /** Standard applyCompletion that replaces prefix with item.value */
17
- function applyCompletion(
18
- lines: string[],
19
- cursorLine: number,
20
- cursorCol: number,
21
- item: { value: string },
22
- prefix: string,
23
- ): { lines: string[]; cursorLine: number; cursorCol: number } {
24
- const line = lines[cursorLine] || "";
25
- const before = line.slice(0, cursorCol - prefix.length);
26
- const after = line.slice(cursorCol);
27
- const newLines = [...lines];
28
- newLines[cursorLine] = before + item.value + after;
29
- return {
30
- lines: newLines,
31
- cursorLine,
32
- cursorCol: cursorCol - prefix.length + item.value.length,
33
- };
34
- }
35
-
36
- async function flushAutocomplete(): Promise<void> {
37
- await Promise.resolve();
38
- await new Promise((resolve) => setImmediate(resolve));
39
- }
40
-
41
- describe("Editor component", () => {
42
- describe("Prompt history navigation", () => {
43
- it("does nothing on Up arrow when history is empty", () => {
44
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
45
-
46
- editor.handleInput("\x1b[A"); // Up arrow
47
-
48
- assert.strictEqual(editor.getText(), "");
49
- });
50
-
51
- it("shows most recent history entry on Up arrow when editor is empty", () => {
52
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
53
-
54
- editor.addToHistory("first prompt");
55
- editor.addToHistory("second prompt");
56
-
57
- editor.handleInput("\x1b[A"); // Up arrow
58
-
59
- assert.strictEqual(editor.getText(), "second prompt");
60
- });
61
-
62
- it("cycles through history entries on repeated Up arrow", () => {
63
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
64
-
65
- editor.addToHistory("first");
66
- editor.addToHistory("second");
67
- editor.addToHistory("third");
68
-
69
- editor.handleInput("\x1b[A"); // Up - shows "third"
70
- assert.strictEqual(editor.getText(), "third");
71
-
72
- editor.handleInput("\x1b[A"); // Up - shows "second"
73
- assert.strictEqual(editor.getText(), "second");
74
-
75
- editor.handleInput("\x1b[A"); // Up - shows "first"
76
- assert.strictEqual(editor.getText(), "first");
77
-
78
- editor.handleInput("\x1b[A"); // Up - stays at "first" (oldest)
79
- assert.strictEqual(editor.getText(), "first");
80
- });
81
-
82
- it("returns to empty editor on Down arrow after browsing history", () => {
83
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
84
-
85
- editor.addToHistory("prompt");
86
-
87
- editor.handleInput("\x1b[A"); // Up - shows "prompt"
88
- assert.strictEqual(editor.getText(), "prompt");
89
-
90
- editor.handleInput("\x1b[B"); // Down - clears editor
91
- assert.strictEqual(editor.getText(), "");
92
- });
93
-
94
- it("navigates forward through history with Down arrow", () => {
95
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
96
-
97
- editor.addToHistory("first");
98
- editor.addToHistory("second");
99
- editor.addToHistory("third");
100
-
101
- // Go to oldest
102
- editor.handleInput("\x1b[A"); // third
103
- editor.handleInput("\x1b[A"); // second
104
- editor.handleInput("\x1b[A"); // first
105
-
106
- // Navigate back
107
- editor.handleInput("\x1b[B"); // second
108
- assert.strictEqual(editor.getText(), "second");
109
-
110
- editor.handleInput("\x1b[B"); // third
111
- assert.strictEqual(editor.getText(), "third");
112
-
113
- editor.handleInput("\x1b[B"); // empty
114
- assert.strictEqual(editor.getText(), "");
115
- });
116
-
117
- it("exits history mode when typing a character", () => {
118
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
119
-
120
- editor.addToHistory("old prompt");
121
-
122
- editor.handleInput("\x1b[A"); // Up - shows "old prompt"
123
- editor.handleInput("x"); // Type a character - exits history mode
124
-
125
- assert.strictEqual(editor.getText(), "old promptx");
126
- });
127
-
128
- it("exits history mode on setText", () => {
129
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
130
-
131
- editor.addToHistory("first");
132
- editor.addToHistory("second");
133
-
134
- editor.handleInput("\x1b[A"); // Up - shows "second"
135
- editor.setText(""); // External clear
136
-
137
- // Up should start fresh from most recent
138
- editor.handleInput("\x1b[A");
139
- assert.strictEqual(editor.getText(), "second");
140
- });
141
-
142
- it("does not add empty strings to history", () => {
143
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
144
-
145
- editor.addToHistory("");
146
- editor.addToHistory(" ");
147
- editor.addToHistory("valid");
148
-
149
- editor.handleInput("\x1b[A");
150
- assert.strictEqual(editor.getText(), "valid");
151
-
152
- // Should not have more entries
153
- editor.handleInput("\x1b[A");
154
- assert.strictEqual(editor.getText(), "valid");
155
- });
156
-
157
- it("does not add consecutive duplicates to history", () => {
158
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
159
-
160
- editor.addToHistory("same");
161
- editor.addToHistory("same");
162
- editor.addToHistory("same");
163
-
164
- editor.handleInput("\x1b[A"); // "same"
165
- assert.strictEqual(editor.getText(), "same");
166
-
167
- editor.handleInput("\x1b[A"); // stays at "same" (only one entry)
168
- assert.strictEqual(editor.getText(), "same");
169
- });
170
-
171
- it("allows non-consecutive duplicates in history", () => {
172
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
173
-
174
- editor.addToHistory("first");
175
- editor.addToHistory("second");
176
- editor.addToHistory("first"); // Not consecutive, should be added
177
-
178
- editor.handleInput("\x1b[A"); // "first"
179
- assert.strictEqual(editor.getText(), "first");
180
-
181
- editor.handleInput("\x1b[A"); // "second"
182
- assert.strictEqual(editor.getText(), "second");
183
-
184
- editor.handleInput("\x1b[A"); // "first" (older one)
185
- assert.strictEqual(editor.getText(), "first");
186
- });
187
-
188
- it("uses cursor movement instead of history when editor has content", () => {
189
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
190
-
191
- editor.addToHistory("history item");
192
- editor.setText("line1\nline2");
193
-
194
- // Cursor is at end of line2, Up should move to line1
195
- editor.handleInput("\x1b[A"); // Up - cursor movement
196
-
197
- // Insert character to verify cursor position
198
- editor.handleInput("X");
199
-
200
- // X should be inserted in line1, not replace with history
201
- assert.strictEqual(editor.getText(), "line1X\nline2");
202
- });
203
-
204
- it("limits history to 100 entries", () => {
205
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
206
-
207
- // Add 105 entries
208
- for (let i = 0; i < 105; i++) {
209
- editor.addToHistory(`prompt ${i}`);
210
- }
211
-
212
- // Navigate to oldest
213
- for (let i = 0; i < 100; i++) {
214
- editor.handleInput("\x1b[A");
215
- }
216
-
217
- // Should be at entry 5 (oldest kept), not entry 0
218
- assert.strictEqual(editor.getText(), "prompt 5");
219
-
220
- // One more Up should not change anything
221
- editor.handleInput("\x1b[A");
222
- assert.strictEqual(editor.getText(), "prompt 5");
223
- });
224
-
225
- it("allows cursor movement within multi-line history entry with Down", () => {
226
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
227
-
228
- editor.addToHistory("line1\nline2\nline3");
229
-
230
- // Browse to the multi-line entry
231
- editor.handleInput("\x1b[A"); // Up - shows entry, cursor at end of line3
232
- assert.strictEqual(editor.getText(), "line1\nline2\nline3");
233
-
234
- // Down should exit history since cursor is on last line
235
- editor.handleInput("\x1b[B"); // Down
236
- assert.strictEqual(editor.getText(), ""); // Exited to empty
237
- });
238
-
239
- it("allows cursor movement within multi-line history entry with Up", () => {
240
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
241
-
242
- editor.addToHistory("older entry");
243
- editor.addToHistory("line1\nline2\nline3");
244
-
245
- // Browse to the multi-line entry
246
- editor.handleInput("\x1b[A"); // Up - shows multi-line, cursor at end of line3
247
-
248
- // Up should move cursor within the entry (not on first line yet)
249
- editor.handleInput("\x1b[A"); // Up - cursor moves to line2
250
- assert.strictEqual(editor.getText(), "line1\nline2\nline3"); // Still same entry
251
-
252
- editor.handleInput("\x1b[A"); // Up - cursor moves to line1 (now on first visual line)
253
- assert.strictEqual(editor.getText(), "line1\nline2\nline3"); // Still same entry
254
-
255
- // Now Up should navigate to older history entry
256
- editor.handleInput("\x1b[A"); // Up - navigate to older
257
- assert.strictEqual(editor.getText(), "older entry");
258
- });
259
-
260
- it("navigates from multi-line entry back to newer via Down after cursor movement", () => {
261
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
262
-
263
- editor.addToHistory("line1\nline2\nline3");
264
-
265
- // Browse to entry and move cursor up
266
- editor.handleInput("\x1b[A"); // Up - shows entry, cursor at end
267
- editor.handleInput("\x1b[A"); // Up - cursor to line2
268
- editor.handleInput("\x1b[A"); // Up - cursor to line1
269
-
270
- // Now Down should move cursor down within the entry
271
- editor.handleInput("\x1b[B"); // Down - cursor to line2
272
- assert.strictEqual(editor.getText(), "line1\nline2\nline3");
273
-
274
- editor.handleInput("\x1b[B"); // Down - cursor to line3
275
- assert.strictEqual(editor.getText(), "line1\nline2\nline3");
276
-
277
- // Now on last line, Down should exit history
278
- editor.handleInput("\x1b[B"); // Down - exit to empty
279
- assert.strictEqual(editor.getText(), "");
280
- });
281
- });
282
-
283
- describe("public state accessors", () => {
284
- it("returns cursor position", () => {
285
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
286
-
287
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
288
-
289
- editor.handleInput("a");
290
- editor.handleInput("b");
291
- editor.handleInput("c");
292
-
293
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
294
-
295
- editor.handleInput("\x1b[D"); // Left
296
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 2 });
297
- });
298
-
299
- it("returns lines as a defensive copy", () => {
300
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
301
- editor.setText("a\nb");
302
-
303
- const lines = editor.getLines();
304
- assert.deepStrictEqual(lines, ["a", "b"]);
305
-
306
- lines[0] = "mutated";
307
- assert.deepStrictEqual(editor.getLines(), ["a", "b"]);
308
- });
309
- });
310
-
311
- describe("Backslash+Enter newline workaround", () => {
312
- it("inserts backslash immediately (no buffering)", () => {
313
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
314
-
315
- editor.handleInput("\\");
316
-
317
- // Backslash should be visible immediately, not buffered
318
- assert.strictEqual(editor.getText(), "\\");
319
- });
320
-
321
- it("converts standalone backslash to newline on Enter", () => {
322
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
323
-
324
- editor.handleInput("\\");
325
- editor.handleInput("\r");
326
-
327
- assert.strictEqual(editor.getText(), "\n");
328
- });
329
-
330
- it("inserts backslash normally when followed by other characters", () => {
331
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
332
-
333
- editor.handleInput("\\");
334
- editor.handleInput("x");
335
-
336
- assert.strictEqual(editor.getText(), "\\x");
337
- });
338
-
339
- it("does not trigger newline when backslash is not immediately before cursor", () => {
340
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
341
- let submitted = false;
342
-
343
- editor.onSubmit = () => {
344
- submitted = true;
345
- };
346
-
347
- editor.handleInput("\\");
348
- editor.handleInput("x");
349
- editor.handleInput("\r");
350
-
351
- // Should submit, not insert newline (backslash not at cursor)
352
- assert.strictEqual(submitted, true);
353
- });
354
-
355
- it("only removes one backslash when multiple are present", () => {
356
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
357
-
358
- editor.handleInput("\\");
359
- editor.handleInput("\\");
360
- editor.handleInput("\\");
361
- assert.strictEqual(editor.getText(), "\\\\\\");
362
-
363
- editor.handleInput("\r");
364
- // Only the last backslash is removed, newline inserted
365
- assert.strictEqual(editor.getText(), "\\\\\n");
366
- });
367
- });
368
-
369
- describe("Kitty CSI-u handling", () => {
370
- it("ignores printable CSI-u sequences with unsupported modifiers", () => {
371
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
372
-
373
- editor.handleInput("\x1b[99;9u");
374
-
375
- assert.strictEqual(editor.getText(), "");
376
- });
377
-
378
- it("inserts shifted CSI-u letters as text", () => {
379
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
380
-
381
- editor.handleInput("\x1b[69;2u");
382
-
383
- assert.strictEqual(editor.getText(), "E");
384
- });
385
-
386
- it("inserts shifted xterm modifyOtherKeys letters as text", () => {
387
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
388
-
389
- editor.handleInput("\x1b[27;2;69~");
390
-
391
- assert.strictEqual(editor.getText(), "E");
392
- });
393
- });
394
-
395
- describe("Unicode text editing behavior", () => {
396
- it("inserts mixed ASCII, umlauts, and emojis as literal text", () => {
397
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
398
-
399
- editor.handleInput("H");
400
- editor.handleInput("e");
401
- editor.handleInput("l");
402
- editor.handleInput("l");
403
- editor.handleInput("o");
404
- editor.handleInput(" ");
405
- editor.handleInput("ä");
406
- editor.handleInput("ö");
407
- editor.handleInput("ü");
408
- editor.handleInput(" ");
409
- editor.handleInput("😀");
410
-
411
- const text = editor.getText();
412
- assert.strictEqual(text, "Hello äöü 😀");
413
- });
414
-
415
- it("deletes single-code-unit unicode characters (umlauts) with Backspace", () => {
416
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
417
-
418
- editor.handleInput("ä");
419
- editor.handleInput("ö");
420
- editor.handleInput("ü");
421
-
422
- // Delete the last character (ü)
423
- editor.handleInput("\x7f"); // Backspace
424
-
425
- const text = editor.getText();
426
- assert.strictEqual(text, "äö");
427
- });
428
-
429
- it("deletes multi-code-unit emojis with single Backspace", () => {
430
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
431
-
432
- editor.handleInput("😀");
433
- editor.handleInput("👍");
434
-
435
- // Delete the last emoji (👍) - single backspace deletes whole grapheme cluster
436
- editor.handleInput("\x7f"); // Backspace
437
-
438
- const text = editor.getText();
439
- assert.strictEqual(text, "😀");
440
- });
441
-
442
- it("inserts characters at the correct position after cursor movement over umlauts", () => {
443
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
444
-
445
- editor.handleInput("ä");
446
- editor.handleInput("ö");
447
- editor.handleInput("ü");
448
-
449
- // Move cursor left twice
450
- editor.handleInput("\x1b[D"); // Left arrow
451
- editor.handleInput("\x1b[D"); // Left arrow
452
-
453
- // Insert 'x' in the middle
454
- editor.handleInput("x");
455
-
456
- const text = editor.getText();
457
- assert.strictEqual(text, "äxöü");
458
- });
459
-
460
- it("moves cursor across multi-code-unit emojis with single arrow key", () => {
461
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
462
-
463
- editor.handleInput("😀");
464
- editor.handleInput("👍");
465
- editor.handleInput("🎉");
466
-
467
- // Move cursor left over last emoji (🎉) - single arrow moves over whole grapheme
468
- editor.handleInput("\x1b[D"); // Left arrow
469
-
470
- // Move cursor left over second emoji (👍)
471
- editor.handleInput("\x1b[D");
472
-
473
- // Insert 'x' between first and second emoji
474
- editor.handleInput("x");
475
-
476
- const text = editor.getText();
477
- assert.strictEqual(text, "😀x👍🎉");
478
- });
479
-
480
- it("preserves umlauts across line breaks", () => {
481
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
482
-
483
- editor.handleInput("ä");
484
- editor.handleInput("ö");
485
- editor.handleInput("ü");
486
- editor.handleInput("\n"); // new line
487
- editor.handleInput("Ä");
488
- editor.handleInput("Ö");
489
- editor.handleInput("Ü");
490
-
491
- const text = editor.getText();
492
- assert.strictEqual(text, "äöü\nÄÖÜ");
493
- });
494
-
495
- it("replaces the entire document with unicode text via setText (paste simulation)", () => {
496
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
497
-
498
- // Simulate bracketed paste / programmatic replacement
499
- editor.setText("Hällö Wörld! 😀 äöüÄÖÜß");
500
-
501
- const text = editor.getText();
502
- assert.strictEqual(text, "Hällö Wörld! 😀 äöüÄÖÜß");
503
- });
504
-
505
- it("moves cursor to document start on Ctrl+A and inserts at the beginning", () => {
506
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
507
-
508
- editor.handleInput("a");
509
- editor.handleInput("b");
510
- editor.handleInput("\x01"); // Ctrl+A (move to start)
511
- editor.handleInput("x"); // Insert at start
512
-
513
- const text = editor.getText();
514
- assert.strictEqual(text, "xab");
515
- });
516
-
517
- it("deletes words correctly with Ctrl+W and Alt+Backspace", () => {
518
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
519
-
520
- // Basic word deletion
521
- editor.setText("foo bar baz");
522
- editor.handleInput("\x17"); // Ctrl+W
523
- assert.strictEqual(editor.getText(), "foo bar ");
524
-
525
- // Trailing whitespace
526
- editor.setText("foo bar ");
527
- editor.handleInput("\x17");
528
- assert.strictEqual(editor.getText(), "foo ");
529
-
530
- // Punctuation run
531
- editor.setText("foo bar...");
532
- editor.handleInput("\x17");
533
- assert.strictEqual(editor.getText(), "foo bar");
534
-
535
- // Delete across multiple lines
536
- editor.setText("line one\nline two");
537
- editor.handleInput("\x17");
538
- assert.strictEqual(editor.getText(), "line one\nline ");
539
-
540
- // Delete empty line (merge)
541
- editor.setText("line one\n");
542
- editor.handleInput("\x17");
543
- assert.strictEqual(editor.getText(), "line one");
544
-
545
- // Grapheme safety (emoji as a word)
546
- editor.setText("foo 😀😀 bar");
547
- editor.handleInput("\x17");
548
- assert.strictEqual(editor.getText(), "foo 😀😀 ");
549
- editor.handleInput("\x17");
550
- assert.strictEqual(editor.getText(), "foo ");
551
-
552
- // Alt+Backspace
553
- editor.setText("foo bar");
554
- editor.handleInput("\x1b\x7f"); // Alt+Backspace (legacy)
555
- assert.strictEqual(editor.getText(), "foo ");
556
- });
557
-
558
- it("navigates words correctly with Ctrl+Left/Right", () => {
559
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
560
-
561
- editor.setText("foo bar... baz");
562
- // Cursor at end
563
-
564
- // Move left over baz
565
- editor.handleInput("\x1b[1;5D"); // Ctrl+Left
566
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 11 }); // after '...'
567
-
568
- // Move left over punctuation
569
- editor.handleInput("\x1b[1;5D"); // Ctrl+Left
570
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 7 }); // after 'bar'
571
-
572
- // Move left over bar
573
- editor.handleInput("\x1b[1;5D"); // Ctrl+Left
574
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 4 }); // after 'foo '
575
-
576
- // Move right over bar
577
- editor.handleInput("\x1b[1;5C"); // Ctrl+Right
578
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 7 }); // at end of 'bar'
579
-
580
- // Move right over punctuation run
581
- editor.handleInput("\x1b[1;5C"); // Ctrl+Right
582
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 }); // after '...'
583
-
584
- // Move right skips space and lands after baz
585
- editor.handleInput("\x1b[1;5C"); // Ctrl+Right
586
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 14 }); // end of line
587
-
588
- // Test forward from start with leading whitespace
589
- editor.setText(" foo bar");
590
- editor.handleInput("\x01"); // Ctrl+A to go to start
591
- editor.handleInput("\x1b[1;5C"); // Ctrl+Right
592
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 6 }); // after 'foo'
593
- });
594
- });
595
-
596
- describe("Grapheme-aware text wrapping", () => {
597
- it("wraps lines correctly when text contains wide emojis", () => {
598
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
599
- const width = 20;
600
-
601
- // ✅ is 2 columns wide, so "Hello ✅ World" is 14 columns
602
- editor.setText("Hello ✅ World");
603
- const lines = editor.render(width);
604
-
605
- // All content lines (between borders) should fit within width
606
- for (let i = 1; i < lines.length - 1; i++) {
607
- const lineWidth = visibleWidth(lines[i]!);
608
- assert.strictEqual(lineWidth, width, `Line ${i} has width ${lineWidth}, expected ${width}`);
609
- }
610
- });
611
-
612
- it("wraps long text with emojis at correct positions", () => {
613
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
614
- const width = 10;
615
-
616
- // Each ✅ is 2 columns. "✅✅✅✅✅" = 10 columns, fits exactly
617
- // "✅✅✅✅✅✅" = 12 columns, needs wrap
618
- editor.setText("✅✅✅✅✅✅");
619
- const lines = editor.render(width);
620
-
621
- // Should have 2 content lines (plus 2 border lines)
622
- // First line: 5 emojis (10 cols), second line: 1 emoji (2 cols) + padding
623
- for (let i = 1; i < lines.length - 1; i++) {
624
- const lineWidth = visibleWidth(lines[i]!);
625
- assert.strictEqual(lineWidth, width, `Line ${i} has width ${lineWidth}, expected ${width}`);
626
- }
627
- });
628
-
629
- it("wraps CJK characters correctly (each is 2 columns wide)", () => {
630
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
631
- const width = 10 + 1; // +1 col reserved for cursor
632
-
633
- // Each CJK char is 2 columns. "日本語テスト" = 6 chars = 12 columns
634
- editor.setText("日本語テスト");
635
- const lines = editor.render(width);
636
-
637
- for (let i = 1; i < lines.length - 1; i++) {
638
- const lineWidth = visibleWidth(lines[i]!);
639
- assert.strictEqual(lineWidth, width, `Line ${i} has width ${lineWidth}, expected ${width}`);
640
- }
641
-
642
- // Verify content split correctly
643
- const contentLines = lines.slice(1, -1).map((l) => stripVTControlCharacters(l).trim());
644
- assert.strictEqual(contentLines.length, 2);
645
- assert.strictEqual(contentLines[0], "日本語テス"); // 5 chars = 10 columns
646
- assert.strictEqual(contentLines[1], "ト"); // 1 char = 2 columns (+ padding)
647
- });
648
-
649
- it("handles mixed ASCII and wide characters in wrapping", () => {
650
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
651
- const width = 15 + 1; // +1 col reserved for cursor
652
-
653
- // "Test ✅ OK 日本" = 4 + 1 + 2 + 1 + 2 + 1 + 4 = 15 columns (fits in width-1=15)
654
- editor.setText("Test ✅ OK 日本");
655
- const lines = editor.render(width);
656
-
657
- // Should fit in one content line
658
- const contentLines = lines.slice(1, -1);
659
- assert.strictEqual(contentLines.length, 1);
660
-
661
- const lineWidth = visibleWidth(contentLines[0]!);
662
- assert.strictEqual(lineWidth, width);
663
- });
664
-
665
- it("renders cursor correctly on wide characters", () => {
666
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
667
- const width = 20;
668
-
669
- editor.setText("A✅B");
670
- // Cursor should be at end (after B)
671
- const lines = editor.render(width);
672
-
673
- // The cursor (reverse video space) should be visible
674
- const contentLine = lines[1]!;
675
- assert.ok(contentLine.includes("\x1b[7m"), "Should have reverse video cursor");
676
-
677
- // Line should still be correct width
678
- assert.strictEqual(visibleWidth(contentLine), width);
679
- });
680
-
681
- it("does not exceed terminal width with emoji at wrap boundary", () => {
682
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
683
- const width = 11;
684
-
685
- // "0123456789✅" = 10 ASCII + 2-wide emoji = 12 columns
686
- // Should wrap before the emoji since it would exceed width
687
- editor.setText("0123456789✅");
688
- const lines = editor.render(width);
689
-
690
- for (let i = 1; i < lines.length - 1; i++) {
691
- const lineWidth = visibleWidth(lines[i]!);
692
- assert.ok(lineWidth <= width, `Line ${i} has width ${lineWidth}, exceeds max ${width}`);
693
- }
694
- });
695
-
696
- it("shows cursor at end of line before wrap, wraps on next char", () => {
697
- const width = 10;
698
- for (const paddingX of [0, 1]) {
699
- const editor = new Editor(createTestTUI(width + paddingX), defaultEditorTheme, { paddingX });
700
-
701
- // Type 9 chars → fills layoutWidth exactly, cursor at end on same line
702
- for (const ch of "aaaaaaaaa") editor.handleInput(ch);
703
- let lines = editor.render(width + paddingX);
704
- let contentLines = lines.slice(1, -1);
705
- assert.strictEqual(contentLines.length, 1, "Should be 1 content line before wrap");
706
- assert.ok(contentLines[0]!.endsWith("\x1b[7m \x1b[0m"), "Cursor should be at end of line");
707
-
708
- // Type 1 more → text wraps to second line
709
- editor.handleInput("a");
710
- lines = editor.render(width + paddingX);
711
- contentLines = lines.slice(1, -1);
712
- assert.strictEqual(contentLines.length, 2, "Should wrap to 2 content lines");
713
- }
714
- });
715
- });
716
-
717
- describe("Word wrapping", () => {
718
- it("wraps at word boundaries instead of mid-word", () => {
719
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
720
- const width = 40;
721
-
722
- editor.setText("Hello world this is a test of word wrapping functionality");
723
- const lines = editor.render(width);
724
-
725
- // Get content lines (between borders)
726
- const contentLines = lines.slice(1, -1).map((l) => stripVTControlCharacters(l).trim());
727
-
728
- // Should NOT break mid-word
729
- // Line 1 should end with a complete word
730
- assert.ok(!contentLines[0]!.endsWith("-"), "Line should not end with hyphen (mid-word break)");
731
-
732
- // Each content line should be complete words
733
- for (const line of contentLines) {
734
- // Words at end of line should be complete (no partial words)
735
- const lastChar = line.trimEnd().slice(-1);
736
- assert.ok(lastChar === "" || /[\w.,!?;:]/.test(lastChar), `Line ends unexpectedly with: "${lastChar}"`);
737
- }
738
- });
739
-
740
- it("does not start lines with leading whitespace after word wrap", () => {
741
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
742
- const width = 20;
743
-
744
- editor.setText("Word1 Word2 Word3 Word4 Word5 Word6");
745
- const lines = editor.render(width);
746
-
747
- // Get content lines (between borders)
748
- const contentLines = lines.slice(1, -1);
749
-
750
- // No line should start with whitespace (except for padding at the end)
751
- for (let i = 0; i < contentLines.length; i++) {
752
- const line = stripVTControlCharacters(contentLines[i]!);
753
- const trimmedStart = line.trimStart();
754
- // The line should either be all padding or start with a word character
755
- if (trimmedStart.length > 0) {
756
- assert.ok(!/^\s+\S/.test(line.trimEnd()), `Line ${i} starts with unexpected whitespace before content`);
757
- }
758
- }
759
- });
760
-
761
- it("breaks long words (URLs) at character level", () => {
762
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
763
- const width = 30;
764
-
765
- editor.setText("Check https://example.com/very/long/path/that/exceeds/width here");
766
- const lines = editor.render(width);
767
-
768
- // All lines should fit within width
769
- for (let i = 1; i < lines.length - 1; i++) {
770
- const lineWidth = visibleWidth(lines[i]!);
771
- assert.strictEqual(lineWidth, width, `Line ${i} has width ${lineWidth}, expected ${width}`);
772
- }
773
- });
774
-
775
- it("preserves multiple spaces within words on same line", () => {
776
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
777
- const width = 50;
778
-
779
- editor.setText("Word1 Word2 Word3");
780
- const lines = editor.render(width);
781
-
782
- const contentLine = stripVTControlCharacters(lines[1]!).trim();
783
- // Multiple spaces should be preserved
784
- assert.ok(contentLine.includes("Word1 Word2"), "Multiple spaces should be preserved");
785
- });
786
-
787
- it("handles empty string", () => {
788
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
789
- const width = 40;
790
-
791
- editor.setText("");
792
- const lines = editor.render(width);
793
-
794
- // Should have border + empty content + border
795
- assert.strictEqual(lines.length, 3);
796
- });
797
-
798
- it("handles single word that fits exactly", () => {
799
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
800
- const width = 10 + 1; // +1 col reserved for cursor
801
-
802
- editor.setText("1234567890");
803
- const lines = editor.render(width);
804
-
805
- // Should have exactly 3 lines (top border, content, bottom border)
806
- assert.strictEqual(lines.length, 3);
807
- const contentLine = stripVTControlCharacters(lines[1]!);
808
- assert.ok(contentLine.includes("1234567890"), "Content should contain the word");
809
- });
810
-
811
- it("wraps word to next line when it ends exactly at terminal width", () => {
812
- // "hello " (6) + "world" (5) = 11, but "world" is non-whitespace ending at width.
813
- // Thus, wrap it to next line. The trailing space stays with "hello" on line 1
814
- const chunks = wordWrapLine("hello world test", 11);
815
-
816
- assert.strictEqual(chunks.length, 2);
817
- assert.strictEqual(chunks[0]!.text, "hello ");
818
- assert.strictEqual(chunks[1]!.text, "world test");
819
- });
820
-
821
- it("keeps whitespace at terminal width boundary on same line", () => {
822
- // "hello world " is exactly 12 chars (including trailing space)
823
- // The space at position 12 should stay on the first line
824
- const chunks = wordWrapLine("hello world test", 12);
825
-
826
- assert.strictEqual(chunks.length, 2);
827
- assert.strictEqual(chunks[0]!.text, "hello world ");
828
- assert.strictEqual(chunks[1]!.text, "test");
829
- });
830
-
831
- it("handles unbreakable word filling width exactly followed by space", () => {
832
- const chunks = wordWrapLine("aaaaaaaaaaaa aaaa", 12);
833
-
834
- assert.strictEqual(chunks.length, 2);
835
- assert.strictEqual(chunks[0]!.text, "aaaaaaaaaaaa");
836
- assert.strictEqual(chunks[1]!.text, " aaaa");
837
- });
838
-
839
- it("wraps word to next line when it fits width but not remaining space", () => {
840
- const chunks = wordWrapLine(" aaaaaaaaaaaa", 12);
841
-
842
- assert.strictEqual(chunks.length, 2);
843
- assert.strictEqual(chunks[0]!.text, " ");
844
- assert.strictEqual(chunks[1]!.text, "aaaaaaaaaaaa");
845
- });
846
-
847
- it("keeps word with multi-space and following word together when they fit", () => {
848
- const chunks = wordWrapLine("Lorem ipsum dolor sit amet, consectetur", 30);
849
-
850
- assert.strictEqual(chunks.length, 2);
851
- assert.strictEqual(chunks[0]!.text, "Lorem ipsum dolor sit ");
852
- assert.strictEqual(chunks[1]!.text, "amet, consectetur");
853
- });
854
-
855
- it("keeps word with multi-space and following word when they fill width exactly", () => {
856
- const chunks = wordWrapLine("Lorem ipsum dolor sit amet, consectetur", 30);
857
-
858
- assert.strictEqual(chunks.length, 2);
859
- assert.strictEqual(chunks[0]!.text, "Lorem ipsum dolor sit ");
860
- assert.strictEqual(chunks[1]!.text, "amet, consectetur");
861
- });
862
-
863
- it("splits when word plus multi-space plus word exceeds width", () => {
864
- const chunks = wordWrapLine("Lorem ipsum dolor sit amet, consectetur", 30);
865
-
866
- assert.strictEqual(chunks.length, 3);
867
- assert.strictEqual(chunks[0]!.text, "Lorem ipsum dolor sit ");
868
- assert.strictEqual(chunks[1]!.text, "amet, ");
869
- assert.strictEqual(chunks[2]!.text, "consectetur");
870
- });
871
-
872
- it("breaks long whitespace at line boundary", () => {
873
- const chunks = wordWrapLine("Lorem ipsum dolor sit amet, consectetur", 30);
874
-
875
- assert.strictEqual(chunks.length, 3);
876
- assert.strictEqual(chunks[0]!.text, "Lorem ipsum dolor sit ");
877
- assert.strictEqual(chunks[1]!.text, "amet, ");
878
- assert.strictEqual(chunks[2]!.text, "consectetur");
879
- });
880
-
881
- it("breaks long whitespace at line boundary 2", () => {
882
- const chunks = wordWrapLine("Lorem ipsum dolor sit amet, consectetur", 30);
883
-
884
- assert.strictEqual(chunks.length, 3);
885
- assert.strictEqual(chunks[0]!.text, "Lorem ipsum dolor sit ");
886
- assert.strictEqual(chunks[1]!.text, "amet, ");
887
- assert.strictEqual(chunks[2]!.text, " consectetur");
888
- });
889
-
890
- it("breaks whitespace spanning full lines", () => {
891
- const chunks = wordWrapLine("Lorem ipsum dolor sit amet, consectetur", 30);
892
-
893
- assert.strictEqual(chunks.length, 3);
894
- assert.strictEqual(chunks[0]!.text, "Lorem ipsum dolor sit ");
895
- assert.strictEqual(chunks[1]!.text, "amet, ");
896
- assert.strictEqual(chunks[2]!.text, " consectetur");
897
- });
898
-
899
- it("force-breaks when wide char after word boundary wrap still overflows", () => {
900
- // " " (1) + "a"*186 (186) + "你" (2) = 189 visible width
901
- // maxWidth = 187: backtracking to the space would leave 186 + 2 = 188 > 187,
902
- // so the algorithm must force-break before the wide char instead.
903
- const line = ` ${"a".repeat(186)}你`;
904
- const chunks = wordWrapLine(line, 187);
905
-
906
- for (const chunk of chunks) {
907
- assert.ok(
908
- visibleWidth(chunk.text) <= 187,
909
- `chunk "${chunk.text.slice(0, 20)}..." has visible width ${visibleWidth(chunk.text)}, expected <= 187`,
910
- );
911
- }
912
- // Verify no content is lost
913
- const reconstructed = chunks.map((c) => line.slice(c.startIndex, c.endIndex)).join("");
914
- assert.strictEqual(reconstructed, line);
915
- });
916
-
917
- it("splits oversized atomic segment across multiple chunks", () => {
918
- // Simulate a paste marker wider than maxWidth by passing pre-segmented data
919
- const marker = "[paste #1 +20 lines]"; // 21 chars
920
- const line = `A${marker}B`;
921
- const segments: Intl.SegmentData[] = [
922
- { segment: "A", index: 0, input: line },
923
- { segment: marker, index: 1, input: line },
924
- { segment: "B", index: 1 + marker.length, input: line },
925
- ];
926
-
927
- const chunks = wordWrapLine(line, 10, segments);
928
-
929
- // Every chunk must fit within maxWidth
930
- for (const chunk of chunks) {
931
- assert.ok(
932
- visibleWidth(chunk.text) <= 10,
933
- `chunk "${chunk.text}" has visible width ${visibleWidth(chunk.text)}, expected <= 10`,
934
- );
935
- }
936
-
937
- // Verify no content is lost
938
- const reconstructed = chunks.map((c) => line.slice(c.startIndex, c.endIndex)).join("");
939
- assert.strictEqual(reconstructed, line);
940
- });
941
-
942
- it("splits oversized atomic segment at start of line", () => {
943
- const marker = "[paste #1 +20 lines]"; // 21 chars
944
- const line = `${marker}B`;
945
- const segments: Intl.SegmentData[] = [
946
- { segment: marker, index: 0, input: line },
947
- { segment: "B", index: marker.length, input: line },
948
- ];
949
-
950
- const chunks = wordWrapLine(line, 10, segments);
951
-
952
- for (const chunk of chunks) {
953
- assert.ok(visibleWidth(chunk.text) <= 10);
954
- }
955
- // "B" ends up on the last line (either alone or with the marker tail)
956
- assert.strictEqual(chunks[chunks.length - 1]!.text.includes("B"), true);
957
-
958
- const reconstructed = chunks.map((c) => line.slice(c.startIndex, c.endIndex)).join("");
959
- assert.strictEqual(reconstructed, line);
960
- });
961
-
962
- it("splits oversized atomic segment at end of line", () => {
963
- const marker = "[paste #1 +20 lines]"; // 21 chars
964
- const line = `A${marker}`;
965
- const segments: Intl.SegmentData[] = [
966
- { segment: "A", index: 0, input: line },
967
- { segment: marker, index: 1, input: line },
968
- ];
969
-
970
- const chunks = wordWrapLine(line, 10, segments);
971
-
972
- for (const chunk of chunks) {
973
- assert.ok(visibleWidth(chunk.text) <= 10);
974
- }
975
- assert.strictEqual(chunks[0]!.text, "A");
976
-
977
- const reconstructed = chunks.map((c) => line.slice(c.startIndex, c.endIndex)).join("");
978
- assert.strictEqual(reconstructed, line);
979
- });
980
-
981
- it("splits consecutive oversized atomic segments", () => {
982
- const m1 = "[paste #1 +20 lines]"; // 21 chars
983
- const m2 = "[paste #2 +30 lines]"; // 21 chars
984
- const line = `${m1}${m2}`;
985
- const segments: Intl.SegmentData[] = [
986
- { segment: m1, index: 0, input: line },
987
- { segment: m2, index: m1.length, input: line },
988
- ];
989
-
990
- const chunks = wordWrapLine(line, 10, segments);
991
-
992
- for (const chunk of chunks) {
993
- assert.ok(
994
- visibleWidth(chunk.text) <= 10,
995
- `chunk "${chunk.text}" has visible width ${visibleWidth(chunk.text)}, expected <= 10`,
996
- );
997
- }
998
-
999
- const reconstructed = chunks.map((c) => line.slice(c.startIndex, c.endIndex)).join("");
1000
- assert.strictEqual(reconstructed, line);
1001
- });
1002
-
1003
- it("wraps normally after oversized atomic segment", () => {
1004
- const marker = "[paste #1 +20 lines]"; // 21 chars
1005
- const line = `${marker} hello world`;
1006
- const segments: Intl.SegmentData[] = [
1007
- { segment: marker, index: 0, input: line },
1008
- { segment: " ", index: marker.length, input: line },
1009
- { segment: "h", index: marker.length + 1, input: line },
1010
- { segment: "e", index: marker.length + 2, input: line },
1011
- { segment: "l", index: marker.length + 3, input: line },
1012
- { segment: "l", index: marker.length + 4, input: line },
1013
- { segment: "o", index: marker.length + 5, input: line },
1014
- { segment: " ", index: marker.length + 6, input: line },
1015
- { segment: "w", index: marker.length + 7, input: line },
1016
- { segment: "o", index: marker.length + 8, input: line },
1017
- { segment: "r", index: marker.length + 9, input: line },
1018
- { segment: "l", index: marker.length + 10, input: line },
1019
- { segment: "d", index: marker.length + 11, input: line },
1020
- ];
1021
-
1022
- const chunks = wordWrapLine(line, 10, segments);
1023
-
1024
- // All chunks must fit
1025
- for (const chunk of chunks) {
1026
- assert.ok(
1027
- visibleWidth(chunk.text) <= 10,
1028
- `chunk "${chunk.text}" has visible width ${visibleWidth(chunk.text)}, expected <= 10`,
1029
- );
1030
- }
1031
-
1032
- // Last chunk should contain "world" (normal wrapping resumes)
1033
- assert.strictEqual(chunks[chunks.length - 1]!.text, "world");
1034
-
1035
- const reconstructed = chunks.map((c) => line.slice(c.startIndex, c.endIndex)).join("");
1036
- assert.strictEqual(reconstructed, line);
1037
- });
1038
- });
1039
-
1040
- describe("Kill ring", () => {
1041
- it("Ctrl+W saves deleted text to kill ring and Ctrl+Y yanks it", () => {
1042
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1043
-
1044
- editor.setText("foo bar baz");
1045
- editor.handleInput("\x17"); // Ctrl+W - deletes "baz"
1046
- assert.strictEqual(editor.getText(), "foo bar ");
1047
-
1048
- // Move to beginning and yank
1049
- editor.handleInput("\x01"); // Ctrl+A
1050
- editor.handleInput("\x19"); // Ctrl+Y
1051
- assert.strictEqual(editor.getText(), "bazfoo bar ");
1052
- });
1053
-
1054
- it("Ctrl+U saves deleted text to kill ring", () => {
1055
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1056
-
1057
- editor.setText("hello world");
1058
- // Move cursor to middle
1059
- editor.handleInput("\x01"); // Ctrl+A (start)
1060
- editor.handleInput("\x1b[C"); // Right 5 times
1061
- editor.handleInput("\x1b[C");
1062
- editor.handleInput("\x1b[C");
1063
- editor.handleInput("\x1b[C");
1064
- editor.handleInput("\x1b[C");
1065
- editor.handleInput("\x1b[C"); // After "hello "
1066
-
1067
- editor.handleInput("\x15"); // Ctrl+U - deletes "hello "
1068
- assert.strictEqual(editor.getText(), "world");
1069
-
1070
- editor.handleInput("\x19"); // Ctrl+Y
1071
- assert.strictEqual(editor.getText(), "hello world");
1072
- });
1073
-
1074
- it("Ctrl+K saves deleted text to kill ring", () => {
1075
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1076
-
1077
- editor.setText("hello world");
1078
- editor.handleInput("\x01"); // Ctrl+A (start)
1079
- editor.handleInput("\x0b"); // Ctrl+K - deletes "hello world"
1080
-
1081
- assert.strictEqual(editor.getText(), "");
1082
-
1083
- editor.handleInput("\x19"); // Ctrl+Y
1084
- assert.strictEqual(editor.getText(), "hello world");
1085
- });
1086
-
1087
- it("Ctrl+Y does nothing when kill ring is empty", () => {
1088
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1089
-
1090
- editor.setText("test");
1091
- editor.handleInput("\x19"); // Ctrl+Y
1092
- assert.strictEqual(editor.getText(), "test");
1093
- });
1094
-
1095
- it("Alt+Y cycles through kill ring after Ctrl+Y", () => {
1096
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1097
-
1098
- // Create kill ring with multiple entries
1099
- editor.setText("first");
1100
- editor.handleInput("\x17"); // Ctrl+W - deletes "first"
1101
- editor.setText("second");
1102
- editor.handleInput("\x17"); // Ctrl+W - deletes "second"
1103
- editor.setText("third");
1104
- editor.handleInput("\x17"); // Ctrl+W - deletes "third"
1105
-
1106
- // Kill ring now has: [first, second, third]
1107
- assert.strictEqual(editor.getText(), "");
1108
-
1109
- editor.handleInput("\x19"); // Ctrl+Y - yanks "third" (most recent)
1110
- assert.strictEqual(editor.getText(), "third");
1111
-
1112
- editor.handleInput("\x1by"); // Alt+Y - cycles to "second"
1113
- assert.strictEqual(editor.getText(), "second");
1114
-
1115
- editor.handleInput("\x1by"); // Alt+Y - cycles to "first"
1116
- assert.strictEqual(editor.getText(), "first");
1117
-
1118
- editor.handleInput("\x1by"); // Alt+Y - cycles back to "third"
1119
- assert.strictEqual(editor.getText(), "third");
1120
- });
1121
-
1122
- it("Alt+Y does nothing if not preceded by yank", () => {
1123
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1124
-
1125
- editor.setText("test");
1126
- editor.handleInput("\x17"); // Ctrl+W - deletes "test"
1127
- editor.setText("other");
1128
-
1129
- // Type something to break the yank chain
1130
- editor.handleInput("x");
1131
- assert.strictEqual(editor.getText(), "otherx");
1132
-
1133
- // Alt+Y should do nothing
1134
- editor.handleInput("\x1by"); // Alt+Y
1135
- assert.strictEqual(editor.getText(), "otherx");
1136
- });
1137
-
1138
- it("Alt+Y does nothing if kill ring has ≤1 entry", () => {
1139
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1140
-
1141
- editor.setText("only");
1142
- editor.handleInput("\x17"); // Ctrl+W - deletes "only"
1143
-
1144
- editor.handleInput("\x19"); // Ctrl+Y - yanks "only"
1145
- assert.strictEqual(editor.getText(), "only");
1146
-
1147
- editor.handleInput("\x1by"); // Alt+Y - should do nothing (only 1 entry)
1148
- assert.strictEqual(editor.getText(), "only");
1149
- });
1150
-
1151
- it("consecutive Ctrl+W accumulates into one kill ring entry", () => {
1152
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1153
-
1154
- editor.setText("one two three");
1155
- editor.handleInput("\x17"); // Ctrl+W - deletes "three"
1156
- editor.handleInput("\x17"); // Ctrl+W - deletes "two " (prepended)
1157
- editor.handleInput("\x17"); // Ctrl+W - deletes "one " (prepended)
1158
-
1159
- assert.strictEqual(editor.getText(), "");
1160
-
1161
- // Should be one combined entry
1162
- editor.handleInput("\x19"); // Ctrl+Y
1163
- assert.strictEqual(editor.getText(), "one two three");
1164
- });
1165
-
1166
- it("Ctrl+U accumulates multiline deletes including newlines", () => {
1167
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1168
-
1169
- // Start with multiline text, cursor at end
1170
- editor.setText("line1\nline2\nline3");
1171
- // Cursor is at end of line3 (line 2, col 5)
1172
-
1173
- // Delete "line3"
1174
- editor.handleInput("\x15"); // Ctrl+U
1175
- assert.strictEqual(editor.getText(), "line1\nline2\n");
1176
-
1177
- // Delete newline (at start of empty line 2, merges with line1)
1178
- editor.handleInput("\x15"); // Ctrl+U
1179
- assert.strictEqual(editor.getText(), "line1\nline2");
1180
-
1181
- // Delete "line2"
1182
- editor.handleInput("\x15"); // Ctrl+U
1183
- assert.strictEqual(editor.getText(), "line1\n");
1184
-
1185
- // Delete newline
1186
- editor.handleInput("\x15"); // Ctrl+U
1187
- assert.strictEqual(editor.getText(), "line1");
1188
-
1189
- // Delete "line1"
1190
- editor.handleInput("\x15"); // Ctrl+U
1191
- assert.strictEqual(editor.getText(), "");
1192
-
1193
- // All deletions accumulated into one entry: "line1\nline2\nline3"
1194
- editor.handleInput("\x19"); // Ctrl+Y
1195
- assert.strictEqual(editor.getText(), "line1\nline2\nline3");
1196
- });
1197
-
1198
- it("backward deletions prepend, forward deletions append during accumulation", () => {
1199
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1200
-
1201
- editor.setText("prefix|suffix");
1202
- // Position cursor at |
1203
- editor.handleInput("\x01"); // Ctrl+A
1204
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C"); // Move right 6 times
1205
-
1206
- editor.handleInput("\x0b"); // Ctrl+K - deletes "suffix" (forward)
1207
- editor.handleInput("\x0b"); // Ctrl+K - deletes "|" (forward, appended)
1208
- assert.strictEqual(editor.getText(), "prefix");
1209
-
1210
- editor.handleInput("\x19"); // Ctrl+Y
1211
- assert.strictEqual(editor.getText(), "prefix|suffix");
1212
- });
1213
-
1214
- it("non-delete actions break kill accumulation", () => {
1215
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1216
-
1217
- // Delete "baz", then type "x" to break accumulation, then delete "x"
1218
- editor.setText("foo bar baz");
1219
- editor.handleInput("\x17"); // Ctrl+W - deletes "baz"
1220
- assert.strictEqual(editor.getText(), "foo bar ");
1221
-
1222
- editor.handleInput("x"); // Typing breaks accumulation
1223
- assert.strictEqual(editor.getText(), "foo bar x");
1224
-
1225
- editor.handleInput("\x17"); // Ctrl+W - deletes "x" (separate entry, not accumulated)
1226
- assert.strictEqual(editor.getText(), "foo bar ");
1227
-
1228
- // Yank most recent - should be "x", not "xbaz"
1229
- editor.handleInput("\x19"); // Ctrl+Y
1230
- assert.strictEqual(editor.getText(), "foo bar x");
1231
-
1232
- // Cycle to previous - should be "baz" (separate entry)
1233
- editor.handleInput("\x1by"); // Alt+Y
1234
- assert.strictEqual(editor.getText(), "foo bar baz");
1235
- });
1236
-
1237
- it("non-yank actions break Alt+Y chain", () => {
1238
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1239
-
1240
- editor.setText("first");
1241
- editor.handleInput("\x17"); // Ctrl+W
1242
- editor.setText("second");
1243
- editor.handleInput("\x17"); // Ctrl+W
1244
- editor.setText("");
1245
-
1246
- editor.handleInput("\x19"); // Ctrl+Y - yanks "second"
1247
- assert.strictEqual(editor.getText(), "second");
1248
-
1249
- editor.handleInput("x"); // Type breaks yank chain
1250
- assert.strictEqual(editor.getText(), "secondx");
1251
-
1252
- editor.handleInput("\x1by"); // Alt+Y - should do nothing
1253
- assert.strictEqual(editor.getText(), "secondx");
1254
- });
1255
-
1256
- it("kill ring rotation persists after cycling", () => {
1257
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1258
-
1259
- editor.setText("first");
1260
- editor.handleInput("\x17"); // deletes "first"
1261
- editor.setText("second");
1262
- editor.handleInput("\x17"); // deletes "second"
1263
- editor.setText("third");
1264
- editor.handleInput("\x17"); // deletes "third"
1265
- editor.setText("");
1266
-
1267
- // Ring: [first, second, third]
1268
-
1269
- editor.handleInput("\x19"); // Ctrl+Y - yanks "third"
1270
- editor.handleInput("\x1by"); // Alt+Y - cycles to "second", ring rotates
1271
-
1272
- // Now ring is: [third, first, second]
1273
- assert.strictEqual(editor.getText(), "second");
1274
-
1275
- // Do something else
1276
- editor.handleInput("x");
1277
- editor.setText("");
1278
-
1279
- // New yank should get "second" (now at end after rotation)
1280
- editor.handleInput("\x19"); // Ctrl+Y
1281
- assert.strictEqual(editor.getText(), "second");
1282
- });
1283
-
1284
- it("consecutive deletions across lines coalesce into one entry", () => {
1285
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1286
-
1287
- // "1\n2\n3" with cursor at end, delete everything with Ctrl+W
1288
- editor.setText("1\n2\n3");
1289
- editor.handleInput("\x17"); // Ctrl+W - deletes "3"
1290
- assert.strictEqual(editor.getText(), "1\n2\n");
1291
-
1292
- editor.handleInput("\x17"); // Ctrl+W - deletes newline (merge with prev line)
1293
- assert.strictEqual(editor.getText(), "1\n2");
1294
-
1295
- editor.handleInput("\x17"); // Ctrl+W - deletes "2"
1296
- assert.strictEqual(editor.getText(), "1\n");
1297
-
1298
- editor.handleInput("\x17"); // Ctrl+W - deletes newline
1299
- assert.strictEqual(editor.getText(), "1");
1300
-
1301
- editor.handleInput("\x17"); // Ctrl+W - deletes "1"
1302
- assert.strictEqual(editor.getText(), "");
1303
-
1304
- // All deletions should have accumulated into one entry
1305
- editor.handleInput("\x19"); // Ctrl+Y
1306
- assert.strictEqual(editor.getText(), "1\n2\n3");
1307
- });
1308
-
1309
- it("Ctrl+K at line end deletes newline and coalesces", () => {
1310
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1311
-
1312
- // "ab" on line 1, "cd" on line 2, cursor at end of line 1
1313
- editor.setText("");
1314
- editor.handleInput("a");
1315
- editor.handleInput("b");
1316
- editor.handleInput("\n");
1317
- editor.handleInput("c");
1318
- editor.handleInput("d");
1319
- // Move to end of first line
1320
- editor.handleInput("\x1b[A"); // Up arrow
1321
- editor.handleInput("\x05"); // Ctrl+E - end of line
1322
-
1323
- // Now at end of "ab", Ctrl+K should delete newline (merge with "cd")
1324
- editor.handleInput("\x0b"); // Ctrl+K - deletes newline
1325
- assert.strictEqual(editor.getText(), "abcd");
1326
-
1327
- // Continue deleting
1328
- editor.handleInput("\x0b"); // Ctrl+K - deletes "cd"
1329
- assert.strictEqual(editor.getText(), "ab");
1330
-
1331
- // Both deletions should accumulate
1332
- editor.handleInput("\x19"); // Ctrl+Y
1333
- assert.strictEqual(editor.getText(), "ab\ncd");
1334
- });
1335
-
1336
- it("handles yank in middle of text", () => {
1337
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1338
-
1339
- editor.setText("word");
1340
- editor.handleInput("\x17"); // Ctrl+W - deletes "word"
1341
- editor.setText("hello world");
1342
-
1343
- // Move to middle (after "hello ")
1344
- editor.handleInput("\x01"); // Ctrl+A
1345
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C");
1346
-
1347
- editor.handleInput("\x19"); // Ctrl+Y
1348
- assert.strictEqual(editor.getText(), "hello wordworld");
1349
- });
1350
-
1351
- it("handles yank-pop in middle of text", () => {
1352
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1353
-
1354
- // Create two kill ring entries
1355
- editor.setText("FIRST");
1356
- editor.handleInput("\x17"); // Ctrl+W - deletes "FIRST"
1357
- editor.setText("SECOND");
1358
- editor.handleInput("\x17"); // Ctrl+W - deletes "SECOND"
1359
-
1360
- // Ring: ["FIRST", "SECOND"]
1361
-
1362
- // Set up "hello world" and position cursor after "hello "
1363
- editor.setText("hello world");
1364
- editor.handleInput("\x01"); // Ctrl+A - go to start of line
1365
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C"); // Move right 6
1366
-
1367
- // Yank "SECOND" in the middle
1368
- editor.handleInput("\x19"); // Ctrl+Y
1369
- assert.strictEqual(editor.getText(), "hello SECONDworld");
1370
-
1371
- // Yank-pop replaces "SECOND" with "FIRST"
1372
- editor.handleInput("\x1by"); // Alt+Y
1373
- assert.strictEqual(editor.getText(), "hello FIRSTworld");
1374
- });
1375
-
1376
- it("multiline yank and yank-pop in middle of text", () => {
1377
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1378
-
1379
- // Create single-line entry
1380
- editor.setText("SINGLE");
1381
- editor.handleInput("\x17"); // Ctrl+W - deletes "SINGLE"
1382
-
1383
- // Create multiline entry via consecutive Ctrl+U
1384
- editor.setText("A\nB");
1385
- editor.handleInput("\x15"); // Ctrl+U - deletes "B"
1386
- editor.handleInput("\x15"); // Ctrl+U - deletes newline
1387
- editor.handleInput("\x15"); // Ctrl+U - deletes "A"
1388
- // Ring: ["SINGLE", "A\nB"]
1389
-
1390
- // Insert in middle of "hello world"
1391
- editor.setText("hello world");
1392
- editor.handleInput("\x01"); // Ctrl+A
1393
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C");
1394
-
1395
- // Yank multiline "A\nB"
1396
- editor.handleInput("\x19"); // Ctrl+Y
1397
- assert.strictEqual(editor.getText(), "hello A\nBworld");
1398
-
1399
- // Yank-pop replaces with "SINGLE"
1400
- editor.handleInput("\x1by"); // Alt+Y
1401
- assert.strictEqual(editor.getText(), "hello SINGLEworld");
1402
- });
1403
-
1404
- it("Alt+D deletes word forward and saves to kill ring", () => {
1405
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1406
-
1407
- editor.setText("hello world test");
1408
- editor.handleInput("\x01"); // Ctrl+A - go to start
1409
-
1410
- editor.handleInput("\x1bd"); // Alt+D - deletes "hello"
1411
- assert.strictEqual(editor.getText(), " world test");
1412
-
1413
- editor.handleInput("\x1bd"); // Alt+D - deletes " world" (skips whitespace, then word)
1414
- assert.strictEqual(editor.getText(), " test");
1415
-
1416
- // Yank should get accumulated text
1417
- editor.handleInput("\x19"); // Ctrl+Y
1418
- assert.strictEqual(editor.getText(), "hello world test");
1419
- });
1420
-
1421
- it("Alt+D at end of line deletes newline", () => {
1422
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1423
-
1424
- editor.setText("line1\nline2");
1425
- // Move to start of document, then to end of first line
1426
- editor.handleInput("\x1b[A"); // Up arrow - go to first line
1427
- editor.handleInput("\x05"); // Ctrl+E - end of line
1428
-
1429
- editor.handleInput("\x1bd"); // Alt+D - deletes newline (merges lines)
1430
- assert.strictEqual(editor.getText(), "line1line2");
1431
-
1432
- editor.handleInput("\x19"); // Ctrl+Y
1433
- assert.strictEqual(editor.getText(), "line1\nline2");
1434
- });
1435
- });
1436
-
1437
- describe("Undo", () => {
1438
- it("does nothing when undo stack is empty", () => {
1439
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1440
-
1441
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1442
- assert.strictEqual(editor.getText(), "");
1443
- });
1444
-
1445
- it("coalesces consecutive word characters into one undo unit", () => {
1446
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1447
-
1448
- editor.handleInput("h");
1449
- editor.handleInput("e");
1450
- editor.handleInput("l");
1451
- editor.handleInput("l");
1452
- editor.handleInput("o");
1453
- editor.handleInput(" ");
1454
- editor.handleInput("w");
1455
- editor.handleInput("o");
1456
- editor.handleInput("r");
1457
- editor.handleInput("l");
1458
- editor.handleInput("d");
1459
- assert.strictEqual(editor.getText(), "hello world");
1460
-
1461
- // Undo removes " world" (space captured state before it, so we restore to "hello")
1462
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1463
- assert.strictEqual(editor.getText(), "hello");
1464
-
1465
- // Undo removes "hello"
1466
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1467
- assert.strictEqual(editor.getText(), "");
1468
- });
1469
-
1470
- it("undoes spaces one at a time", () => {
1471
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1472
-
1473
- editor.handleInput("h");
1474
- editor.handleInput("e");
1475
- editor.handleInput("l");
1476
- editor.handleInput("l");
1477
- editor.handleInput("o");
1478
- editor.handleInput(" ");
1479
- editor.handleInput(" ");
1480
- assert.strictEqual(editor.getText(), "hello ");
1481
-
1482
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo) - removes second " "
1483
- assert.strictEqual(editor.getText(), "hello ");
1484
-
1485
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo) - removes first " "
1486
- assert.strictEqual(editor.getText(), "hello");
1487
-
1488
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo) - removes "hello"
1489
- assert.strictEqual(editor.getText(), "");
1490
- });
1491
-
1492
- it("undoes newlines and signals next word to capture state", () => {
1493
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1494
-
1495
- editor.handleInput("h");
1496
- editor.handleInput("e");
1497
- editor.handleInput("l");
1498
- editor.handleInput("l");
1499
- editor.handleInput("o");
1500
- editor.handleInput("\n");
1501
- editor.handleInput("w");
1502
- editor.handleInput("o");
1503
- editor.handleInput("r");
1504
- editor.handleInput("l");
1505
- editor.handleInput("d");
1506
- assert.strictEqual(editor.getText(), "hello\nworld");
1507
-
1508
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1509
- assert.strictEqual(editor.getText(), "hello\n");
1510
-
1511
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1512
- assert.strictEqual(editor.getText(), "hello");
1513
-
1514
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1515
- assert.strictEqual(editor.getText(), "");
1516
- });
1517
-
1518
- it("undoes backspace", () => {
1519
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1520
-
1521
- editor.handleInput("h");
1522
- editor.handleInput("e");
1523
- editor.handleInput("l");
1524
- editor.handleInput("l");
1525
- editor.handleInput("o");
1526
- editor.handleInput("\x7f"); // Backspace
1527
- assert.strictEqual(editor.getText(), "hell");
1528
-
1529
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1530
- assert.strictEqual(editor.getText(), "hello");
1531
- });
1532
-
1533
- it("undoes forward delete", () => {
1534
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1535
-
1536
- editor.handleInput("h");
1537
- editor.handleInput("e");
1538
- editor.handleInput("l");
1539
- editor.handleInput("l");
1540
- editor.handleInput("o");
1541
- editor.handleInput("\x01"); // Ctrl+A - go to start
1542
- editor.handleInput("\x1b[C"); // Right arrow
1543
- editor.handleInput("\x1b[3~"); // Delete key
1544
- assert.strictEqual(editor.getText(), "hllo");
1545
-
1546
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1547
- assert.strictEqual(editor.getText(), "hello");
1548
- });
1549
-
1550
- it("undoes Ctrl+W (delete word backward)", () => {
1551
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1552
-
1553
- editor.handleInput("h");
1554
- editor.handleInput("e");
1555
- editor.handleInput("l");
1556
- editor.handleInput("l");
1557
- editor.handleInput("o");
1558
- editor.handleInput(" ");
1559
- editor.handleInput("w");
1560
- editor.handleInput("o");
1561
- editor.handleInput("r");
1562
- editor.handleInput("l");
1563
- editor.handleInput("d");
1564
- assert.strictEqual(editor.getText(), "hello world");
1565
-
1566
- editor.handleInput("\x17"); // Ctrl+W
1567
- assert.strictEqual(editor.getText(), "hello ");
1568
-
1569
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1570
- assert.strictEqual(editor.getText(), "hello world");
1571
- });
1572
-
1573
- it("undoes Ctrl+K (delete to line end)", () => {
1574
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1575
-
1576
- editor.handleInput("h");
1577
- editor.handleInput("e");
1578
- editor.handleInput("l");
1579
- editor.handleInput("l");
1580
- editor.handleInput("o");
1581
- editor.handleInput(" ");
1582
- editor.handleInput("w");
1583
- editor.handleInput("o");
1584
- editor.handleInput("r");
1585
- editor.handleInput("l");
1586
- editor.handleInput("d");
1587
- editor.handleInput("\x01"); // Ctrl+A - go to start
1588
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C"); // Move right 6 times
1589
-
1590
- editor.handleInput("\x0b"); // Ctrl+K
1591
- assert.strictEqual(editor.getText(), "hello ");
1592
-
1593
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1594
- assert.strictEqual(editor.getText(), "hello world");
1595
-
1596
- editor.handleInput("|");
1597
- assert.strictEqual(editor.getText(), "hello |world");
1598
- });
1599
-
1600
- it("undoes Ctrl+U (delete to line start)", () => {
1601
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1602
-
1603
- editor.handleInput("h");
1604
- editor.handleInput("e");
1605
- editor.handleInput("l");
1606
- editor.handleInput("l");
1607
- editor.handleInput("o");
1608
- editor.handleInput(" ");
1609
- editor.handleInput("w");
1610
- editor.handleInput("o");
1611
- editor.handleInput("r");
1612
- editor.handleInput("l");
1613
- editor.handleInput("d");
1614
- editor.handleInput("\x01"); // Ctrl+A - go to start
1615
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C"); // Move right 6 times
1616
-
1617
- editor.handleInput("\x15"); // Ctrl+U
1618
- assert.strictEqual(editor.getText(), "world");
1619
-
1620
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1621
- assert.strictEqual(editor.getText(), "hello world");
1622
- });
1623
-
1624
- it("undoes yank", () => {
1625
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1626
-
1627
- editor.handleInput("h");
1628
- editor.handleInput("e");
1629
- editor.handleInput("l");
1630
- editor.handleInput("l");
1631
- editor.handleInput("o");
1632
- editor.handleInput(" ");
1633
- editor.handleInput("\x17"); // Ctrl+W - delete "hello "
1634
- editor.handleInput("\x19"); // Ctrl+Y - yank
1635
- assert.strictEqual(editor.getText(), "hello ");
1636
-
1637
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1638
- assert.strictEqual(editor.getText(), "");
1639
- });
1640
-
1641
- it("undoes single-line paste atomically", () => {
1642
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1643
-
1644
- editor.setText("hello world");
1645
- editor.handleInput("\x01"); // Ctrl+A - go to start
1646
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[C"); // Move right 5 (after "hello", before space)
1647
-
1648
- // Simulate bracketed paste of "beep boop"
1649
- editor.handleInput("\x1b[200~beep boop\x1b[201~");
1650
- assert.strictEqual(editor.getText(), "hellobeep boop world");
1651
-
1652
- // Single undo should restore entire pre-paste state
1653
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1654
- assert.strictEqual(editor.getText(), "hello world");
1655
-
1656
- editor.handleInput("|");
1657
- assert.strictEqual(editor.getText(), "hello| world");
1658
- });
1659
-
1660
- it("does not trigger autocomplete during single-line paste", () => {
1661
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1662
- let suggestionCalls = 0;
1663
-
1664
- const mockProvider: AutocompleteProvider = {
1665
- getSuggestions: async () => {
1666
- suggestionCalls += 1;
1667
- return null;
1668
- },
1669
- applyCompletion,
1670
- };
1671
-
1672
- editor.setAutocompleteProvider(mockProvider);
1673
- editor.handleInput("\x1b[200~look at @node_modules/react/index.js please\x1b[201~");
1674
-
1675
- assert.strictEqual(editor.getText(), "look at @node_modules/react/index.js please");
1676
- assert.strictEqual(suggestionCalls, 0);
1677
- assert.strictEqual(editor.isShowingAutocomplete(), false);
1678
- });
1679
-
1680
- it("undoes multi-line paste atomically", () => {
1681
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1682
-
1683
- editor.setText("hello world");
1684
- editor.handleInput("\x01"); // Ctrl+A - go to start
1685
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[C"); // Move right 5 (after "hello", before space)
1686
-
1687
- // Simulate bracketed paste of multi-line text
1688
- editor.handleInput("\x1b[200~line1\nline2\nline3\x1b[201~");
1689
- assert.strictEqual(editor.getText(), "helloline1\nline2\nline3 world");
1690
-
1691
- // Single undo should restore entire pre-paste state
1692
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1693
- assert.strictEqual(editor.getText(), "hello world");
1694
-
1695
- editor.handleInput("|");
1696
- assert.strictEqual(editor.getText(), "hello| world");
1697
- });
1698
-
1699
- it("undoes insertTextAtCursor atomically", () => {
1700
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1701
-
1702
- editor.setText("hello world");
1703
- editor.handleInput("\x01"); // Ctrl+A - go to start
1704
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[C"); // Move right 5 (after "hello", before space)
1705
-
1706
- // Programmatic insertion (e.g., clipboard image path)
1707
- editor.insertTextAtCursor("/tmp/image.png");
1708
- assert.strictEqual(editor.getText(), "hello/tmp/image.png world");
1709
-
1710
- // Single undo should restore entire pre-insert state
1711
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1712
- assert.strictEqual(editor.getText(), "hello world");
1713
-
1714
- editor.handleInput("|");
1715
- assert.strictEqual(editor.getText(), "hello| world");
1716
- });
1717
-
1718
- it("insertTextAtCursor handles multiline text", () => {
1719
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1720
-
1721
- editor.setText("hello world");
1722
- editor.handleInput("\x01"); // Ctrl+A - go to start
1723
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[C"); // Move right 5 (after "hello", before space)
1724
-
1725
- // Insert multiline text
1726
- editor.insertTextAtCursor("line1\nline2\nline3");
1727
- assert.strictEqual(editor.getText(), "helloline1\nline2\nline3 world");
1728
-
1729
- // Cursor should be at end of inserted text (after "line3", before " world")
1730
- const cursor = editor.getCursor();
1731
- assert.strictEqual(cursor.line, 2);
1732
- assert.strictEqual(cursor.col, 5); // "line3".length
1733
-
1734
- // Single undo should restore entire pre-insert state
1735
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1736
- assert.strictEqual(editor.getText(), "hello world");
1737
- });
1738
-
1739
- it("insertTextAtCursor normalizes CRLF and CR line endings", () => {
1740
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1741
-
1742
- editor.setText("");
1743
-
1744
- // Insert text with CRLF
1745
- editor.insertTextAtCursor("a\r\nb\r\nc");
1746
- assert.strictEqual(editor.getText(), "a\nb\nc");
1747
-
1748
- editor.handleInput("\x1b[45;5u"); // Undo
1749
- assert.strictEqual(editor.getText(), "");
1750
-
1751
- // Insert text with CR only
1752
- editor.insertTextAtCursor("x\ry\rz");
1753
- assert.strictEqual(editor.getText(), "x\ny\nz");
1754
- });
1755
-
1756
- it("undoes setText to empty string", () => {
1757
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1758
-
1759
- editor.handleInput("h");
1760
- editor.handleInput("e");
1761
- editor.handleInput("l");
1762
- editor.handleInput("l");
1763
- editor.handleInput("o");
1764
- editor.handleInput(" ");
1765
- editor.handleInput("w");
1766
- editor.handleInput("o");
1767
- editor.handleInput("r");
1768
- editor.handleInput("l");
1769
- editor.handleInput("d");
1770
- assert.strictEqual(editor.getText(), "hello world");
1771
-
1772
- editor.setText("");
1773
- assert.strictEqual(editor.getText(), "");
1774
-
1775
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1776
- assert.strictEqual(editor.getText(), "hello world");
1777
- });
1778
-
1779
- it("clears undo stack on submit", () => {
1780
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1781
- let submitted = "";
1782
- editor.onSubmit = (text) => {
1783
- submitted = text;
1784
- };
1785
-
1786
- editor.handleInput("h");
1787
- editor.handleInput("e");
1788
- editor.handleInput("l");
1789
- editor.handleInput("l");
1790
- editor.handleInput("o");
1791
- editor.handleInput("\r"); // Enter - submit
1792
-
1793
- assert.strictEqual(submitted, "hello");
1794
- assert.strictEqual(editor.getText(), "");
1795
-
1796
- // Undo should do nothing - stack was cleared
1797
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1798
- assert.strictEqual(editor.getText(), "");
1799
- });
1800
-
1801
- it("exits history browsing mode on undo", () => {
1802
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1803
-
1804
- // Add "hello" to history
1805
- editor.addToHistory("hello");
1806
- assert.strictEqual(editor.getText(), "");
1807
-
1808
- // Type "world"
1809
- editor.handleInput("w");
1810
- editor.handleInput("o");
1811
- editor.handleInput("r");
1812
- editor.handleInput("l");
1813
- editor.handleInput("d");
1814
- assert.strictEqual(editor.getText(), "world");
1815
-
1816
- // Ctrl+W - delete word
1817
- editor.handleInput("\x17"); // Ctrl+W
1818
- assert.strictEqual(editor.getText(), "");
1819
-
1820
- // Press Up - enter history browsing, shows "hello"
1821
- editor.handleInput("\x1b[A"); // Up arrow
1822
- assert.strictEqual(editor.getText(), "hello");
1823
-
1824
- // Undo should restore to "" (state before entering history browsing)
1825
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1826
- assert.strictEqual(editor.getText(), "");
1827
-
1828
- // Undo again should restore to "world" (state before Ctrl+W)
1829
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1830
- assert.strictEqual(editor.getText(), "world");
1831
- });
1832
-
1833
- it("undo restores to pre-history state even after multiple history navigations", () => {
1834
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1835
-
1836
- // Add history entries
1837
- editor.addToHistory("first");
1838
- editor.addToHistory("second");
1839
- editor.addToHistory("third");
1840
-
1841
- // Type something
1842
- editor.handleInput("c");
1843
- editor.handleInput("u");
1844
- editor.handleInput("r");
1845
- editor.handleInput("r");
1846
- editor.handleInput("e");
1847
- editor.handleInput("n");
1848
- editor.handleInput("t");
1849
- assert.strictEqual(editor.getText(), "current");
1850
-
1851
- // Clear editor
1852
- editor.handleInput("\x17"); // Ctrl+W
1853
- assert.strictEqual(editor.getText(), "");
1854
-
1855
- // Navigate through history multiple times
1856
- editor.handleInput("\x1b[A"); // Up - "third"
1857
- assert.strictEqual(editor.getText(), "third");
1858
- editor.handleInput("\x1b[A"); // Up - "second"
1859
- assert.strictEqual(editor.getText(), "second");
1860
- editor.handleInput("\x1b[A"); // Up - "first"
1861
- assert.strictEqual(editor.getText(), "first");
1862
-
1863
- // Undo should go back to "" (state before we started browsing), not intermediate states
1864
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1865
- assert.strictEqual(editor.getText(), "");
1866
-
1867
- // Another undo goes back to "current"
1868
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1869
- assert.strictEqual(editor.getText(), "current");
1870
- });
1871
-
1872
- it("cursor movement starts new undo unit", () => {
1873
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1874
-
1875
- editor.handleInput("h");
1876
- editor.handleInput("e");
1877
- editor.handleInput("l");
1878
- editor.handleInput("l");
1879
- editor.handleInput("o");
1880
- editor.handleInput(" ");
1881
- editor.handleInput("w");
1882
- editor.handleInput("o");
1883
- editor.handleInput("r");
1884
- editor.handleInput("l");
1885
- editor.handleInput("d");
1886
- assert.strictEqual(editor.getText(), "hello world");
1887
-
1888
- // Move cursor left 5 (to after "hello ")
1889
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[D");
1890
-
1891
- // Type "lol" in the middle
1892
- editor.handleInput("l");
1893
- editor.handleInput("o");
1894
- editor.handleInput("l");
1895
- assert.strictEqual(editor.getText(), "hello lolworld");
1896
-
1897
- // Undo should restore to "hello world" (before inserting "lol")
1898
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1899
- assert.strictEqual(editor.getText(), "hello world");
1900
-
1901
- editor.handleInput("|");
1902
- assert.strictEqual(editor.getText(), "hello |world");
1903
- });
1904
-
1905
- it("no-op delete operations do not push undo snapshots", () => {
1906
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1907
-
1908
- editor.handleInput("h");
1909
- editor.handleInput("e");
1910
- editor.handleInput("l");
1911
- editor.handleInput("l");
1912
- editor.handleInput("o");
1913
- assert.strictEqual(editor.getText(), "hello");
1914
-
1915
- // Delete word on empty - multiple times (should be no-ops)
1916
- editor.handleInput("\x17"); // Ctrl+W - deletes "hello"
1917
- assert.strictEqual(editor.getText(), "");
1918
- editor.handleInput("\x17"); // Ctrl+W - no-op (nothing to delete)
1919
- editor.handleInput("\x17"); // Ctrl+W - no-op
1920
-
1921
- // Single undo should restore "hello"
1922
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1923
- assert.strictEqual(editor.getText(), "hello");
1924
- });
1925
-
1926
- it("undoes autocomplete", async () => {
1927
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1928
-
1929
- // Create a mock autocomplete provider
1930
- const mockProvider: AutocompleteProvider = {
1931
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
1932
- const text = lines[0] || "";
1933
- const prefix = text.slice(0, cursorCol);
1934
- if (prefix === "di") {
1935
- return {
1936
- items: [{ value: "dist/", label: "dist/" }],
1937
- prefix: "di",
1938
- };
1939
- }
1940
- return null;
1941
- },
1942
- applyCompletion,
1943
- };
1944
-
1945
- editor.setAutocompleteProvider(mockProvider);
1946
-
1947
- // Type "di"
1948
- editor.handleInput("d");
1949
- editor.handleInput("i");
1950
- assert.strictEqual(editor.getText(), "di");
1951
-
1952
- // Press Tab to trigger autocomplete
1953
- editor.handleInput("\t");
1954
- await flushAutocomplete();
1955
- assert.strictEqual(editor.getText(), "dist/");
1956
- assert.strictEqual(editor.isShowingAutocomplete(), false);
1957
-
1958
- // Undo should restore to "di"
1959
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
1960
- assert.strictEqual(editor.getText(), "di");
1961
- });
1962
- });
1963
-
1964
- describe("Autocomplete", () => {
1965
- it("auto-applies single force-file suggestion without showing menu", async () => {
1966
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
1967
-
1968
- const mockProvider: AutocompleteProvider = {
1969
- getSuggestions: async (lines, _cursorLine, cursorCol, options) => {
1970
- if (!options.force) {
1971
- return null;
1972
- }
1973
- const text = lines[0] || "";
1974
- const prefix = text.slice(0, cursorCol);
1975
- if (prefix === "Work") {
1976
- return {
1977
- items: [{ value: "Workspace/", label: "Workspace/" }],
1978
- prefix: "Work",
1979
- };
1980
- }
1981
- return null;
1982
- },
1983
- applyCompletion,
1984
- };
1985
-
1986
- editor.setAutocompleteProvider(mockProvider);
1987
-
1988
- // Type "Work"
1989
- editor.handleInput("W");
1990
- editor.handleInput("o");
1991
- editor.handleInput("r");
1992
- editor.handleInput("k");
1993
- assert.strictEqual(editor.getText(), "Work");
1994
-
1995
- // Press Tab - should auto-apply without showing menu
1996
- editor.handleInput("\t");
1997
- await flushAutocomplete();
1998
- assert.strictEqual(editor.getText(), "Workspace/");
1999
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2000
-
2001
- // Undo should restore to "Work"
2002
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
2003
- assert.strictEqual(editor.getText(), "Work");
2004
- });
2005
-
2006
- it("shows menu when force-file has multiple suggestions", async () => {
2007
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2008
-
2009
- const mockProvider: AutocompleteProvider = {
2010
- getSuggestions: async (lines, _cursorLine, cursorCol, options) => {
2011
- if (!options.force) {
2012
- return null;
2013
- }
2014
- const text = lines[0] || "";
2015
- const prefix = text.slice(0, cursorCol);
2016
- if (prefix === "src") {
2017
- return {
2018
- items: [
2019
- { value: "src/", label: "src/" },
2020
- { value: "src.txt", label: "src.txt" },
2021
- ],
2022
- prefix: "src",
2023
- };
2024
- }
2025
- return null;
2026
- },
2027
- applyCompletion,
2028
- };
2029
-
2030
- editor.setAutocompleteProvider(mockProvider);
2031
-
2032
- // Type "src"
2033
- editor.handleInput("s");
2034
- editor.handleInput("r");
2035
- editor.handleInput("c");
2036
- assert.strictEqual(editor.getText(), "src");
2037
-
2038
- // Press Tab - should show menu because there are multiple suggestions
2039
- editor.handleInput("\t");
2040
- await flushAutocomplete();
2041
- assert.strictEqual(editor.getText(), "src");
2042
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2043
-
2044
- // Press Tab again to accept first suggestion
2045
- editor.handleInput("\t");
2046
- assert.strictEqual(editor.getText(), "src/");
2047
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2048
- });
2049
-
2050
- it("keeps suggestions open when typing in force mode (Tab-triggered)", async () => {
2051
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2052
-
2053
- const allFiles = [
2054
- { value: "readme.md", label: "readme.md" },
2055
- { value: "package.json", label: "package.json" },
2056
- { value: "src/", label: "src/" },
2057
- { value: "dist/", label: "dist/" },
2058
- ];
2059
-
2060
- const mockProvider: AutocompleteProvider = {
2061
- getSuggestions: async (lines, _cursorLine, cursorCol, options) => {
2062
- const text = lines[0] || "";
2063
- const prefix = text.slice(0, cursorCol);
2064
- const shouldMatch = options.force || prefix.includes("/") || prefix.startsWith(".");
2065
- if (!shouldMatch) {
2066
- return null;
2067
- }
2068
- const filtered = allFiles.filter((f) => f.value.toLowerCase().startsWith(prefix.toLowerCase()));
2069
- if (filtered.length > 0) {
2070
- return { items: filtered, prefix };
2071
- }
2072
- return null;
2073
- },
2074
- applyCompletion,
2075
- };
2076
-
2077
- editor.setAutocompleteProvider(mockProvider);
2078
-
2079
- // Press Tab on empty prompt - should show all files (force mode)
2080
- editor.handleInput("\t");
2081
- await flushAutocomplete();
2082
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2083
-
2084
- // Type "r" - should narrow to "readme.md" (force mode keeps suggestions open)
2085
- editor.handleInput("r");
2086
- await flushAutocomplete();
2087
- assert.strictEqual(editor.getText(), "r");
2088
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2089
-
2090
- // Type "e" - should still show "readme.md"
2091
- editor.handleInput("e");
2092
- await flushAutocomplete();
2093
- assert.strictEqual(editor.getText(), "re");
2094
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2095
-
2096
- // Accept with Tab
2097
- editor.handleInput("\t");
2098
- assert.strictEqual(editor.getText(), "readme.md");
2099
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2100
- });
2101
-
2102
- it("debounces @ autocomplete while typing", async () => {
2103
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2104
- let suggestionCalls = 0;
2105
-
2106
- const mockProvider: AutocompleteProvider = {
2107
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2108
- suggestionCalls += 1;
2109
- const text = (lines[0] || "").slice(0, cursorCol);
2110
- return {
2111
- items: [{ value: "@main.ts", label: "main.ts" }],
2112
- prefix: text,
2113
- };
2114
- },
2115
- applyCompletion,
2116
- };
2117
-
2118
- editor.setAutocompleteProvider(mockProvider);
2119
-
2120
- editor.handleInput("@");
2121
- editor.handleInput("m");
2122
- editor.handleInput("a");
2123
- editor.handleInput("i");
2124
-
2125
- assert.strictEqual(suggestionCalls, 0);
2126
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2127
-
2128
- await new Promise((resolve) => setTimeout(resolve, 50));
2129
- await flushAutocomplete();
2130
-
2131
- assert.strictEqual(suggestionCalls, 1);
2132
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2133
- });
2134
-
2135
- it("debounces # autocomplete while typing", async () => {
2136
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2137
- let suggestionCalls = 0;
2138
-
2139
- const mockProvider: AutocompleteProvider = {
2140
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2141
- suggestionCalls += 1;
2142
- const text = (lines[0] || "").slice(0, cursorCol);
2143
- return {
2144
- items: [{ value: "#2983", label: "#2983" }],
2145
- prefix: text,
2146
- };
2147
- },
2148
- applyCompletion,
2149
- };
2150
-
2151
- editor.setAutocompleteProvider(mockProvider);
2152
-
2153
- editor.handleInput("#");
2154
- editor.handleInput("2");
2155
- editor.handleInput("9");
2156
- editor.handleInput("8");
2157
-
2158
- assert.strictEqual(suggestionCalls, 0);
2159
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2160
-
2161
- await new Promise((resolve) => setTimeout(resolve, 50));
2162
- await flushAutocomplete();
2163
-
2164
- assert.strictEqual(suggestionCalls, 1);
2165
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2166
- });
2167
-
2168
- it("aborts active @ autocomplete when typing continues", async () => {
2169
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2170
- let aborts = 0;
2171
-
2172
- const mockProvider: AutocompleteProvider = {
2173
- getSuggestions: async (_lines, _cursorLine, _cursorCol, options) => {
2174
- return await new Promise((resolve) => {
2175
- const timeout = setTimeout(() => {
2176
- resolve({ items: [{ value: "@main.ts", label: "main.ts" }], prefix: "@main" });
2177
- }, 500);
2178
- options.signal.addEventListener(
2179
- "abort",
2180
- () => {
2181
- aborts += 1;
2182
- clearTimeout(timeout);
2183
- resolve(null);
2184
- },
2185
- { once: true },
2186
- );
2187
- });
2188
- },
2189
- applyCompletion,
2190
- };
2191
-
2192
- editor.setAutocompleteProvider(mockProvider);
2193
-
2194
- editor.handleInput("@");
2195
- editor.handleInput("m");
2196
- editor.handleInput("a");
2197
- editor.handleInput("i");
2198
- await new Promise((resolve) => setTimeout(resolve, 250));
2199
- editor.handleInput("n");
2200
- await new Promise((resolve) => setTimeout(resolve, 50));
2201
-
2202
- assert.strictEqual(aborts, 1);
2203
- });
2204
-
2205
- it("hides autocomplete when backspacing slash command to empty", async () => {
2206
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2207
-
2208
- // Mock provider with slash commands
2209
- const mockProvider: AutocompleteProvider = {
2210
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2211
- const text = lines[0] || "";
2212
- const prefix = text.slice(0, cursorCol);
2213
- // Only return slash command suggestions when line starts with /
2214
- if (prefix.startsWith("/")) {
2215
- const commands = [
2216
- { value: "/model", label: "model", description: "Change model" },
2217
- { value: "/help", label: "help", description: "Show help" },
2218
- ];
2219
- const query = prefix.slice(1); // Remove leading /
2220
- const filtered = commands.filter((c) => c.value.startsWith(query));
2221
- if (filtered.length > 0) {
2222
- return { items: filtered, prefix };
2223
- }
2224
- }
2225
- return null;
2226
- },
2227
- applyCompletion,
2228
- };
2229
-
2230
- editor.setAutocompleteProvider(mockProvider);
2231
-
2232
- // Type "/" - should show slash command suggestions
2233
- editor.handleInput("/");
2234
- await flushAutocomplete();
2235
- assert.strictEqual(editor.getText(), "/");
2236
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2237
-
2238
- // Backspace to delete "/" - should hide autocomplete completely
2239
- editor.handleInput("\x7f"); // Backspace
2240
- await flushAutocomplete();
2241
- assert.strictEqual(editor.getText(), "");
2242
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2243
- });
2244
-
2245
- it("applies exact typed slash-argument value on Enter even when first item is highlighted", async () => {
2246
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2247
-
2248
- // Mock provider for /argtest command with argument completions
2249
- const mockProvider: AutocompleteProvider = {
2250
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2251
- const text = lines[0] || "";
2252
- const beforeCursor = text.slice(0, cursorCol);
2253
-
2254
- // Check if we're in argument completion context: "/argtest <prefix>"
2255
- const argtestMatch = beforeCursor.match(/^\/argtest\s+(\S+)$/);
2256
- if (argtestMatch) {
2257
- const argumentText = argtestMatch[1]!;
2258
- const allArguments = [
2259
- { value: "one", label: "one" },
2260
- { value: "two", label: "two" },
2261
- { value: "three", label: "three" },
2262
- ];
2263
- // Return all arguments that start with the typed prefix
2264
- const filtered = allArguments.filter((arg) => arg.value.startsWith(argumentText));
2265
- if (filtered.length > 0) {
2266
- return { items: filtered, prefix: argumentText };
2267
- }
2268
- }
2269
- return null;
2270
- },
2271
- applyCompletion,
2272
- };
2273
-
2274
- editor.setAutocompleteProvider(mockProvider);
2275
-
2276
- // Type "/argtest two"
2277
- editor.handleInput("/");
2278
- editor.handleInput("a");
2279
- editor.handleInput("r");
2280
- editor.handleInput("g");
2281
- editor.handleInput("t");
2282
- editor.handleInput("e");
2283
- editor.handleInput("s");
2284
- editor.handleInput("t");
2285
- editor.handleInput(" ");
2286
- editor.handleInput("t");
2287
- editor.handleInput("w");
2288
- editor.handleInput("o");
2289
-
2290
- assert.strictEqual(editor.getText(), "/argtest two");
2291
- await flushAutocomplete();
2292
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2293
-
2294
- // Press Enter - should apply the exact typed value "two", not the first item
2295
- editor.handleInput("\r");
2296
-
2297
- // The exact typed value "two" should be retained
2298
- assert.strictEqual(editor.getText(), "/argtest two");
2299
- });
2300
-
2301
- it("selects first prefix match on Enter when typed arg is not exact match", async () => {
2302
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2303
-
2304
- // Mock provider for /argtest command with argument completions
2305
- const mockProvider: AutocompleteProvider = {
2306
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2307
- const text = lines[0] || "";
2308
- const beforeCursor = text.slice(0, cursorCol);
2309
-
2310
- // Check if we're in argument completion context
2311
- const argtestMatch = beforeCursor.match(/^\/argtest\s+(\S+)$/);
2312
- if (argtestMatch) {
2313
- const argumentText = argtestMatch[1]!;
2314
- const allArguments = [
2315
- { value: "two", label: "two" },
2316
- { value: "three", label: "three" },
2317
- { value: "twelve", label: "twelve" },
2318
- ];
2319
- // Return all items that start with the typed prefix
2320
- const filtered = allArguments.filter((arg) => arg.value.startsWith(argumentText));
2321
- if (filtered.length > 0) {
2322
- return { items: filtered, prefix: argumentText };
2323
- }
2324
- }
2325
- return null;
2326
- },
2327
- applyCompletion,
2328
- };
2329
-
2330
- editor.setAutocompleteProvider(mockProvider);
2331
-
2332
- // Type "/argtest t" - filtered to [two, three, twelve], prefix "t" matches "two" first
2333
- editor.handleInput("/");
2334
- editor.handleInput("a");
2335
- editor.handleInput("r");
2336
- editor.handleInput("g");
2337
- editor.handleInput("t");
2338
- editor.handleInput("e");
2339
- editor.handleInput("s");
2340
- editor.handleInput("t");
2341
- editor.handleInput(" ");
2342
- editor.handleInput("t");
2343
-
2344
- await flushAutocomplete();
2345
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2346
-
2347
- // Press Enter - "t" prefix matches "two" (first in list), so "two" is applied
2348
- editor.handleInput("\r");
2349
- assert.strictEqual(editor.getText(), "/argtest two");
2350
- });
2351
-
2352
- it("highlights unique prefix match as user types (before full exact match)", async () => {
2353
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2354
-
2355
- // Mock provider that returns all items unfiltered (like real extensions do)
2356
- const mockProvider: AutocompleteProvider = {
2357
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2358
- const text = lines[0] || "";
2359
- const beforeCursor = text.slice(0, cursorCol);
2360
-
2361
- const argtestMatch = beforeCursor.match(/^\/argtest\s+(\S+)$/);
2362
- if (argtestMatch) {
2363
- const argumentText = argtestMatch[1]!;
2364
- // Return all items - provider does not filter
2365
- const allArguments = [
2366
- { value: "one", label: "one" },
2367
- { value: "two", label: "two" },
2368
- { value: "three", label: "three" },
2369
- ];
2370
- return { items: allArguments, prefix: argumentText };
2371
- }
2372
- return null;
2373
- },
2374
- applyCompletion,
2375
- };
2376
-
2377
- editor.setAutocompleteProvider(mockProvider);
2378
-
2379
- // Type "/argtest tw" - "tw" is a prefix of only "two"
2380
- editor.handleInput("/");
2381
- editor.handleInput("a");
2382
- editor.handleInput("r");
2383
- editor.handleInput("g");
2384
- editor.handleInput("t");
2385
- editor.handleInput("e");
2386
- editor.handleInput("s");
2387
- editor.handleInput("t");
2388
- editor.handleInput(" ");
2389
- editor.handleInput("t");
2390
- editor.handleInput("w");
2391
-
2392
- assert.strictEqual(editor.getText(), "/argtest tw");
2393
- await flushAutocomplete();
2394
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2395
-
2396
- // Press Enter - "tw" uniquely matches "two", so "two" should be applied
2397
- editor.handleInput("\r");
2398
- assert.strictEqual(editor.getText(), "/argtest two");
2399
- });
2400
-
2401
- it("selects first prefix match when multiple items match", async () => {
2402
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2403
-
2404
- // Mock provider that returns all items unfiltered
2405
- const mockProvider: AutocompleteProvider = {
2406
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2407
- const text = lines[0] || "";
2408
- const beforeCursor = text.slice(0, cursorCol);
2409
-
2410
- const argtestMatch = beforeCursor.match(/^\/argtest\s+(\S+)$/);
2411
- if (argtestMatch) {
2412
- const argumentText = argtestMatch[1]!;
2413
- const allArguments = [
2414
- { value: "one", label: "one" },
2415
- { value: "two", label: "two" },
2416
- { value: "three", label: "three" },
2417
- ];
2418
- return { items: allArguments, prefix: argumentText };
2419
- }
2420
- return null;
2421
- },
2422
- applyCompletion,
2423
- };
2424
-
2425
- editor.setAutocompleteProvider(mockProvider);
2426
-
2427
- // Type "/argtest t" - "t" is a prefix of both "two" and "three"
2428
- editor.handleInput("/");
2429
- editor.handleInput("a");
2430
- editor.handleInput("r");
2431
- editor.handleInput("g");
2432
- editor.handleInput("t");
2433
- editor.handleInput("e");
2434
- editor.handleInput("s");
2435
- editor.handleInput("t");
2436
- editor.handleInput(" ");
2437
- editor.handleInput("t");
2438
-
2439
- await flushAutocomplete();
2440
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2441
-
2442
- // Press Enter - "t" matches "two" first, so "two" is selected
2443
- editor.handleInput("\r");
2444
- assert.strictEqual(editor.getText(), "/argtest two");
2445
- });
2446
-
2447
- it("works for built-in-style command argument completion path (model-like)", async () => {
2448
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2449
-
2450
- // Mock provider for /model command with model completions
2451
- const mockProvider: AutocompleteProvider = {
2452
- getSuggestions: async (lines, _cursorLine, cursorCol) => {
2453
- const text = lines[0] || "";
2454
- const beforeCursor = text.slice(0, cursorCol);
2455
-
2456
- // Check if we're in /model argument completion context
2457
- // Use [^ ]+ to match any non-space characters (including hyphens)
2458
- const modelMatch = beforeCursor.match(/^\/model\s+(\S+)$/);
2459
- if (modelMatch) {
2460
- const modelText = modelMatch[1]!;
2461
- const allModels = [
2462
- { value: "gpt-4o", label: "gpt-4o" },
2463
- { value: "gpt-4o-mini", label: "gpt-4o-mini" },
2464
- { value: "claude-sonnet", label: "claude-sonnet" },
2465
- ];
2466
- // Return all models that start with the typed prefix
2467
- const filtered = allModels.filter((m) => m.value.startsWith(modelText));
2468
- if (filtered.length > 0) {
2469
- return { items: filtered, prefix: modelText };
2470
- }
2471
- }
2472
- return null;
2473
- },
2474
- applyCompletion,
2475
- };
2476
-
2477
- editor.setAutocompleteProvider(mockProvider);
2478
-
2479
- // Type "/model gpt-4o-mini" - exact match for second item in list
2480
- editor.handleInput("/");
2481
- editor.handleInput("m");
2482
- editor.handleInput("o");
2483
- editor.handleInput("d");
2484
- editor.handleInput("e");
2485
- editor.handleInput("l");
2486
- editor.handleInput(" ");
2487
- editor.handleInput("g");
2488
- editor.handleInput("p");
2489
- editor.handleInput("t");
2490
- editor.handleInput("-");
2491
- editor.handleInput("4");
2492
- editor.handleInput("o");
2493
- editor.handleInput("-");
2494
- editor.handleInput("m");
2495
- editor.handleInput("i");
2496
- editor.handleInput("n");
2497
- editor.handleInput("i");
2498
-
2499
- assert.strictEqual(editor.getText(), "/model gpt-4o-mini");
2500
- await flushAutocomplete();
2501
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2502
-
2503
- // Press Enter - should retain exact typed value, not apply first highlighted item
2504
- editor.handleInput("\r");
2505
-
2506
- // The exact typed value should be retained
2507
- assert.strictEqual(editor.getText(), "/model gpt-4o-mini");
2508
- });
2509
-
2510
- it("awaits async slash command argument completions", async () => {
2511
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2512
- const provider = new CombinedAutocompleteProvider(
2513
- [
2514
- {
2515
- name: "load-skills",
2516
- description: "Load skills",
2517
- getArgumentCompletions: async (prefix) =>
2518
- prefix.startsWith("s") ? [{ value: "skill-a", label: "skill-a" }] : null,
2519
- },
2520
- ],
2521
- process.cwd(),
2522
- );
2523
- editor.setAutocompleteProvider(provider);
2524
- editor.setText("/load-skills ");
2525
-
2526
- editor.handleInput("s");
2527
- await flushAutocomplete();
2528
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2529
-
2530
- editor.handleInput("\t");
2531
- assert.strictEqual(editor.getText(), "/load-skills skill-a");
2532
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2533
- });
2534
-
2535
- it("ignores invalid slash command argument completion results", async () => {
2536
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2537
- const provider = new CombinedAutocompleteProvider(
2538
- [
2539
- {
2540
- name: "load-skills",
2541
- description: "Load skills",
2542
- getArgumentCompletions: (() => "not-an-array") as unknown as (
2543
- argumentPrefix: string,
2544
- ) => Promise<{ value: string; label: string }[] | null>,
2545
- },
2546
- ],
2547
- process.cwd(),
2548
- );
2549
- editor.setAutocompleteProvider(provider);
2550
- editor.setText("/load-skills ");
2551
-
2552
- editor.handleInput("s");
2553
- await flushAutocomplete();
2554
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2555
- assert.strictEqual(editor.getText(), "/load-skills s");
2556
- });
2557
-
2558
- it("does not show argument completions when command has no argument completer", async () => {
2559
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2560
- const provider = new CombinedAutocompleteProvider(
2561
- [
2562
- { name: "help", description: "Show help" },
2563
- {
2564
- name: "model",
2565
- description: "Switch model",
2566
- getArgumentCompletions: () => [{ value: "claude-opus", label: "claude-opus" }],
2567
- },
2568
- ],
2569
- process.cwd(),
2570
- );
2571
- editor.setAutocompleteProvider(provider);
2572
-
2573
- editor.handleInput("/");
2574
- editor.handleInput("h");
2575
- editor.handleInput("e");
2576
- await flushAutocomplete();
2577
- assert.strictEqual(editor.isShowingAutocomplete(), true);
2578
-
2579
- editor.handleInput("\t");
2580
- assert.strictEqual(editor.getText(), "/help ");
2581
- assert.strictEqual(editor.isShowingAutocomplete(), false);
2582
- });
2583
- });
2584
-
2585
- describe("Character jump (Ctrl+])", () => {
2586
- it("jumps forward to first occurrence of character on same line", () => {
2587
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2588
-
2589
- editor.setText("hello world");
2590
- editor.handleInput("\x01"); // Ctrl+A - go to start
2591
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2592
-
2593
- editor.handleInput("\x1d"); // Ctrl+] (legacy sequence for ctrl+])
2594
- editor.handleInput("o"); // Jump to first 'o'
2595
-
2596
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 4 }); // 'o' in "hello"
2597
- });
2598
-
2599
- it("jumps forward to next occurrence after cursor", () => {
2600
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2601
-
2602
- editor.setText("hello world");
2603
- editor.handleInput("\x01"); // Ctrl+A - go to start
2604
- // Move cursor to the 'o' in "hello" (col 4)
2605
- for (let i = 0; i < 4; i++) editor.handleInput("\x1b[C");
2606
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 4 });
2607
-
2608
- editor.handleInput("\x1d"); // Ctrl+]
2609
- editor.handleInput("o"); // Jump to next 'o' (in "world")
2610
-
2611
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 7 }); // 'o' in "world"
2612
- });
2613
-
2614
- it("jumps forward across multiple lines", () => {
2615
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2616
-
2617
- editor.setText("abc\ndef\nghi");
2618
- // Cursor is at end (line 2, col 3). Move to line 0 via up arrows, then Ctrl+A
2619
- editor.handleInput("\x1b[A"); // Up
2620
- editor.handleInput("\x1b[A"); // Up - now on line 0
2621
- editor.handleInput("\x01"); // Ctrl+A - go to start of line
2622
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2623
-
2624
- editor.handleInput("\x1d"); // Ctrl+]
2625
- editor.handleInput("g"); // Jump to 'g' on line 3
2626
-
2627
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 0 });
2628
- });
2629
-
2630
- it("jumps backward to first occurrence before cursor on same line", () => {
2631
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2632
-
2633
- editor.setText("hello world");
2634
- // Cursor at end (col 11)
2635
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 11 });
2636
-
2637
- editor.handleInput("\x1b\x1d"); // Ctrl+Alt+] (ESC followed by Ctrl+])
2638
- editor.handleInput("o"); // Jump to last 'o' before cursor
2639
-
2640
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 7 }); // 'o' in "world"
2641
- });
2642
-
2643
- it("jumps backward across multiple lines", () => {
2644
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2645
-
2646
- editor.setText("abc\ndef\nghi");
2647
- // Cursor at end of line 3
2648
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 3 });
2649
-
2650
- editor.handleInput("\x1b\x1d"); // Ctrl+Alt+]
2651
- editor.handleInput("a"); // Jump to 'a' on line 1
2652
-
2653
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2654
- });
2655
-
2656
- it("does nothing when character is not found (forward)", () => {
2657
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2658
-
2659
- editor.setText("hello world");
2660
- editor.handleInput("\x01"); // Ctrl+A - go to start
2661
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2662
-
2663
- editor.handleInput("\x1d"); // Ctrl+]
2664
- editor.handleInput("z"); // 'z' doesn't exist
2665
-
2666
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 }); // Cursor unchanged
2667
- });
2668
-
2669
- it("does nothing when character is not found (backward)", () => {
2670
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2671
-
2672
- editor.setText("hello world");
2673
- // Cursor at end
2674
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 11 });
2675
-
2676
- editor.handleInput("\x1b\x1d"); // Ctrl+Alt+]
2677
- editor.handleInput("z"); // 'z' doesn't exist
2678
-
2679
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 11 }); // Cursor unchanged
2680
- });
2681
-
2682
- it("is case-sensitive", () => {
2683
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2684
-
2685
- editor.setText("Hello World");
2686
- editor.handleInput("\x01"); // Ctrl+A - go to start
2687
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2688
-
2689
- // Search for lowercase 'h' - should not find it (only 'H' exists)
2690
- editor.handleInput("\x1d"); // Ctrl+]
2691
- editor.handleInput("h");
2692
-
2693
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 }); // Cursor unchanged
2694
-
2695
- // Search for uppercase 'W' - should find it
2696
- editor.handleInput("\x1d"); // Ctrl+]
2697
- editor.handleInput("W");
2698
-
2699
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 6 }); // 'W' in "World"
2700
- });
2701
-
2702
- it("cancels jump mode when Ctrl+] is pressed again", () => {
2703
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2704
-
2705
- editor.setText("hello world");
2706
- editor.handleInput("\x01"); // Ctrl+A - go to start
2707
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2708
-
2709
- editor.handleInput("\x1d"); // Ctrl+] - enter jump mode
2710
- editor.handleInput("\x1d"); // Ctrl+] again - cancel
2711
-
2712
- // Type 'o' normally - should insert, not jump
2713
- editor.handleInput("o");
2714
- assert.strictEqual(editor.getText(), "ohello world");
2715
- });
2716
-
2717
- it("cancels jump mode on Escape and processes the Escape", () => {
2718
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2719
-
2720
- editor.setText("hello world");
2721
- editor.handleInput("\x01"); // Ctrl+A - go to start
2722
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2723
-
2724
- editor.handleInput("\x1d"); // Ctrl+] - enter jump mode
2725
- editor.handleInput("\x1b"); // Escape - cancel jump mode
2726
-
2727
- // Cursor should be unchanged (Escape itself doesn't move cursor in editor)
2728
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2729
-
2730
- // Type 'o' normally - should insert, not jump
2731
- editor.handleInput("o");
2732
- assert.strictEqual(editor.getText(), "ohello world");
2733
- });
2734
-
2735
- it("cancels backward jump mode when Ctrl+Alt+] is pressed again", () => {
2736
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2737
-
2738
- editor.setText("hello world");
2739
- // Cursor at end
2740
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 11 });
2741
-
2742
- editor.handleInput("\x1b\x1d"); // Ctrl+Alt+] - enter backward jump mode
2743
- editor.handleInput("\x1b\x1d"); // Ctrl+Alt+] again - cancel
2744
-
2745
- // Type 'o' normally - should insert, not jump
2746
- editor.handleInput("o");
2747
- assert.strictEqual(editor.getText(), "hello worldo");
2748
- });
2749
-
2750
- it("searches for special characters", () => {
2751
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2752
-
2753
- editor.setText("foo(bar) = baz;");
2754
- editor.handleInput("\x01"); // Ctrl+A - go to start
2755
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2756
-
2757
- // Jump to '('
2758
- editor.handleInput("\x1d"); // Ctrl+]
2759
- editor.handleInput("(");
2760
-
2761
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
2762
-
2763
- // Jump to '='
2764
- editor.handleInput("\x1d"); // Ctrl+]
2765
- editor.handleInput("=");
2766
-
2767
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 9 });
2768
- });
2769
-
2770
- it("handles empty text gracefully", () => {
2771
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2772
-
2773
- editor.setText("");
2774
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2775
-
2776
- editor.handleInput("\x1d"); // Ctrl+]
2777
- editor.handleInput("x");
2778
-
2779
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 }); // Cursor unchanged
2780
- });
2781
-
2782
- it("resets lastAction when jumping", () => {
2783
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2784
-
2785
- editor.setText("hello world");
2786
- editor.handleInput("\x01"); // Ctrl+A - go to start
2787
-
2788
- // Type to set lastAction to "type-word"
2789
- editor.handleInput("x");
2790
- assert.strictEqual(editor.getText(), "xhello world");
2791
-
2792
- // Jump forward
2793
- editor.handleInput("\x1d"); // Ctrl+]
2794
- editor.handleInput("o");
2795
-
2796
- // Type more - should start a new undo unit (lastAction was reset)
2797
- editor.handleInput("Y");
2798
- assert.strictEqual(editor.getText(), "xhellYo world");
2799
-
2800
- // Undo should only undo "Y", not "x" as well
2801
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
2802
- assert.strictEqual(editor.getText(), "xhello world");
2803
- });
2804
- });
2805
-
2806
- describe("Sticky column", () => {
2807
- // Helper: position cursor at a specific line and column
2808
- function positionCursor(editor: Editor, line: number, col: number): void {
2809
- // Go to line 0 first
2810
- for (let i = 0; i < 20; i++) editor.handleInput("\x1b[A");
2811
- // Go to target line
2812
- for (let i = 0; i < line; i++) editor.handleInput("\x1b[B");
2813
- // Go to target col
2814
- editor.handleInput("\x01"); // Ctrl+A
2815
- for (let i = 0; i < col; i++) editor.handleInput("\x1b[C");
2816
- }
2817
-
2818
- it("preserves target column when moving up through a shorter line", () => {
2819
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2820
-
2821
- // Line 0: "2222222222x222" (x at col 10)
2822
- // Line 1: "" (empty)
2823
- // Line 2: "1111111111_111111111111" (_ at col 10)
2824
- editor.setText("2222222222x222\n\n1111111111_111111111111");
2825
-
2826
- // Position cursor on _ (line 2, col 10)
2827
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 23 }); // At end
2828
- editor.handleInput("\x01"); // Ctrl+A - go to start of line
2829
- for (let i = 0; i < 10; i++) editor.handleInput("\x1b[C"); // Move right to col 10
2830
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 10 });
2831
-
2832
- // Press Up - should move to empty line (col clamped to 0)
2833
- editor.handleInput("\x1b[A"); // Up arrow
2834
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 0 });
2835
-
2836
- // Press Up again - should move to line 0 at col 10 (on 'x')
2837
- editor.handleInput("\x1b[A"); // Up arrow
2838
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 });
2839
- });
2840
-
2841
- it("preserves target column when moving down through a shorter line", () => {
2842
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2843
-
2844
- editor.setText("1111111111_111\n\n2222222222x222222222222");
2845
-
2846
- // Position cursor on _ (line 0, col 10)
2847
- editor.handleInput("\x1b[A"); // Up to line 1
2848
- editor.handleInput("\x1b[A"); // Up to line 0
2849
- editor.handleInput("\x01"); // Ctrl+A
2850
- for (let i = 0; i < 10; i++) editor.handleInput("\x1b[C");
2851
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 });
2852
-
2853
- // Press Down - should move to empty line (col clamped to 0)
2854
- editor.handleInput("\x1b[B"); // Down arrow
2855
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 0 });
2856
-
2857
- // Press Down again - should move to line 2 at col 10 (on 'x')
2858
- editor.handleInput("\x1b[B"); // Down arrow
2859
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 10 });
2860
- });
2861
-
2862
- it("resets sticky column on horizontal movement (left arrow)", () => {
2863
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2864
-
2865
- editor.setText("1234567890\n\n1234567890");
2866
-
2867
- // Start at line 2, col 5
2868
- editor.handleInput("\x01"); // Ctrl+A
2869
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[C");
2870
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 5 });
2871
-
2872
- // Move up through empty line
2873
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
2874
- editor.handleInput("\x1b[A"); // Up - line 0, col 5 (sticky)
2875
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 5 });
2876
-
2877
- // Move left - resets sticky column
2878
- editor.handleInput("\x1b[D"); // Left
2879
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 4 });
2880
-
2881
- // Move down twice
2882
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
2883
- editor.handleInput("\x1b[B"); // Down - line 2, col 4 (new sticky from col 4)
2884
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 4 });
2885
- });
2886
-
2887
- it("resets sticky column on horizontal movement (right arrow)", () => {
2888
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2889
-
2890
- editor.setText("1234567890\n\n1234567890");
2891
-
2892
- // Start at line 0, col 5
2893
- editor.handleInput("\x1b[A"); // Up to line 1
2894
- editor.handleInput("\x1b[A"); // Up to line 0
2895
- editor.handleInput("\x01"); // Ctrl+A
2896
- for (let i = 0; i < 5; i++) editor.handleInput("\x1b[C");
2897
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 5 });
2898
-
2899
- // Move down through empty line
2900
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
2901
- editor.handleInput("\x1b[B"); // Down - line 2, col 5 (sticky)
2902
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 5 });
2903
-
2904
- // Move right - resets sticky column
2905
- editor.handleInput("\x1b[C"); // Right
2906
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 6 });
2907
-
2908
- // Move up twice
2909
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
2910
- editor.handleInput("\x1b[A"); // Up - line 0, col 6 (new sticky from col 6)
2911
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 6 });
2912
- });
2913
-
2914
- it("resets sticky column on typing", () => {
2915
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2916
-
2917
- editor.setText("1234567890\n\n1234567890");
2918
-
2919
- // Start at line 2, col 8
2920
- editor.handleInput("\x01"); // Ctrl+A
2921
- for (let i = 0; i < 8; i++) editor.handleInput("\x1b[C");
2922
-
2923
- // Move up through empty line
2924
- editor.handleInput("\x1b[A"); // Up
2925
- editor.handleInput("\x1b[A"); // Up - line 0, col 8
2926
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 8 });
2927
-
2928
- // Type a character - resets sticky column
2929
- editor.handleInput("X");
2930
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 9 });
2931
-
2932
- // Move down twice
2933
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
2934
- editor.handleInput("\x1b[B"); // Down - line 2, col 9 (new sticky from col 9)
2935
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 9 });
2936
- });
2937
-
2938
- it("resets sticky column on backspace", () => {
2939
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2940
-
2941
- editor.setText("1234567890\n\n1234567890");
2942
-
2943
- // Start at line 2, col 8
2944
- editor.handleInput("\x01"); // Ctrl+A
2945
- for (let i = 0; i < 8; i++) editor.handleInput("\x1b[C");
2946
-
2947
- // Move up through empty line
2948
- editor.handleInput("\x1b[A"); // Up
2949
- editor.handleInput("\x1b[A"); // Up - line 0, col 8
2950
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 8 });
2951
-
2952
- // Backspace - resets sticky column
2953
- editor.handleInput("\x7f"); // Backspace
2954
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 7 });
2955
-
2956
- // Move down twice
2957
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
2958
- editor.handleInput("\x1b[B"); // Down - line 2, col 7 (new sticky from col 7)
2959
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 7 });
2960
- });
2961
-
2962
- it("resets sticky column on Ctrl+A (move to line start)", () => {
2963
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2964
-
2965
- editor.setText("1234567890\n\n1234567890");
2966
-
2967
- // Start at line 2, col 8
2968
- editor.handleInput("\x01"); // Ctrl+A
2969
- for (let i = 0; i < 8; i++) editor.handleInput("\x1b[C");
2970
-
2971
- // Move up - establishes sticky col 8
2972
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
2973
-
2974
- // Ctrl+A - resets sticky column to 0
2975
- editor.handleInput("\x01"); // Ctrl+A
2976
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 0 });
2977
-
2978
- // Move up
2979
- editor.handleInput("\x1b[A"); // Up - line 0, col 0 (new sticky from col 0)
2980
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
2981
- });
2982
-
2983
- it("resets sticky column on Ctrl+E (move to line end)", () => {
2984
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
2985
-
2986
- editor.setText("12345\n\n1234567890");
2987
-
2988
- // Start at line 2, col 3
2989
- editor.handleInput("\x01"); // Ctrl+A
2990
- for (let i = 0; i < 3; i++) editor.handleInput("\x1b[C");
2991
-
2992
- // Move up through empty line - establishes sticky col 3
2993
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
2994
- editor.handleInput("\x1b[A"); // Up - line 0, col 3
2995
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
2996
-
2997
- // Ctrl+E - resets sticky column to end
2998
- editor.handleInput("\x05"); // Ctrl+E
2999
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 5 });
3000
-
3001
- // Move down twice
3002
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
3003
- editor.handleInput("\x1b[B"); // Down - line 2, col 5 (new sticky from col 5)
3004
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 5 });
3005
- });
3006
-
3007
- it("resets sticky column on word movement (Ctrl+Left)", () => {
3008
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3009
-
3010
- editor.setText("hello world\n\nhello world");
3011
-
3012
- // Start at end of line 2 (col 11)
3013
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 11 });
3014
-
3015
- // Move up through empty line - establishes sticky col 11
3016
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
3017
- editor.handleInput("\x1b[A"); // Up - line 0, col 11
3018
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 11 });
3019
-
3020
- // Ctrl+Left - word movement resets sticky column
3021
- editor.handleInput("\x1b[1;5D"); // Ctrl+Left
3022
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 6 }); // Before "world"
3023
-
3024
- // Move down twice
3025
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
3026
- editor.handleInput("\x1b[B"); // Down - line 2, col 6 (new sticky from col 6)
3027
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 6 });
3028
- });
3029
-
3030
- it("resets sticky column on word movement (Ctrl+Right)", () => {
3031
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3032
-
3033
- editor.setText("hello world\n\nhello world");
3034
-
3035
- // Start at line 0, col 0
3036
- editor.handleInput("\x1b[A"); // Up
3037
- editor.handleInput("\x1b[A"); // Up
3038
- editor.handleInput("\x01"); // Ctrl+A
3039
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
3040
-
3041
- // Move down through empty line - establishes sticky col 0
3042
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
3043
- editor.handleInput("\x1b[B"); // Down - line 2, col 0
3044
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 0 });
3045
-
3046
- // Ctrl+Right - word movement resets sticky column
3047
- editor.handleInput("\x1b[1;5C"); // Ctrl+Right
3048
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 5 }); // After "hello"
3049
-
3050
- // Move up twice
3051
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
3052
- editor.handleInput("\x1b[A"); // Up - line 0, col 5 (new sticky from col 5)
3053
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 5 });
3054
- });
3055
-
3056
- it("resets sticky column on undo", () => {
3057
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3058
-
3059
- editor.setText("1234567890\n\n1234567890");
3060
-
3061
- // Go to line 0, col 8
3062
- editor.handleInput("\x1b[A"); // Up to line 1
3063
- editor.handleInput("\x1b[A"); // Up to line 0
3064
- editor.handleInput("\x01"); // Ctrl+A
3065
- for (let i = 0; i < 8; i++) editor.handleInput("\x1b[C");
3066
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 8 });
3067
-
3068
- // Move down through empty line - establishes sticky col 8
3069
- editor.handleInput("\x1b[B"); // Down - line 1, col 0
3070
- editor.handleInput("\x1b[B"); // Down - line 2, col 8 (sticky)
3071
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 8 });
3072
-
3073
- // Type something to create undo state - this clears sticky and sets col to 9
3074
- editor.handleInput("X");
3075
- assert.strictEqual(editor.getText(), "1234567890\n\n12345678X90");
3076
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 9 });
3077
-
3078
- // Move up - establishes new sticky col 9
3079
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
3080
- editor.handleInput("\x1b[A"); // Up - line 0, col 9
3081
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 9 });
3082
-
3083
- // Undo - resets sticky column and restores cursor to line 2, col 8
3084
- editor.handleInput("\x1b[45;5u"); // Ctrl+- (undo)
3085
- assert.strictEqual(editor.getText(), "1234567890\n\n1234567890");
3086
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 8 });
3087
-
3088
- // Move up - should capture new sticky from restored col 8, not old col 9
3089
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
3090
- editor.handleInput("\x1b[A"); // Up - line 0, col 8 (new sticky from restored position)
3091
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 8 });
3092
- });
3093
-
3094
- it("handles multiple consecutive up/down movements", () => {
3095
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3096
-
3097
- editor.setText("1234567890\nab\ncd\nef\n1234567890");
3098
-
3099
- // Start at line 4, col 7
3100
- editor.handleInput("\x01"); // Ctrl+A
3101
- for (let i = 0; i < 7; i++) editor.handleInput("\x1b[C");
3102
- assert.deepStrictEqual(editor.getCursor(), { line: 4, col: 7 });
3103
-
3104
- // Move up multiple times through short lines
3105
- editor.handleInput("\x1b[A"); // Up - line 3, col 2 (clamped)
3106
- editor.handleInput("\x1b[A"); // Up - line 2, col 2 (clamped)
3107
- editor.handleInput("\x1b[A"); // Up - line 1, col 2 (clamped)
3108
- editor.handleInput("\x1b[A"); // Up - line 0, col 7 (restored)
3109
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 7 });
3110
-
3111
- // Move down multiple times - sticky should still be 7
3112
- editor.handleInput("\x1b[B"); // Down - line 1, col 2
3113
- editor.handleInput("\x1b[B"); // Down - line 2, col 2
3114
- editor.handleInput("\x1b[B"); // Down - line 3, col 2
3115
- editor.handleInput("\x1b[B"); // Down - line 4, col 7 (restored)
3116
- assert.deepStrictEqual(editor.getCursor(), { line: 4, col: 7 });
3117
- });
3118
-
3119
- it("moves correctly through wrapped visual lines without getting stuck", () => {
3120
- const tui = createTestTUI(15, 24); // Narrow terminal
3121
- const editor = new Editor(tui, defaultEditorTheme);
3122
-
3123
- // Line 0: short
3124
- // Line 1: 30 chars = wraps to 3 visual lines at width 10 (after padding)
3125
- editor.setText("short\n123456789012345678901234567890");
3126
- editor.render(15); // This gives 14 layout width
3127
-
3128
- // Position at end of line 1 (col 30)
3129
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 30 });
3130
-
3131
- // Move up repeatedly - should traverse all visual lines of the wrapped text
3132
- // and eventually reach line 0
3133
- editor.handleInput("\x1b[A"); // Up - to previous visual line within line 1
3134
- assert.strictEqual(editor.getCursor().line, 1);
3135
-
3136
- editor.handleInput("\x1b[A"); // Up - another visual line
3137
- assert.strictEqual(editor.getCursor().line, 1);
3138
-
3139
- editor.handleInput("\x1b[A"); // Up - should reach line 0
3140
- assert.strictEqual(editor.getCursor().line, 0);
3141
- });
3142
-
3143
- it("handles setText resetting sticky column", () => {
3144
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3145
-
3146
- editor.setText("1234567890\n\n1234567890");
3147
-
3148
- // Establish sticky column
3149
- editor.handleInput("\x01"); // Ctrl+A
3150
- for (let i = 0; i < 8; i++) editor.handleInput("\x1b[C");
3151
- editor.handleInput("\x1b[A"); // Up
3152
-
3153
- // setText should reset sticky column
3154
- editor.setText("abcdefghij\n\nabcdefghij");
3155
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 10 }); // At end
3156
-
3157
- // Move up - should capture new sticky from current position (10)
3158
- editor.handleInput("\x1b[A"); // Up - line 1, col 0
3159
- editor.handleInput("\x1b[A"); // Up - line 0, col 10
3160
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 });
3161
- });
3162
-
3163
- it("sets preferredVisualCol when pressing right at end of prompt (last line)", () => {
3164
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3165
-
3166
- // Line 0: 20 chars with 'x' at col 10
3167
- // Line 1: empty
3168
- // Line 2: 10 chars ending with '_'
3169
- editor.setText("111111111x1111111111\n\n333333333_");
3170
-
3171
- // Go to line 0, press Ctrl+E (end of line) - col 20
3172
- editor.handleInput("\x1b[A"); // Up to line 1
3173
- editor.handleInput("\x1b[A"); // Up to line 0
3174
- editor.handleInput("\x05"); // Ctrl+E - move to end of line
3175
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 20 });
3176
-
3177
- // Move down to line 2 - cursor clamped to col 10 (end of line)
3178
- editor.handleInput("\x1b[B"); // Down to line 1, col 0
3179
- editor.handleInput("\x1b[B"); // Down to line 2, col 10 (clamped)
3180
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 10 });
3181
-
3182
- // Press Right at end of prompt - nothing visible happens, but sets preferredVisualCol to 10
3183
- editor.handleInput("\x1b[C"); // Right - can't move, but sets preferredVisualCol
3184
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 10 }); // Still at same position
3185
-
3186
- // Move up twice to line 0 - should use preferredVisualCol (10) to land on 'x'
3187
- editor.handleInput("\x1b[A"); // Up to line 1, col 0
3188
- editor.handleInput("\x1b[A"); // Up to line 0, col 10 (on 'x')
3189
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 });
3190
- });
3191
-
3192
- it("handles editor resizes when preferredVisualCol is on the same line", () => {
3193
- // Create editor with wider terminal
3194
- const tui = createTestTUI(80, 24);
3195
- const editor = new Editor(tui, defaultEditorTheme);
3196
-
3197
- editor.setText("12345678901234567890\n\n12345678901234567890");
3198
-
3199
- // Start at line 2, col 15
3200
- editor.handleInput("\x01"); // Ctrl+A
3201
- for (let i = 0; i < 15; i++) editor.handleInput("\x1b[C");
3202
-
3203
- // Move up through empty line - establishes sticky col 15
3204
- editor.handleInput("\x1b[A"); // Up
3205
- editor.handleInput("\x1b[A"); // Up - line 0, col 15
3206
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 15 });
3207
-
3208
- // Render with narrower width to simulate resize
3209
- editor.render(12); // Width 12
3210
-
3211
- // Move down - sticky should be clamped to new width
3212
- editor.handleInput("\x1b[B"); // Down - line 1
3213
- editor.handleInput("\x1b[B"); // Down - line 2, col should be clamped
3214
- assert.equal(editor.getCursor().col, 4);
3215
- });
3216
-
3217
- it("handles editor resizes when preferredVisualCol is on a different line", () => {
3218
- const tui = createTestTUI(80, 24);
3219
- const editor = new Editor(tui, defaultEditorTheme);
3220
-
3221
- // Create a line that wraps into multiple visual lines at width 10
3222
- // "12345678901234567890" = 20 chars, wraps to 2 visual lines at width 10
3223
- editor.setText("short\n12345678901234567890");
3224
-
3225
- // Go to line 1, col 15
3226
- editor.handleInput("\x01"); // Ctrl+A
3227
- for (let i = 0; i < 15; i++) editor.handleInput("\x1b[C");
3228
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 15 });
3229
-
3230
- // Move up to establish sticky col 15
3231
- editor.handleInput("\x1b[A"); // Up to line 0
3232
- // Line 0 has only 5 chars, so cursor at col 5
3233
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 5 });
3234
-
3235
- // Narrow the editor
3236
- editor.render(10);
3237
-
3238
- // Move down - preferredVisualCol was 15, but width is 10
3239
- // Should land on line 1, clamped to width (visual col 9, which is logical col 9)
3240
- editor.handleInput("\x1b[B"); // Down to line 1
3241
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 8 });
3242
-
3243
- // Move up
3244
- editor.handleInput("\x1b[A"); // Up - should go to line 0
3245
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 5 }); // Line 0 only has 5 chars
3246
-
3247
- // Restore the original width
3248
- editor.render(80);
3249
-
3250
- // Move down - preferredVisualCol was kept at 15
3251
- editor.handleInput("\x1b[B"); // Down to line 1
3252
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 15 });
3253
- });
3254
-
3255
- it("rewrapped lines: target fits current visual column", () => {
3256
- const tui = createTestTUI(80, 24);
3257
- const editor = new Editor(tui, defaultEditorTheme);
3258
- editor.setText("abcdefghijklmnopqr\n123456789012345678");
3259
-
3260
- positionCursor(editor, 0, 18);
3261
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 18 });
3262
-
3263
- // Narrow to width 10 (layoutWidth = 9).
3264
- // Line 0 last segment has visual col max 9, line 1 first segment max 8
3265
- editor.render(10);
3266
-
3267
- // Move down: cursor clamps to 8
3268
- editor.handleInput("\x1b[B");
3269
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 8 });
3270
-
3271
- // Widen back. Move up, the current visual col wins
3272
- editor.render(80);
3273
- editor.handleInput("\x1b[A");
3274
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 8 });
3275
-
3276
- // Preferred was cleared by the rewrapped branch
3277
- editor.handleInput("\x1b[B");
3278
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 8 });
3279
- });
3280
-
3281
- it("rewrapped lines: target shorter than current visual column", () => {
3282
- const tui = createTestTUI(80, 24);
3283
- const editor = new Editor(tui, defaultEditorTheme);
3284
- editor.setText("abcdefghijklmnopqr\n123456789012345678\nab");
3285
-
3286
- positionCursor(editor, 0, 18);
3287
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 18 });
3288
-
3289
- // Narrow to width 10 (layoutWidth = 9). Moving down clamps to col 8
3290
- editor.render(10);
3291
- editor.handleInput("\x1b[B");
3292
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 8 });
3293
-
3294
- // Widen the editor
3295
- editor.render(80);
3296
-
3297
- // Move down to short line "ab".
3298
- // preferredVisualCol is replaced with current visual col (8), cursor clamps to 2
3299
- editor.handleInput("\x1b[B");
3300
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 2 });
3301
-
3302
- // Moving up restores to preferred col 8
3303
- editor.handleInput("\x1b[A");
3304
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 8 });
3305
- });
3306
- });
3307
-
3308
- describe("Paste marker atomic behavior", () => {
3309
- /** Helper: simulate a large paste that creates a marker */
3310
- function pasteWithMarker(editor: Editor): string {
3311
- const bigContent = "line\n".repeat(20).trimEnd(); // 20 lines
3312
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3313
- // The editor replaces large pastes with a marker like "[paste #1 +20 lines]"
3314
- return editor.getText();
3315
- }
3316
-
3317
- it("creates a paste marker for large pastes", () => {
3318
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3319
- const text = pasteWithMarker(editor);
3320
- assert.match(text, /\[paste #\d+ \+\d+ lines\]/);
3321
- });
3322
-
3323
- it("treats paste marker as single unit for right arrow", () => {
3324
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3325
- editor.handleInput("A");
3326
- pasteWithMarker(editor);
3327
- editor.handleInput("B");
3328
- // Text: "A[paste #1 +20 lines]B", cursor at end
3329
-
3330
- // Go to start
3331
- editor.handleInput("\x01"); // Ctrl+A
3332
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
3333
-
3334
- // Right arrow: should move past "A"
3335
- editor.handleInput("\x1b[C");
3336
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 });
3337
-
3338
- // Right arrow: should skip the entire marker
3339
- editor.handleInput("\x1b[C");
3340
- const marker = editor.getText().match(/\[paste #\d+ \+\d+ lines\]/)![0];
3341
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 + marker.length });
3342
-
3343
- // Right arrow: should move past "B"
3344
- editor.handleInput("\x1b[C");
3345
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 + marker.length + 1 });
3346
- });
3347
-
3348
- it("treats paste marker as single unit for left arrow", () => {
3349
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3350
- editor.handleInput("A");
3351
- pasteWithMarker(editor);
3352
- editor.handleInput("B");
3353
- // Cursor at end
3354
-
3355
- // Left arrow: past "B"
3356
- editor.handleInput("\x1b[D");
3357
- const text = editor.getText();
3358
- const marker = text.match(/\[paste #\d+ \+\d+ lines\]/)![0];
3359
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 + marker.length });
3360
-
3361
- // Left arrow: skip the entire marker
3362
- editor.handleInput("\x1b[D");
3363
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 });
3364
-
3365
- // Left arrow: past "A"
3366
- editor.handleInput("\x1b[D");
3367
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
3368
- });
3369
-
3370
- it("treats paste marker as single unit for backspace", () => {
3371
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3372
- editor.handleInput("A");
3373
- pasteWithMarker(editor);
3374
- editor.handleInput("B");
3375
-
3376
- const text = editor.getText();
3377
- const marker = text.match(/\[paste #\d+ \+\d+ lines\]/)![0];
3378
-
3379
- // Position cursor right after the marker (before "B")
3380
- editor.handleInput("\x01"); // Ctrl+A
3381
- // Move past "A" and the marker
3382
- editor.handleInput("\x1b[C"); // past "A"
3383
- editor.handleInput("\x1b[C"); // past marker
3384
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 + marker.length });
3385
-
3386
- // Backspace: should delete the entire marker at once
3387
- editor.handleInput("\x7f");
3388
- assert.strictEqual(editor.getText(), "AB");
3389
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 });
3390
- });
3391
-
3392
- it("treats paste marker as single unit for forward delete", () => {
3393
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3394
- editor.handleInput("A");
3395
- pasteWithMarker(editor);
3396
- editor.handleInput("B");
3397
-
3398
- // Position cursor on "A" (col 0) then move right once to be just before marker
3399
- editor.handleInput("\x01"); // Ctrl+A
3400
- editor.handleInput("\x1b[C"); // past "A", now at col 1 (start of marker)
3401
-
3402
- // Forward delete: should delete the entire marker at once
3403
- editor.handleInput("\x1b[3~"); // Delete key
3404
- assert.strictEqual(editor.getText(), "AB");
3405
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 });
3406
- });
3407
-
3408
- it("treats paste marker as single unit for word movement", () => {
3409
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3410
- editor.handleInput("X");
3411
- editor.handleInput(" ");
3412
- pasteWithMarker(editor);
3413
- editor.handleInput(" ");
3414
- editor.handleInput("Y");
3415
- // Text: "X [paste #1 +20 lines] Y"
3416
-
3417
- const text = editor.getText();
3418
- const marker = text.match(/\[paste #\d+ \+\d+ lines\]/)![0];
3419
-
3420
- // Go to start
3421
- editor.handleInput("\x01"); // Ctrl+A
3422
-
3423
- // Ctrl+Right: skip "X"
3424
- editor.handleInput("\x1b[1;5C");
3425
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 });
3426
-
3427
- // Ctrl+Right: skip whitespace + marker (marker treated as single non-ws, non-punct unit)
3428
- editor.handleInput("\x1b[1;5C");
3429
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 2 + marker.length });
3430
- });
3431
-
3432
- it("undo restores marker after backspace deletion", () => {
3433
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3434
- editor.handleInput("A");
3435
- pasteWithMarker(editor);
3436
- editor.handleInput("B");
3437
-
3438
- const textBefore = editor.getText();
3439
-
3440
- // Position after marker
3441
- editor.handleInput("\x01");
3442
- editor.handleInput("\x1b[C"); // past A
3443
- editor.handleInput("\x1b[C"); // past marker
3444
-
3445
- // Delete marker
3446
- editor.handleInput("\x7f");
3447
- assert.strictEqual(editor.getText(), "AB");
3448
-
3449
- // Undo
3450
- editor.handleInput("\x1b[45;5u");
3451
- assert.strictEqual(editor.getText(), textBefore);
3452
- });
3453
-
3454
- it("handles multiple paste markers in same line", () => {
3455
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3456
- pasteWithMarker(editor);
3457
- editor.handleInput(" ");
3458
- pasteWithMarker(editor);
3459
-
3460
- const text = editor.getText();
3461
- const markers = [...text.matchAll(/\[paste #\d+ \+\d+ lines\]/g)];
3462
- assert.strictEqual(markers.length, 2);
3463
-
3464
- // Go to start
3465
- editor.handleInput("\x01");
3466
-
3467
- // Right arrow: should skip first marker atomically
3468
- editor.handleInput("\x1b[C");
3469
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: markers[0]![0].length });
3470
-
3471
- // Right arrow: past space
3472
- editor.handleInput("\x1b[C");
3473
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: markers[0]![0].length + 1 });
3474
-
3475
- // Right arrow: should skip second marker atomically
3476
- editor.handleInput("\x1b[C");
3477
- assert.deepStrictEqual(editor.getCursor(), {
3478
- line: 0,
3479
- col: markers[0]![0].length + 1 + markers[1]![0].length,
3480
- });
3481
- });
3482
-
3483
- it("does not treat manually typed marker-like text as atomic (no valid paste ID)", () => {
3484
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3485
- // Type text that matches the pattern but was typed manually (no paste entry)
3486
- const fakeMarker = "[paste #99 +5 lines]";
3487
- for (const ch of fakeMarker) editor.handleInput(ch);
3488
-
3489
- assert.strictEqual(editor.getText(), fakeMarker);
3490
-
3491
- // No paste with ID 99 exists, so the marker is NOT treated atomically.
3492
- // Right arrow should move one grapheme at a time.
3493
- editor.handleInput("\x01"); // Ctrl+A
3494
- editor.handleInput("\x1b[C"); // Right
3495
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 1 }); // Just past "["
3496
- });
3497
-
3498
- it("does not crash when paste marker is wider than terminal width", () => {
3499
- // Reproduce: terminal width 8, paste marker "[paste #1 +47 lines]" (21 chars)
3500
- const tui = createTestTUI();
3501
- const editor = new Editor(tui, defaultEditorTheme);
3502
- const bigContent = "line\n".repeat(47).trimEnd();
3503
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3504
-
3505
- const text = editor.getText();
3506
- const marker = text.match(/\[paste #\d+ \+\d+ lines\]/);
3507
- assert.ok(marker, "paste marker should be created");
3508
- assert.ok(visibleWidth(marker[0]) > 8, "marker should be wider than render width");
3509
-
3510
- // Render at very narrow width - should not throw
3511
- const lines = editor.render(8);
3512
- // Every rendered line must fit within the width (marker is split)
3513
- for (const line of lines) {
3514
- assert.ok(
3515
- visibleWidth(line) <= 8,
3516
- `line exceeds width 8: visible=${visibleWidth(line)} text=${JSON.stringify(line)}`,
3517
- );
3518
- }
3519
- });
3520
-
3521
- it("does not crash when text + paste marker exceeds terminal width with cursor on marker", () => {
3522
- // Reproduce: terminal width 54, text "b".repeat(35) + "[paste #1 +27 lines]" + "bbbb"
3523
- // Cursor lands on the paste marker after word-wrap, causing the rendered line
3524
- // to be 55 visible chars (1 over the width).
3525
- const tui = createTestTUI();
3526
- const editor = new Editor(tui, defaultEditorTheme);
3527
-
3528
- // Type 35 'b' characters
3529
- for (let i = 0; i < 35; i++) editor.handleInput("b");
3530
-
3531
- // Paste 27 lines
3532
- const bigContent = "line\n".repeat(27).trimEnd();
3533
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3534
-
3535
- // Type a few more characters
3536
- for (let i = 0; i < 4; i++) editor.handleInput("b");
3537
-
3538
- // Move cursor left to land on the paste marker
3539
- editor.handleInput("\x1b[D"); // past last 'b'
3540
- editor.handleInput("\x1b[D"); // past last 'b'
3541
- editor.handleInput("\x1b[D"); // past last 'b'
3542
- editor.handleInput("\x1b[D"); // past last 'b'
3543
- editor.handleInput("\x1b[D"); // now on the paste marker
3544
-
3545
- // Render at width 54 - should not throw
3546
- const renderWidth = 54;
3547
- const lines = editor.render(renderWidth);
3548
- for (const line of lines) {
3549
- assert.ok(
3550
- visibleWidth(line) <= renderWidth,
3551
- `line exceeds width ${renderWidth}: visible=${visibleWidth(line)} text=${JSON.stringify(line)}`,
3552
- );
3553
- }
3554
- });
3555
-
3556
- it("wordWrapLine re-checks overflow after backtracking to wrap opportunity", () => {
3557
- // Reproduce crash #2: " " + "b".repeat(35) + atomic_marker(20 chars) + "bbbb"
3558
- // layoutWidth=53. After wrapping at the space, the remaining 35 b's + marker = 55
3559
- // must trigger a second force-break instead of silently overflowing.
3560
- const tui = createTestTUI();
3561
- const editor = new Editor(tui, defaultEditorTheme);
3562
-
3563
- // Type a space, then 35 b's
3564
- editor.handleInput(" ");
3565
- for (let i = 0; i < 35; i++) editor.handleInput("b");
3566
-
3567
- // Paste 27 lines to create marker
3568
- const bigContent = "line\n".repeat(27).trimEnd();
3569
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3570
-
3571
- // Type trailing chars
3572
- for (let i = 0; i < 4; i++) editor.handleInput("b");
3573
-
3574
- // Render at width 54 (contentWidth=54, layoutWidth=53 with paddingX=0)
3575
- const renderWidth = 54;
3576
- const lines = editor.render(renderWidth);
3577
- for (const line of lines) {
3578
- assert.ok(
3579
- visibleWidth(line) <= renderWidth,
3580
- `line exceeds width ${renderWidth}: visible=${visibleWidth(line)} text=${JSON.stringify(line)}`,
3581
- );
3582
- }
3583
- });
3584
-
3585
- it("expands large pasted content literally in getExpandedText", () => {
3586
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3587
- const pastedText = [
3588
- "line 1",
3589
- "line 2",
3590
- "line 3",
3591
- "line 4",
3592
- "line 5",
3593
- "line 6",
3594
- "line 7",
3595
- "line 8",
3596
- "line 9",
3597
- "line 10",
3598
- "tokens $1 $2 $& $$ $` $' end",
3599
- ].join("\n");
3600
-
3601
- editor.handleInput(`\x1b[200~${pastedText}\x1b[201~`);
3602
-
3603
- assert.match(editor.getText(), /\[paste #\d+ \+\d+ lines\]/);
3604
- assert.strictEqual(editor.getExpandedText(), pastedText);
3605
- });
3606
-
3607
- it("snaps to the paste marker start when navigating down into it", () => {
3608
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3609
-
3610
- // Line 0: long enough text to establish a sticky column
3611
- editor.setText("12345678901234567890\n\nhello ");
3612
-
3613
- // Create a large paste to get a marker
3614
- const bigContent = "x".repeat(2000);
3615
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3616
- editor.render(80);
3617
-
3618
- const text = editor.getText();
3619
- const _marker = text.match(/\[paste #\d+ \d+ chars\]/)![0];
3620
- // Line 0: "12345678901234567890"
3621
- // Line 1: "" (empty)
3622
- // Line 2: "hello [paste #1 2000 chars]"
3623
- // marker starts at col 6
3624
-
3625
- // Navigate to line 0, col 10
3626
- editor.handleInput("\x1b[A"); // Up to line 1
3627
- editor.handleInput("\x1b[A"); // Up to line 0
3628
- editor.handleInput("\x01"); // Ctrl+A (start of line)
3629
- for (let i = 0; i < 10; i++) editor.handleInput("\x1b[C"); // Right 10
3630
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 });
3631
-
3632
- // Down to empty line
3633
- editor.handleInput("\x1b[B");
3634
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 0 });
3635
-
3636
- // Down to paste marker line - sticky col 10 falls inside marker (starts at col 6).
3637
- // Cursor should snap to start of marker (col 6), not end (col 6 + marker.length).
3638
- editor.handleInput("\x1b[B");
3639
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 6 });
3640
- });
3641
-
3642
- it("preserves sticky column when navigating through paste marker line", () => {
3643
- const tui = createTestTUI(30, 24);
3644
- const editor = new Editor(tui, defaultEditorTheme);
3645
-
3646
- // Build:
3647
- // Line 0: "1234567890123456" (16 chars)
3648
- // Line 1: "" (empty)
3649
- // Line 2: "[paste #1 2000 chars]" (22 chars, paste marker)
3650
- // Line 3: "" (empty)
3651
- // Line 4: "abcdefghijklmnop" (16 chars)
3652
- for (const ch of "1234567890123456") editor.handleInput(ch);
3653
- editor.handleInput("\n");
3654
- editor.handleInput("\n");
3655
- editor.handleInput(`\x1b[200~${"x".repeat(2000)}\x1b[201~`);
3656
- editor.handleInput("\n");
3657
- editor.handleInput("\n");
3658
- for (const ch of "abcdefghijklmnop") editor.handleInput(ch);
3659
- editor.render(30);
3660
-
3661
- // Navigate to line 0, col 10
3662
- for (let i = 0; i < 4; i++) editor.handleInput("\x1b[A"); // Up to line 0
3663
- editor.handleInput("\x01"); // Ctrl+A
3664
- for (let i = 0; i < 10; i++) editor.handleInput("\x1b[C");
3665
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 10 });
3666
-
3667
- // Down to empty line - sticky col 10 established
3668
- editor.handleInput("\x1b[B");
3669
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 0 });
3670
-
3671
- // Down to paste marker - cursor snapped to col 0 (start of marker)
3672
- editor.handleInput("\x1b[B");
3673
- assert.deepStrictEqual(editor.getCursor(), { line: 2, col: 0 });
3674
-
3675
- // Down to empty line
3676
- editor.handleInput("\x1b[B");
3677
- assert.deepStrictEqual(editor.getCursor(), { line: 3, col: 0 });
3678
-
3679
- // Down to last line - should restore sticky col 10
3680
- editor.handleInput("\x1b[B");
3681
- assert.deepStrictEqual(editor.getCursor(), { line: 4, col: 10 });
3682
- });
3683
-
3684
- it("does not get stuck moving down from a multi-visual-line paste marker", () => {
3685
- const tui = createTestTUI(20, 24);
3686
- const editor = new Editor(tui, defaultEditorTheme);
3687
-
3688
- // Build:
3689
- // Logical line 0: "abcdefgh" + marker(21 chars) + "ijklmnopqr"
3690
- // Logical line 1: "123456789012345678"
3691
- //
3692
- // Marker "[paste #1 +100 lines]" (21 chars) is wider than the
3693
- // terminal (20). Word-wrap splits at the space before "lines",
3694
- // producing:
3695
- // VL1: abcdefgh (startCol 0, len 8)
3696
- // VL2: [paste #1 +100 (startCol 8, len 15) <- marker head
3697
- // VL3: lines]ijklmnopqr (startCol 23, len 16) <- marker tail + content
3698
- // VL4: 123456789012345678 (line 1)
3699
- //
3700
- // On VL3 the marker tail "lines]" occupies visual cols 0-5.
3701
- // Content ("i") starts at visual col 6 = logical col 29.
3702
- for (const ch of "abcdefgh") editor.handleInput(ch);
3703
- const bigContent = "line\n".repeat(100).trimEnd();
3704
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3705
- for (const ch of "ijklmnopqr") editor.handleInput(ch);
3706
- editor.handleInput("\n");
3707
- for (const ch of "123456789012345678") editor.handleInput(ch);
3708
- editor.render(20);
3709
-
3710
- const text = editor.getText();
3711
- const markerMatch = text.match(/\[paste #\d+ \+\d+ lines]/);
3712
- assert.ok(markerMatch, "paste marker should be created");
3713
- const markerLen = markerMatch[0].length; // 21
3714
- assert.ok(markerLen > 20, "marker should be wider than terminal");
3715
- const markerStart = 8;
3716
- const markerEnd = markerStart + markerLen; // 29
3717
-
3718
- // Navigate to line 0, col 6 (on "g"). Preferred col 6 is past the
3719
- // marker tail on VL3, so the cursor should land on content ("i" at
3720
- // col 29) without snapping back.
3721
- editor.handleInput("\x1b[A"); // Up to line 0
3722
- editor.handleInput("\x01"); // Ctrl+A (start of line)
3723
- for (let i = 0; i < 6; i++) editor.handleInput("\x1b[C"); // Right to col 6
3724
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 6 });
3725
-
3726
- // Down: cursor lands on paste marker start
3727
- editor.handleInput("\x1b[B");
3728
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: markerStart });
3729
-
3730
- // Down again: preferred col 6 lands at VL3 col 29 ("i"), which is
3731
- // past the marker. Cursor stays on line 0.
3732
- editor.handleInput("\x1b[B");
3733
- assert.strictEqual(editor.getCursor().line, 0);
3734
- assert.strictEqual(editor.getCursor().col, markerEnd); // col 29 = "i"
3735
-
3736
- // Up: back to paste marker
3737
- editor.handleInput("\x1b[A");
3738
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: markerStart });
3739
-
3740
- // Up again: back to col 6 ("g")
3741
- editor.handleInput("\x1b[A");
3742
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 6 });
3743
- });
3744
-
3745
- it("skips marker continuation VLs when preferred col falls in marker tail", () => {
3746
- const tui = createTestTUI(20, 24);
3747
- const editor = new Editor(tui, defaultEditorTheme);
3748
-
3749
- // Same layout. Start at col 3 ("d"). Preferred col 3 maps to VL3
3750
- // visual col 3 which is inside the "lines]" marker tail.
3751
- // moveToVisualLine detects the continuation VL and skips to VL4
3752
- // (line 1).
3753
- // VL1: abcdefgh (startCol 0, len 8)
3754
- // VL2: [paste #1 +100 (startCol 8, len 15) <- marker head
3755
- // VL3: lines]ijklmnopqr (startCol 23, len 16) <- marker tail + content
3756
- // VL4: 123456789012345678 (line 1)
3757
- for (const ch of "abcdefgh") editor.handleInput(ch);
3758
- const bigContent = "line\n".repeat(100).trimEnd();
3759
- editor.handleInput(`\x1b[200~${bigContent}\x1b[201~`);
3760
- for (const ch of "ijklmnopqr") editor.handleInput(ch);
3761
- editor.handleInput("\n");
3762
- for (const ch of "123456789012345678") editor.handleInput(ch);
3763
- editor.render(20);
3764
-
3765
- // Navigate to line 0, col 3 (on "d")
3766
- editor.handleInput("\x1b[A"); // Up to line 0
3767
- editor.handleInput("\x01"); // Ctrl+A
3768
- for (let i = 0; i < 3; i++) editor.handleInput("\x1b[C");
3769
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
3770
-
3771
- // Down: marker
3772
- editor.handleInput("\x1b[B");
3773
- assert.strictEqual(editor.getCursor().col, 8);
3774
-
3775
- // Down: skips VL3 (col 3 in marker tail) and lands on line 1
3776
- editor.handleInput("\x1b[B");
3777
- assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 3 });
3778
-
3779
- // Round-trip back
3780
- editor.handleInput("\x1b[A");
3781
- assert.strictEqual(editor.getCursor().col, 8); // marker
3782
- editor.handleInput("\x1b[A");
3783
- assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
3784
- });
3785
-
3786
- it("submits large pasted content literally", () => {
3787
- const editor = new Editor(createTestTUI(), defaultEditorTheme);
3788
- const pastedText = [
3789
- "line 1",
3790
- "line 2",
3791
- "line 3",
3792
- "line 4",
3793
- "line 5",
3794
- "line 6",
3795
- "line 7",
3796
- "line 8",
3797
- "line 9",
3798
- "line 10",
3799
- "tokens $1 $2 $& $$ $` $' end",
3800
- ].join("\n");
3801
- let submitted = "";
3802
- editor.onSubmit = (text) => {
3803
- submitted = text;
3804
- };
3805
-
3806
- editor.handleInput(`\x1b[200~${pastedText}\x1b[201~`);
3807
- editor.handleInput("\r");
3808
-
3809
- assert.strictEqual(submitted, pastedText);
3810
- });
3811
- });
3812
- });