@code-yeongyu/senpi 0.74.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 (1193) hide show
  1. package/CHANGELOG.md +4225 -0
  2. package/README.md +654 -0
  3. package/dist/bun/cli.d.ts +3 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +9 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/register-bedrock.d.ts +2 -0
  8. package/dist/bun/register-bedrock.d.ts.map +1 -0
  9. package/dist/bun/register-bedrock.js +4 -0
  10. package/dist/bun/register-bedrock.js.map +1 -0
  11. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  12. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  13. package/dist/bun/restore-sandbox-env.js +32 -0
  14. package/dist/bun/restore-sandbox-env.js.map +1 -0
  15. package/dist/cli/args.d.ts +53 -0
  16. package/dist/cli/args.d.ts.map +1 -0
  17. package/dist/cli/args.js +342 -0
  18. package/dist/cli/args.js.map +1 -0
  19. package/dist/cli/config-selector.d.ts +14 -0
  20. package/dist/cli/config-selector.d.ts.map +1 -0
  21. package/dist/cli/config-selector.js +31 -0
  22. package/dist/cli/config-selector.js.map +1 -0
  23. package/dist/cli/file-processor.d.ts +15 -0
  24. package/dist/cli/file-processor.d.ts.map +1 -0
  25. package/dist/cli/file-processor.js +83 -0
  26. package/dist/cli/file-processor.js.map +1 -0
  27. package/dist/cli/initial-message.d.ts +18 -0
  28. package/dist/cli/initial-message.d.ts.map +1 -0
  29. package/dist/cli/initial-message.js +22 -0
  30. package/dist/cli/initial-message.js.map +1 -0
  31. package/dist/cli/list-models.d.ts +9 -0
  32. package/dist/cli/list-models.d.ts.map +1 -0
  33. package/dist/cli/list-models.js +98 -0
  34. package/dist/cli/list-models.js.map +1 -0
  35. package/dist/cli/session-picker.d.ts +9 -0
  36. package/dist/cli/session-picker.d.ts.map +1 -0
  37. package/dist/cli/session-picker.js +35 -0
  38. package/dist/cli/session-picker.js.map +1 -0
  39. package/dist/cli.d.ts +3 -0
  40. package/dist/cli.d.ts.map +1 -0
  41. package/dist/cli.js +20 -0
  42. package/dist/cli.js.map +1 -0
  43. package/dist/config.d.ts +92 -0
  44. package/dist/config.d.ts.map +1 -0
  45. package/dist/config.js +399 -0
  46. package/dist/config.js.map +1 -0
  47. package/dist/core/agent-session-runtime.d.ts +117 -0
  48. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  49. package/dist/core/agent-session-runtime.js +300 -0
  50. package/dist/core/agent-session-runtime.js.map +1 -0
  51. package/dist/core/agent-session-services.d.ts +93 -0
  52. package/dist/core/agent-session-services.d.ts.map +1 -0
  53. package/dist/core/agent-session-services.js +118 -0
  54. package/dist/core/agent-session-services.js.map +1 -0
  55. package/dist/core/agent-session.d.ts +643 -0
  56. package/dist/core/agent-session.d.ts.map +1 -0
  57. package/dist/core/agent-session.js +2702 -0
  58. package/dist/core/agent-session.js.map +1 -0
  59. package/dist/core/auth-guidance.d.ts +5 -0
  60. package/dist/core/auth-guidance.d.ts.map +1 -0
  61. package/dist/core/auth-guidance.js +21 -0
  62. package/dist/core/auth-guidance.js.map +1 -0
  63. package/dist/core/auth-storage.d.ts +141 -0
  64. package/dist/core/auth-storage.d.ts.map +1 -0
  65. package/dist/core/auth-storage.js +441 -0
  66. package/dist/core/auth-storage.js.map +1 -0
  67. package/dist/core/bash-executor.d.ts +32 -0
  68. package/dist/core/bash-executor.d.ts.map +1 -0
  69. package/dist/core/bash-executor.js +111 -0
  70. package/dist/core/bash-executor.js.map +1 -0
  71. package/dist/core/compaction/branch-summarization.d.ts +93 -0
  72. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  73. package/dist/core/compaction/branch-summarization.js +285 -0
  74. package/dist/core/compaction/branch-summarization.js.map +1 -0
  75. package/dist/core/compaction/compaction.d.ts +129 -0
  76. package/dist/core/compaction/compaction.d.ts.map +1 -0
  77. package/dist/core/compaction/compaction.js +635 -0
  78. package/dist/core/compaction/compaction.js.map +1 -0
  79. package/dist/core/compaction/index.d.ts +7 -0
  80. package/dist/core/compaction/index.d.ts.map +1 -0
  81. package/dist/core/compaction/index.js +7 -0
  82. package/dist/core/compaction/index.js.map +1 -0
  83. package/dist/core/compaction/utils.d.ts +38 -0
  84. package/dist/core/compaction/utils.d.ts.map +1 -0
  85. package/dist/core/compaction/utils.js +165 -0
  86. package/dist/core/compaction/utils.js.map +1 -0
  87. package/dist/core/defaults.d.ts +3 -0
  88. package/dist/core/defaults.d.ts.map +1 -0
  89. package/dist/core/defaults.js +2 -0
  90. package/dist/core/defaults.js.map +1 -0
  91. package/dist/core/diagnostics.d.ts +15 -0
  92. package/dist/core/diagnostics.d.ts.map +1 -0
  93. package/dist/core/diagnostics.js +2 -0
  94. package/dist/core/diagnostics.js.map +1 -0
  95. package/dist/core/dynamic-prompt/build.d.ts +15 -0
  96. package/dist/core/dynamic-prompt/build.d.ts.map +1 -0
  97. package/dist/core/dynamic-prompt/build.js +61 -0
  98. package/dist/core/dynamic-prompt/build.js.map +1 -0
  99. package/dist/core/dynamic-prompt/exploration.d.ts +2 -0
  100. package/dist/core/dynamic-prompt/exploration.d.ts.map +1 -0
  101. package/dist/core/dynamic-prompt/exploration.js +8 -0
  102. package/dist/core/dynamic-prompt/exploration.js.map +1 -0
  103. package/dist/core/dynamic-prompt/identity.d.ts +2 -0
  104. package/dist/core/dynamic-prompt/identity.d.ts.map +1 -0
  105. package/dist/core/dynamic-prompt/identity.js +4 -0
  106. package/dist/core/dynamic-prompt/identity.js.map +1 -0
  107. package/dist/core/dynamic-prompt/index.d.ts +13 -0
  108. package/dist/core/dynamic-prompt/index.d.ts.map +1 -0
  109. package/dist/core/dynamic-prompt/index.js +11 -0
  110. package/dist/core/dynamic-prompt/index.js.map +1 -0
  111. package/dist/core/dynamic-prompt/intent-gate.d.ts +5 -0
  112. package/dist/core/dynamic-prompt/intent-gate.d.ts.map +1 -0
  113. package/dist/core/dynamic-prompt/intent-gate.js +57 -0
  114. package/dist/core/dynamic-prompt/intent-gate.js.map +1 -0
  115. package/dist/core/dynamic-prompt/parallel-tools.d.ts +2 -0
  116. package/dist/core/dynamic-prompt/parallel-tools.d.ts.map +1 -0
  117. package/dist/core/dynamic-prompt/parallel-tools.js +10 -0
  118. package/dist/core/dynamic-prompt/parallel-tools.js.map +1 -0
  119. package/dist/core/dynamic-prompt/policies.d.ts +2 -0
  120. package/dist/core/dynamic-prompt/policies.d.ts.map +1 -0
  121. package/dist/core/dynamic-prompt/policies.js +14 -0
  122. package/dist/core/dynamic-prompt/policies.js.map +1 -0
  123. package/dist/core/dynamic-prompt/style.d.ts +2 -0
  124. package/dist/core/dynamic-prompt/style.d.ts.map +1 -0
  125. package/dist/core/dynamic-prompt/style.js +10 -0
  126. package/dist/core/dynamic-prompt/style.js.map +1 -0
  127. package/dist/core/dynamic-prompt/tool-categorization.d.ts +4 -0
  128. package/dist/core/dynamic-prompt/tool-categorization.d.ts.map +1 -0
  129. package/dist/core/dynamic-prompt/tool-categorization.js +26 -0
  130. package/dist/core/dynamic-prompt/tool-categorization.js.map +1 -0
  131. package/dist/core/dynamic-prompt/tool-section.d.ts +7 -0
  132. package/dist/core/dynamic-prompt/tool-section.d.ts.map +1 -0
  133. package/dist/core/dynamic-prompt/tool-section.js +46 -0
  134. package/dist/core/dynamic-prompt/tool-section.js.map +1 -0
  135. package/dist/core/dynamic-prompt/types.d.ts +5 -0
  136. package/dist/core/dynamic-prompt/types.d.ts.map +1 -0
  137. package/dist/core/dynamic-prompt/types.js +2 -0
  138. package/dist/core/dynamic-prompt/types.js.map +1 -0
  139. package/dist/core/dynamic-prompt/verification.d.ts +2 -0
  140. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -0
  141. package/dist/core/dynamic-prompt/verification.js +12 -0
  142. package/dist/core/dynamic-prompt/verification.js.map +1 -0
  143. package/dist/core/event-bus.d.ts +9 -0
  144. package/dist/core/event-bus.d.ts.map +1 -0
  145. package/dist/core/event-bus.js +25 -0
  146. package/dist/core/event-bus.js.map +1 -0
  147. package/dist/core/exec.d.ts +29 -0
  148. package/dist/core/exec.d.ts.map +1 -0
  149. package/dist/core/exec.js +75 -0
  150. package/dist/core/exec.js.map +1 -0
  151. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  152. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  153. package/dist/core/export-html/ansi-to-html.js +249 -0
  154. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  155. package/dist/core/export-html/index.d.ts +37 -0
  156. package/dist/core/export-html/index.d.ts.map +1 -0
  157. package/dist/core/export-html/index.js +224 -0
  158. package/dist/core/export-html/index.js.map +1 -0
  159. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  160. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  161. package/dist/core/export-html/tool-renderer.js +108 -0
  162. package/dist/core/export-html/tool-renderer.js.map +1 -0
  163. package/dist/core/extensions/builtin/agent-system/agent-types.d.ts +25 -0
  164. package/dist/core/extensions/builtin/agent-system/agent-types.d.ts.map +1 -0
  165. package/dist/core/extensions/builtin/agent-system/agent-types.js +38 -0
  166. package/dist/core/extensions/builtin/agent-system/agent-types.js.map +1 -0
  167. package/dist/core/extensions/builtin/agent-system/builtin-agents.d.ts +3 -0
  168. package/dist/core/extensions/builtin/agent-system/builtin-agents.d.ts.map +1 -0
  169. package/dist/core/extensions/builtin/agent-system/builtin-agents.js +32 -0
  170. package/dist/core/extensions/builtin/agent-system/builtin-agents.js.map +1 -0
  171. package/dist/core/extensions/builtin/agent-system/index.d.ts +3 -0
  172. package/dist/core/extensions/builtin/agent-system/index.d.ts.map +1 -0
  173. package/dist/core/extensions/builtin/agent-system/index.js +42 -0
  174. package/dist/core/extensions/builtin/agent-system/index.js.map +1 -0
  175. package/dist/core/extensions/builtin/agent-system/loader.d.ts +4 -0
  176. package/dist/core/extensions/builtin/agent-system/loader.d.ts.map +1 -0
  177. package/dist/core/extensions/builtin/agent-system/loader.js +59 -0
  178. package/dist/core/extensions/builtin/agent-system/loader.js.map +1 -0
  179. package/dist/core/extensions/builtin/agent-system/permission.d.ts +11 -0
  180. package/dist/core/extensions/builtin/agent-system/permission.d.ts.map +1 -0
  181. package/dist/core/extensions/builtin/agent-system/permission.js +24 -0
  182. package/dist/core/extensions/builtin/agent-system/permission.js.map +1 -0
  183. package/dist/core/extensions/builtin/agent-system/registry.d.ts +10 -0
  184. package/dist/core/extensions/builtin/agent-system/registry.d.ts.map +1 -0
  185. package/dist/core/extensions/builtin/agent-system/registry.js +50 -0
  186. package/dist/core/extensions/builtin/agent-system/registry.js.map +1 -0
  187. package/dist/core/extensions/builtin/agent-system/types.d.ts +9 -0
  188. package/dist/core/extensions/builtin/agent-system/types.d.ts.map +1 -0
  189. package/dist/core/extensions/builtin/agent-system/types.js +2 -0
  190. package/dist/core/extensions/builtin/agent-system/types.js.map +1 -0
  191. package/dist/core/extensions/builtin/agent-system/wildcard.d.ts +4 -0
  192. package/dist/core/extensions/builtin/agent-system/wildcard.d.ts.map +1 -0
  193. package/dist/core/extensions/builtin/agent-system/wildcard.js +58 -0
  194. package/dist/core/extensions/builtin/agent-system/wildcard.js.map +1 -0
  195. package/dist/core/extensions/builtin/anthropic-bash/index.d.ts +7 -0
  196. package/dist/core/extensions/builtin/anthropic-bash/index.d.ts.map +1 -0
  197. package/dist/core/extensions/builtin/anthropic-bash/index.js +79 -0
  198. package/dist/core/extensions/builtin/anthropic-bash/index.js.map +1 -0
  199. package/dist/core/extensions/builtin/anthropic-code-execution/index.d.ts +7 -0
  200. package/dist/core/extensions/builtin/anthropic-code-execution/index.d.ts.map +1 -0
  201. package/dist/core/extensions/builtin/anthropic-code-execution/index.js +79 -0
  202. package/dist/core/extensions/builtin/anthropic-code-execution/index.js.map +1 -0
  203. package/dist/core/extensions/builtin/anthropic-computer-use/index.d.ts +53 -0
  204. package/dist/core/extensions/builtin/anthropic-computer-use/index.d.ts.map +1 -0
  205. package/dist/core/extensions/builtin/anthropic-computer-use/index.js +676 -0
  206. package/dist/core/extensions/builtin/anthropic-computer-use/index.js.map +1 -0
  207. package/dist/core/extensions/builtin/anthropic-text-editor/index.d.ts +25 -0
  208. package/dist/core/extensions/builtin/anthropic-text-editor/index.d.ts.map +1 -0
  209. package/dist/core/extensions/builtin/anthropic-text-editor/index.js +244 -0
  210. package/dist/core/extensions/builtin/anthropic-text-editor/index.js.map +1 -0
  211. package/dist/core/extensions/builtin/anthropic-tool-search/index.d.ts +6 -0
  212. package/dist/core/extensions/builtin/anthropic-tool-search/index.d.ts.map +1 -0
  213. package/dist/core/extensions/builtin/anthropic-tool-search/index.js +112 -0
  214. package/dist/core/extensions/builtin/anthropic-tool-search/index.js.map +1 -0
  215. package/dist/core/extensions/builtin/anthropic-web-fetch/index.d.ts +7 -0
  216. package/dist/core/extensions/builtin/anthropic-web-fetch/index.d.ts.map +1 -0
  217. package/dist/core/extensions/builtin/anthropic-web-fetch/index.js +112 -0
  218. package/dist/core/extensions/builtin/anthropic-web-fetch/index.js.map +1 -0
  219. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts +7 -0
  220. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts.map +1 -0
  221. package/dist/core/extensions/builtin/anthropic-web-search/index.js +102 -0
  222. package/dist/core/extensions/builtin/anthropic-web-search/index.js.map +1 -0
  223. package/dist/core/extensions/builtin/background-task/cancel-tool.d.ts +10 -0
  224. package/dist/core/extensions/builtin/background-task/cancel-tool.d.ts.map +1 -0
  225. package/dist/core/extensions/builtin/background-task/cancel-tool.js +109 -0
  226. package/dist/core/extensions/builtin/background-task/cancel-tool.js.map +1 -0
  227. package/dist/core/extensions/builtin/background-task/index.d.ts +3 -0
  228. package/dist/core/extensions/builtin/background-task/index.d.ts.map +1 -0
  229. package/dist/core/extensions/builtin/background-task/index.js +207 -0
  230. package/dist/core/extensions/builtin/background-task/index.js.map +1 -0
  231. package/dist/core/extensions/builtin/background-task/manager.d.ts +17 -0
  232. package/dist/core/extensions/builtin/background-task/manager.d.ts.map +1 -0
  233. package/dist/core/extensions/builtin/background-task/manager.js +114 -0
  234. package/dist/core/extensions/builtin/background-task/manager.js.map +1 -0
  235. package/dist/core/extensions/builtin/background-task/notification.d.ts +22 -0
  236. package/dist/core/extensions/builtin/background-task/notification.d.ts.map +1 -0
  237. package/dist/core/extensions/builtin/background-task/notification.js +105 -0
  238. package/dist/core/extensions/builtin/background-task/notification.js.map +1 -0
  239. package/dist/core/extensions/builtin/background-task/output-tool.d.ts +11 -0
  240. package/dist/core/extensions/builtin/background-task/output-tool.d.ts.map +1 -0
  241. package/dist/core/extensions/builtin/background-task/output-tool.js +127 -0
  242. package/dist/core/extensions/builtin/background-task/output-tool.js.map +1 -0
  243. package/dist/core/extensions/builtin/background-task/spawner.d.ts +8 -0
  244. package/dist/core/extensions/builtin/background-task/spawner.d.ts.map +1 -0
  245. package/dist/core/extensions/builtin/background-task/spawner.js +207 -0
  246. package/dist/core/extensions/builtin/background-task/spawner.js.map +1 -0
  247. package/dist/core/extensions/builtin/background-task/task-tool.d.ts +20 -0
  248. package/dist/core/extensions/builtin/background-task/task-tool.d.ts.map +1 -0
  249. package/dist/core/extensions/builtin/background-task/task-tool.js +302 -0
  250. package/dist/core/extensions/builtin/background-task/task-tool.js.map +1 -0
  251. package/dist/core/extensions/builtin/background-task/types.d.ts +72 -0
  252. package/dist/core/extensions/builtin/background-task/types.d.ts.map +1 -0
  253. package/dist/core/extensions/builtin/background-task/types.js +32 -0
  254. package/dist/core/extensions/builtin/background-task/types.js.map +1 -0
  255. package/dist/core/extensions/builtin/bash-timeout/index.d.ts +5 -0
  256. package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -0
  257. package/dist/core/extensions/builtin/bash-timeout/index.js +20 -0
  258. package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -0
  259. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts +17 -0
  260. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -0
  261. package/dist/core/extensions/builtin/bash-timeout/timeout.js +28 -0
  262. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -0
  263. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts +46 -0
  264. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -0
  265. package/dist/core/extensions/builtin/compaction/checkpoint-state.js +131 -0
  266. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -0
  267. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts +23 -0
  268. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts.map +1 -0
  269. package/dist/core/extensions/builtin/compaction/circuit-breaker.js +36 -0
  270. package/dist/core/extensions/builtin/compaction/circuit-breaker.js.map +1 -0
  271. package/dist/core/extensions/builtin/compaction/degradation-monitor.d.ts +67 -0
  272. package/dist/core/extensions/builtin/compaction/degradation-monitor.d.ts.map +1 -0
  273. package/dist/core/extensions/builtin/compaction/degradation-monitor.js +90 -0
  274. package/dist/core/extensions/builtin/compaction/degradation-monitor.js.map +1 -0
  275. package/dist/core/extensions/builtin/compaction/index.d.ts +3 -0
  276. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -0
  277. package/dist/core/extensions/builtin/compaction/index.js +199 -0
  278. package/dist/core/extensions/builtin/compaction/index.js.map +1 -0
  279. package/dist/core/extensions/builtin/compaction/overflow-detection.d.ts +11 -0
  280. package/dist/core/extensions/builtin/compaction/overflow-detection.d.ts.map +1 -0
  281. package/dist/core/extensions/builtin/compaction/overflow-detection.js +40 -0
  282. package/dist/core/extensions/builtin/compaction/overflow-detection.js.map +1 -0
  283. package/dist/core/extensions/builtin/compaction/per-turn-cap.d.ts +15 -0
  284. package/dist/core/extensions/builtin/compaction/per-turn-cap.d.ts.map +1 -0
  285. package/dist/core/extensions/builtin/compaction/per-turn-cap.js +26 -0
  286. package/dist/core/extensions/builtin/compaction/per-turn-cap.js.map +1 -0
  287. package/dist/core/extensions/builtin/compaction/policy.d.ts +19 -0
  288. package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -0
  289. package/dist/core/extensions/builtin/compaction/policy.js +96 -0
  290. package/dist/core/extensions/builtin/compaction/policy.js.map +1 -0
  291. package/dist/core/extensions/builtin/compaction/prompts.d.ts +16 -0
  292. package/dist/core/extensions/builtin/compaction/prompts.d.ts.map +1 -0
  293. package/dist/core/extensions/builtin/compaction/prompts.js +252 -0
  294. package/dist/core/extensions/builtin/compaction/prompts.js.map +1 -0
  295. package/dist/core/extensions/builtin/compaction/restoration-tracker.d.ts +57 -0
  296. package/dist/core/extensions/builtin/compaction/restoration-tracker.d.ts.map +1 -0
  297. package/dist/core/extensions/builtin/compaction/restoration-tracker.js +274 -0
  298. package/dist/core/extensions/builtin/compaction/restoration-tracker.js.map +1 -0
  299. package/dist/core/extensions/builtin/compaction/speculative.d.ts +58 -0
  300. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -0
  301. package/dist/core/extensions/builtin/compaction/speculative.js +230 -0
  302. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -0
  303. package/dist/core/extensions/builtin/compaction/state.d.ts +17 -0
  304. package/dist/core/extensions/builtin/compaction/state.d.ts.map +1 -0
  305. package/dist/core/extensions/builtin/compaction/state.js +15 -0
  306. package/dist/core/extensions/builtin/compaction/state.js.map +1 -0
  307. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts +25 -0
  308. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -0
  309. package/dist/core/extensions/builtin/compaction/todo-bridge.js +77 -0
  310. package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -0
  311. package/dist/core/extensions/builtin/compaction/tool-truncation.d.ts +4 -0
  312. package/dist/core/extensions/builtin/compaction/tool-truncation.d.ts.map +1 -0
  313. package/dist/core/extensions/builtin/compaction/tool-truncation.js +85 -0
  314. package/dist/core/extensions/builtin/compaction/tool-truncation.js.map +1 -0
  315. package/dist/core/extensions/builtin/diff.d.ts +9 -0
  316. package/dist/core/extensions/builtin/diff.d.ts.map +1 -0
  317. package/dist/core/extensions/builtin/diff.js +188 -0
  318. package/dist/core/extensions/builtin/diff.js.map +1 -0
  319. package/dist/core/extensions/builtin/files.d.ts +9 -0
  320. package/dist/core/extensions/builtin/files.d.ts.map +1 -0
  321. package/dist/core/extensions/builtin/files.js +186 -0
  322. package/dist/core/extensions/builtin/files.js.map +1 -0
  323. package/dist/core/extensions/builtin/google-code-execution/index.d.ts +7 -0
  324. package/dist/core/extensions/builtin/google-code-execution/index.d.ts.map +1 -0
  325. package/dist/core/extensions/builtin/google-code-execution/index.js +73 -0
  326. package/dist/core/extensions/builtin/google-code-execution/index.js.map +1 -0
  327. package/dist/core/extensions/builtin/google-google-search/index.d.ts +7 -0
  328. package/dist/core/extensions/builtin/google-google-search/index.d.ts.map +1 -0
  329. package/dist/core/extensions/builtin/google-google-search/index.js +83 -0
  330. package/dist/core/extensions/builtin/google-google-search/index.js.map +1 -0
  331. package/dist/core/extensions/builtin/google-url-context/index.d.ts +7 -0
  332. package/dist/core/extensions/builtin/google-url-context/index.d.ts.map +1 -0
  333. package/dist/core/extensions/builtin/google-url-context/index.js +82 -0
  334. package/dist/core/extensions/builtin/google-url-context/index.js.map +1 -0
  335. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts +6 -0
  336. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -0
  337. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js +159 -0
  338. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -0
  339. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts +8 -0
  340. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -0
  341. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js +29 -0
  342. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -0
  343. package/dist/core/extensions/builtin/gpt-apply-patch/errors.d.ts +8 -0
  344. package/dist/core/extensions/builtin/gpt-apply-patch/errors.d.ts.map +1 -0
  345. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js +14 -0
  346. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js.map +1 -0
  347. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts +6 -0
  348. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -0
  349. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +54 -0
  350. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -0
  351. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +12 -0
  352. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -0
  353. package/dist/core/extensions/builtin/gpt-apply-patch/index.js +11 -0
  354. package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -0
  355. package/dist/core/extensions/builtin/gpt-apply-patch/params.d.ts +3 -0
  356. package/dist/core/extensions/builtin/gpt-apply-patch/params.d.ts.map +1 -0
  357. package/dist/core/extensions/builtin/gpt-apply-patch/params.js +13 -0
  358. package/dist/core/extensions/builtin/gpt-apply-patch/params.js.map +1 -0
  359. package/dist/core/extensions/builtin/gpt-apply-patch/parser.d.ts +3 -0
  360. package/dist/core/extensions/builtin/gpt-apply-patch/parser.d.ts.map +1 -0
  361. package/dist/core/extensions/builtin/gpt-apply-patch/parser.js +157 -0
  362. package/dist/core/extensions/builtin/gpt-apply-patch/parser.js.map +1 -0
  363. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.d.ts +6 -0
  364. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.d.ts.map +1 -0
  365. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.js +36 -0
  366. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.js.map +1 -0
  367. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.d.ts +6 -0
  368. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.d.ts.map +1 -0
  369. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.js +50 -0
  370. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.js.map +1 -0
  371. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.d.ts +13 -0
  372. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.d.ts.map +1 -0
  373. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.js +306 -0
  374. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.js.map +1 -0
  375. package/dist/core/extensions/builtin/gpt-apply-patch/preview.d.ts +7 -0
  376. package/dist/core/extensions/builtin/gpt-apply-patch/preview.d.ts.map +1 -0
  377. package/dist/core/extensions/builtin/gpt-apply-patch/preview.js +73 -0
  378. package/dist/core/extensions/builtin/gpt-apply-patch/preview.js.map +1 -0
  379. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.d.ts +6 -0
  380. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.d.ts.map +1 -0
  381. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.js +49 -0
  382. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.js.map +1 -0
  383. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.d.ts +23 -0
  384. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.d.ts.map +1 -0
  385. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js +197 -0
  386. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js.map +1 -0
  387. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.d.ts +4 -0
  388. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.d.ts.map +1 -0
  389. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.js +76 -0
  390. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.js.map +1 -0
  391. package/dist/core/extensions/builtin/gpt-apply-patch/text.d.ts +4 -0
  392. package/dist/core/extensions/builtin/gpt-apply-patch/text.d.ts.map +1 -0
  393. package/dist/core/extensions/builtin/gpt-apply-patch/text.js +16 -0
  394. package/dist/core/extensions/builtin/gpt-apply-patch/text.js.map +1 -0
  395. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +3 -0
  396. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -0
  397. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +116 -0
  398. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -0
  399. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts +109 -0
  400. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -0
  401. package/dist/core/extensions/builtin/gpt-apply-patch/types.js +2 -0
  402. package/dist/core/extensions/builtin/gpt-apply-patch/types.js.map +1 -0
  403. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.d.ts +2 -0
  404. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.d.ts.map +1 -0
  405. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.js +5 -0
  406. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.js.map +1 -0
  407. package/dist/core/extensions/builtin/index.d.ts +18 -0
  408. package/dist/core/extensions/builtin/index.d.ts.map +1 -0
  409. package/dist/core/extensions/builtin/index.js +58 -0
  410. package/dist/core/extensions/builtin/index.js.map +1 -0
  411. package/dist/core/extensions/builtin/openai-api-parallel-tool-calls/index.d.ts +6 -0
  412. package/dist/core/extensions/builtin/openai-api-parallel-tool-calls/index.d.ts.map +1 -0
  413. package/dist/core/extensions/builtin/openai-api-parallel-tool-calls/index.js +57 -0
  414. package/dist/core/extensions/builtin/openai-api-parallel-tool-calls/index.js.map +1 -0
  415. package/dist/core/extensions/builtin/openai-code-interpreter/index.d.ts +10 -0
  416. package/dist/core/extensions/builtin/openai-code-interpreter/index.d.ts.map +1 -0
  417. package/dist/core/extensions/builtin/openai-code-interpreter/index.js +95 -0
  418. package/dist/core/extensions/builtin/openai-code-interpreter/index.js.map +1 -0
  419. package/dist/core/extensions/builtin/openai-web-search/index.d.ts +7 -0
  420. package/dist/core/extensions/builtin/openai-web-search/index.d.ts.map +1 -0
  421. package/dist/core/extensions/builtin/openai-web-search/index.js +111 -0
  422. package/dist/core/extensions/builtin/openai-web-search/index.js.map +1 -0
  423. package/dist/core/extensions/builtin/permission-system/arity.d.ts +4 -0
  424. package/dist/core/extensions/builtin/permission-system/arity.d.ts.map +1 -0
  425. package/dist/core/extensions/builtin/permission-system/arity.js +168 -0
  426. package/dist/core/extensions/builtin/permission-system/arity.js.map +1 -0
  427. package/dist/core/extensions/builtin/permission-system/cli.d.ts +6 -0
  428. package/dist/core/extensions/builtin/permission-system/cli.d.ts.map +1 -0
  429. package/dist/core/extensions/builtin/permission-system/cli.js +33 -0
  430. package/dist/core/extensions/builtin/permission-system/cli.js.map +1 -0
  431. package/dist/core/extensions/builtin/permission-system/config.d.ts +7 -0
  432. package/dist/core/extensions/builtin/permission-system/config.d.ts.map +1 -0
  433. package/dist/core/extensions/builtin/permission-system/config.js +49 -0
  434. package/dist/core/extensions/builtin/permission-system/config.js.map +1 -0
  435. package/dist/core/extensions/builtin/permission-system/evaluate.d.ts +9 -0
  436. package/dist/core/extensions/builtin/permission-system/evaluate.d.ts.map +1 -0
  437. package/dist/core/extensions/builtin/permission-system/evaluate.js +14 -0
  438. package/dist/core/extensions/builtin/permission-system/evaluate.js.map +1 -0
  439. package/dist/core/extensions/builtin/permission-system/events.d.ts +67 -0
  440. package/dist/core/extensions/builtin/permission-system/events.d.ts.map +1 -0
  441. package/dist/core/extensions/builtin/permission-system/events.js +63 -0
  442. package/dist/core/extensions/builtin/permission-system/events.js.map +1 -0
  443. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts +4 -0
  444. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -0
  445. package/dist/core/extensions/builtin/permission-system/external-dir.js +138 -0
  446. package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -0
  447. package/dist/core/extensions/builtin/permission-system/index.d.ts +3 -0
  448. package/dist/core/extensions/builtin/permission-system/index.d.ts.map +1 -0
  449. package/dist/core/extensions/builtin/permission-system/index.js +134 -0
  450. package/dist/core/extensions/builtin/permission-system/index.js.map +1 -0
  451. package/dist/core/extensions/builtin/permission-system/non-interactive.d.ts +9 -0
  452. package/dist/core/extensions/builtin/permission-system/non-interactive.d.ts.map +1 -0
  453. package/dist/core/extensions/builtin/permission-system/non-interactive.js +43 -0
  454. package/dist/core/extensions/builtin/permission-system/non-interactive.js.map +1 -0
  455. package/dist/core/extensions/builtin/permission-system/parsers.d.ts +16 -0
  456. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -0
  457. package/dist/core/extensions/builtin/permission-system/parsers.js +150 -0
  458. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -0
  459. package/dist/core/extensions/builtin/permission-system/prompt.d.ts +4 -0
  460. package/dist/core/extensions/builtin/permission-system/prompt.d.ts.map +1 -0
  461. package/dist/core/extensions/builtin/permission-system/prompt.js +74 -0
  462. package/dist/core/extensions/builtin/permission-system/prompt.js.map +1 -0
  463. package/dist/core/extensions/builtin/permission-system/service.d.ts +27 -0
  464. package/dist/core/extensions/builtin/permission-system/service.d.ts.map +1 -0
  465. package/dist/core/extensions/builtin/permission-system/service.js +129 -0
  466. package/dist/core/extensions/builtin/permission-system/service.js.map +1 -0
  467. package/dist/core/extensions/builtin/permission-system/settings.d.ts +18 -0
  468. package/dist/core/extensions/builtin/permission-system/settings.d.ts.map +1 -0
  469. package/dist/core/extensions/builtin/permission-system/settings.js +23 -0
  470. package/dist/core/extensions/builtin/permission-system/settings.js.map +1 -0
  471. package/dist/core/extensions/builtin/permission-system/storage.d.ts +6 -0
  472. package/dist/core/extensions/builtin/permission-system/storage.d.ts.map +1 -0
  473. package/dist/core/extensions/builtin/permission-system/storage.js +58 -0
  474. package/dist/core/extensions/builtin/permission-system/storage.js.map +1 -0
  475. package/dist/core/extensions/builtin/permission-system/types.d.ts +61 -0
  476. package/dist/core/extensions/builtin/permission-system/types.d.ts.map +1 -0
  477. package/dist/core/extensions/builtin/permission-system/types.js +29 -0
  478. package/dist/core/extensions/builtin/permission-system/types.js.map +1 -0
  479. package/dist/core/extensions/builtin/permission-system/wildcard.d.ts +4 -0
  480. package/dist/core/extensions/builtin/permission-system/wildcard.d.ts.map +1 -0
  481. package/dist/core/extensions/builtin/permission-system/wildcard.js +58 -0
  482. package/dist/core/extensions/builtin/permission-system/wildcard.js.map +1 -0
  483. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts +3 -0
  484. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -0
  485. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +8 -0
  486. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -0
  487. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts +3 -0
  488. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -0
  489. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +8 -0
  490. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -0
  491. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts +3 -0
  492. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -0
  493. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +10 -0
  494. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -0
  495. package/dist/core/extensions/builtin/prompt-preset/file-operations.d.ts +2 -0
  496. package/dist/core/extensions/builtin/prompt-preset/file-operations.d.ts.map +1 -0
  497. package/dist/core/extensions/builtin/prompt-preset/file-operations.js +31 -0
  498. package/dist/core/extensions/builtin/prompt-preset/file-operations.js.map +1 -0
  499. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.d.ts +3 -0
  500. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.d.ts.map +1 -0
  501. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +17 -0
  502. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -0
  503. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.d.ts +3 -0
  504. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.d.ts.map +1 -0
  505. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +15 -0
  506. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -0
  507. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.d.ts +3 -0
  508. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.d.ts.map +1 -0
  509. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +15 -0
  510. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -0
  511. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts +3 -0
  512. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -0
  513. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +21 -0
  514. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -0
  515. package/dist/core/extensions/builtin/prompt-preset/gpt-5.d.ts +3 -0
  516. package/dist/core/extensions/builtin/prompt-preset/gpt-5.d.ts.map +1 -0
  517. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +13 -0
  518. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -0
  519. package/dist/core/extensions/builtin/prompt-preset/index.d.ts +3 -0
  520. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -0
  521. package/dist/core/extensions/builtin/prompt-preset/index.js +56 -0
  522. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -0
  523. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts +3 -0
  524. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts.map +1 -0
  525. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +10 -0
  526. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -0
  527. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts +12 -0
  528. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -0
  529. package/dist/core/extensions/builtin/prompt-preset/presets.js +101 -0
  530. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -0
  531. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +7 -0
  532. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -0
  533. package/dist/core/extensions/builtin/prompt-preset/settings.js +26 -0
  534. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -0
  535. package/dist/core/extensions/builtin/prompt-url-widget.d.ts +3 -0
  536. package/dist/core/extensions/builtin/prompt-url-widget.d.ts.map +1 -0
  537. package/dist/core/extensions/builtin/prompt-url-widget.js +127 -0
  538. package/dist/core/extensions/builtin/prompt-url-widget.js.map +1 -0
  539. package/dist/core/extensions/builtin/redraws.d.ts +8 -0
  540. package/dist/core/extensions/builtin/redraws.d.ts.map +1 -0
  541. package/dist/core/extensions/builtin/redraws.js +23 -0
  542. package/dist/core/extensions/builtin/redraws.js.map +1 -0
  543. package/dist/core/extensions/builtin/service-tier.d.ts +6 -0
  544. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -0
  545. package/dist/core/extensions/builtin/service-tier.js +29 -0
  546. package/dist/core/extensions/builtin/service-tier.js.map +1 -0
  547. package/dist/core/extensions/builtin/system-messages.d.ts +47 -0
  548. package/dist/core/extensions/builtin/system-messages.d.ts.map +1 -0
  549. package/dist/core/extensions/builtin/system-messages.js +117 -0
  550. package/dist/core/extensions/builtin/system-messages.js.map +1 -0
  551. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts +10 -0
  552. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts.map +1 -0
  553. package/dist/core/extensions/builtin/todotools/continuation/config.js +33 -0
  554. package/dist/core/extensions/builtin/todotools/continuation/config.js.map +1 -0
  555. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts +2 -0
  556. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts.map +1 -0
  557. package/dist/core/extensions/builtin/todotools/continuation/index.js +2 -0
  558. package/dist/core/extensions/builtin/todotools/continuation/index.js.map +1 -0
  559. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts +5 -0
  560. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts.map +1 -0
  561. package/dist/core/extensions/builtin/todotools/continuation/prompt.js +34 -0
  562. package/dist/core/extensions/builtin/todotools/continuation/prompt.js.map +1 -0
  563. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts +11 -0
  564. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts.map +1 -0
  565. package/dist/core/extensions/builtin/todotools/continuation/runtime.js +204 -0
  566. package/dist/core/extensions/builtin/todotools/continuation/runtime.js.map +1 -0
  567. package/dist/core/extensions/builtin/todotools/index.d.ts +5 -0
  568. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -0
  569. package/dist/core/extensions/builtin/todotools/index.js +39 -0
  570. package/dist/core/extensions/builtin/todotools/index.js.map +1 -0
  571. package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -0
  572. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -0
  573. package/dist/core/extensions/builtin/todotools/prompt.js +164 -0
  574. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -0
  575. package/dist/core/extensions/builtin/todotools/state.d.ts +29 -0
  576. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -0
  577. package/dist/core/extensions/builtin/todotools/state.js +74 -0
  578. package/dist/core/extensions/builtin/todotools/state.js.map +1 -0
  579. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts +4 -0
  580. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +1 -0
  581. package/dist/core/extensions/builtin/todotools/tools/todoread.js +35 -0
  582. package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +1 -0
  583. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts +10 -0
  584. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -0
  585. package/dist/core/extensions/builtin/todotools/tools/todowrite.js +92 -0
  586. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -0
  587. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts +4 -0
  588. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -0
  589. package/dist/core/extensions/builtin/tool-pair-guard/index.js +11 -0
  590. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -0
  591. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts +3 -0
  592. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +1 -0
  593. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js +75 -0
  594. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +1 -0
  595. package/dist/core/extensions/builtin/tps.d.ts +3 -0
  596. package/dist/core/extensions/builtin/tps.d.ts.map +1 -0
  597. package/dist/core/extensions/builtin/tps.js +65 -0
  598. package/dist/core/extensions/builtin/tps.js.map +1 -0
  599. package/dist/core/extensions/index.d.ts +12 -0
  600. package/dist/core/extensions/index.d.ts.map +1 -0
  601. package/dist/core/extensions/index.js +9 -0
  602. package/dist/core/extensions/index.js.map +1 -0
  603. package/dist/core/extensions/loader.d.ts +27 -0
  604. package/dist/core/extensions/loader.d.ts.map +1 -0
  605. package/dist/core/extensions/loader.js +505 -0
  606. package/dist/core/extensions/loader.js.map +1 -0
  607. package/dist/core/extensions/runner.d.ts +164 -0
  608. package/dist/core/extensions/runner.d.ts.map +1 -0
  609. package/dist/core/extensions/runner.js +900 -0
  610. package/dist/core/extensions/runner.js.map +1 -0
  611. package/dist/core/extensions/types.d.ts +1240 -0
  612. package/dist/core/extensions/types.d.ts.map +1 -0
  613. package/dist/core/extensions/types.js +45 -0
  614. package/dist/core/extensions/types.js.map +1 -0
  615. package/dist/core/extensions/wrapper.d.ts +20 -0
  616. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  617. package/dist/core/extensions/wrapper.js +22 -0
  618. package/dist/core/extensions/wrapper.js.map +1 -0
  619. package/dist/core/footer-data-provider.d.ts +52 -0
  620. package/dist/core/footer-data-provider.d.ts.map +1 -0
  621. package/dist/core/footer-data-provider.js +310 -0
  622. package/dist/core/footer-data-provider.js.map +1 -0
  623. package/dist/core/index.d.ts +12 -0
  624. package/dist/core/index.d.ts.map +1 -0
  625. package/dist/core/index.js +12 -0
  626. package/dist/core/index.js.map +1 -0
  627. package/dist/core/keybindings.d.ts +353 -0
  628. package/dist/core/keybindings.d.ts.map +1 -0
  629. package/dist/core/keybindings.js +295 -0
  630. package/dist/core/keybindings.js.map +1 -0
  631. package/dist/core/messages.d.ts +79 -0
  632. package/dist/core/messages.d.ts.map +1 -0
  633. package/dist/core/messages.js +138 -0
  634. package/dist/core/messages.js.map +1 -0
  635. package/dist/core/model-registry.d.ts +177 -0
  636. package/dist/core/model-registry.d.ts.map +1 -0
  637. package/dist/core/model-registry.js +853 -0
  638. package/dist/core/model-registry.js.map +1 -0
  639. package/dist/core/model-resolver.d.ts +116 -0
  640. package/dist/core/model-resolver.d.ts.map +1 -0
  641. package/dist/core/model-resolver.js +498 -0
  642. package/dist/core/model-resolver.js.map +1 -0
  643. package/dist/core/output-guard.d.ts +6 -0
  644. package/dist/core/output-guard.d.ts.map +1 -0
  645. package/dist/core/output-guard.js +59 -0
  646. package/dist/core/output-guard.js.map +1 -0
  647. package/dist/core/package-manager.d.ts +198 -0
  648. package/dist/core/package-manager.d.ts.map +1 -0
  649. package/dist/core/package-manager.js +1995 -0
  650. package/dist/core/package-manager.js.map +1 -0
  651. package/dist/core/prompt-templates.d.ts +52 -0
  652. package/dist/core/prompt-templates.d.ts.map +1 -0
  653. package/dist/core/prompt-templates.js +250 -0
  654. package/dist/core/prompt-templates.js.map +1 -0
  655. package/dist/core/provider-display-names.d.ts +2 -0
  656. package/dist/core/provider-display-names.d.ts.map +1 -0
  657. package/dist/core/provider-display-names.js +33 -0
  658. package/dist/core/provider-display-names.js.map +1 -0
  659. package/dist/core/resolve-config-value.d.ts +23 -0
  660. package/dist/core/resolve-config-value.d.ts.map +1 -0
  661. package/dist/core/resolve-config-value.js +126 -0
  662. package/dist/core/resolve-config-value.js.map +1 -0
  663. package/dist/core/resource-loader.d.ts +184 -0
  664. package/dist/core/resource-loader.d.ts.map +1 -0
  665. package/dist/core/resource-loader.js +771 -0
  666. package/dist/core/resource-loader.js.map +1 -0
  667. package/dist/core/sdk.d.ts +129 -0
  668. package/dist/core/sdk.d.ts.map +1 -0
  669. package/dist/core/sdk.js +339 -0
  670. package/dist/core/sdk.js.map +1 -0
  671. package/dist/core/session-cwd.d.ts +19 -0
  672. package/dist/core/session-cwd.d.ts.map +1 -0
  673. package/dist/core/session-cwd.js +38 -0
  674. package/dist/core/session-cwd.js.map +1 -0
  675. package/dist/core/session-manager.d.ts +333 -0
  676. package/dist/core/session-manager.d.ts.map +1 -0
  677. package/dist/core/session-manager.js +1128 -0
  678. package/dist/core/session-manager.js.map +1 -0
  679. package/dist/core/settings-manager.d.ts +294 -0
  680. package/dist/core/settings-manager.d.ts.map +1 -0
  681. package/dist/core/settings-manager.js +810 -0
  682. package/dist/core/settings-manager.js.map +1 -0
  683. package/dist/core/skills.d.ts +60 -0
  684. package/dist/core/skills.d.ts.map +1 -0
  685. package/dist/core/skills.js +404 -0
  686. package/dist/core/skills.js.map +1 -0
  687. package/dist/core/slash-commands.d.ts +14 -0
  688. package/dist/core/slash-commands.d.ts.map +1 -0
  689. package/dist/core/slash-commands.js +25 -0
  690. package/dist/core/slash-commands.js.map +1 -0
  691. package/dist/core/source-info.d.ts +18 -0
  692. package/dist/core/source-info.d.ts.map +1 -0
  693. package/dist/core/source-info.js +19 -0
  694. package/dist/core/source-info.js.map +1 -0
  695. package/dist/core/system-prompt.d.ts +28 -0
  696. package/dist/core/system-prompt.d.ts.map +1 -0
  697. package/dist/core/system-prompt.js +120 -0
  698. package/dist/core/system-prompt.js.map +1 -0
  699. package/dist/core/telemetry.d.ts +3 -0
  700. package/dist/core/telemetry.d.ts.map +1 -0
  701. package/dist/core/telemetry.js +9 -0
  702. package/dist/core/telemetry.js.map +1 -0
  703. package/dist/core/timings.d.ts +8 -0
  704. package/dist/core/timings.d.ts.map +1 -0
  705. package/dist/core/timings.js +31 -0
  706. package/dist/core/timings.js.map +1 -0
  707. package/dist/core/tools/bash.d.ts +68 -0
  708. package/dist/core/tools/bash.d.ts.map +1 -0
  709. package/dist/core/tools/bash.js +335 -0
  710. package/dist/core/tools/bash.js.map +1 -0
  711. package/dist/core/tools/edit-diff.d.ts +85 -0
  712. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  713. package/dist/core/tools/edit-diff.js +338 -0
  714. package/dist/core/tools/edit-diff.js.map +1 -0
  715. package/dist/core/tools/edit.d.ts +49 -0
  716. package/dist/core/tools/edit.d.ts.map +1 -0
  717. package/dist/core/tools/edit.js +324 -0
  718. package/dist/core/tools/edit.js.map +1 -0
  719. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  720. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  721. package/dist/core/tools/file-mutation-queue.js +37 -0
  722. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  723. package/dist/core/tools/find.d.ts +35 -0
  724. package/dist/core/tools/find.d.ts.map +1 -0
  725. package/dist/core/tools/find.js +298 -0
  726. package/dist/core/tools/find.js.map +1 -0
  727. package/dist/core/tools/grep.d.ts +37 -0
  728. package/dist/core/tools/grep.d.ts.map +1 -0
  729. package/dist/core/tools/grep.js +304 -0
  730. package/dist/core/tools/grep.js.map +1 -0
  731. package/dist/core/tools/index.d.ts +40 -0
  732. package/dist/core/tools/index.d.ts.map +1 -0
  733. package/dist/core/tools/index.js +112 -0
  734. package/dist/core/tools/index.js.map +1 -0
  735. package/dist/core/tools/ls.d.ts +37 -0
  736. package/dist/core/tools/ls.d.ts.map +1 -0
  737. package/dist/core/tools/ls.js +169 -0
  738. package/dist/core/tools/ls.js.map +1 -0
  739. package/dist/core/tools/output-accumulator.d.ts +50 -0
  740. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  741. package/dist/core/tools/output-accumulator.js +178 -0
  742. package/dist/core/tools/output-accumulator.js.map +1 -0
  743. package/dist/core/tools/path-utils.d.ts +8 -0
  744. package/dist/core/tools/path-utils.d.ts.map +1 -0
  745. package/dist/core/tools/path-utils.js +81 -0
  746. package/dist/core/tools/path-utils.js.map +1 -0
  747. package/dist/core/tools/read.d.ts +35 -0
  748. package/dist/core/tools/read.d.ts.map +1 -0
  749. package/dist/core/tools/read.js +289 -0
  750. package/dist/core/tools/read.js.map +1 -0
  751. package/dist/core/tools/render-utils.d.ts +21 -0
  752. package/dist/core/tools/render-utils.d.ts.map +1 -0
  753. package/dist/core/tools/render-utils.js +49 -0
  754. package/dist/core/tools/render-utils.js.map +1 -0
  755. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  756. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  757. package/dist/core/tools/tool-definition-wrapper.js +36 -0
  758. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  759. package/dist/core/tools/truncate.d.ts +70 -0
  760. package/dist/core/tools/truncate.d.ts.map +1 -0
  761. package/dist/core/tools/truncate.js +205 -0
  762. package/dist/core/tools/truncate.js.map +1 -0
  763. package/dist/core/tools/write.d.ts +26 -0
  764. package/dist/core/tools/write.d.ts.map +1 -0
  765. package/dist/core/tools/write.js +213 -0
  766. package/dist/core/tools/write.js.map +1 -0
  767. package/dist/index.d.ts +28 -0
  768. package/dist/index.d.ts.map +1 -0
  769. package/dist/index.js +41 -0
  770. package/dist/index.js.map +1 -0
  771. package/dist/main.d.ts +12 -0
  772. package/dist/main.d.ts.map +1 -0
  773. package/dist/main.js +603 -0
  774. package/dist/main.js.map +1 -0
  775. package/dist/migrations.d.ts +33 -0
  776. package/dist/migrations.d.ts.map +1 -0
  777. package/dist/migrations.js +311 -0
  778. package/dist/migrations.js.map +1 -0
  779. package/dist/modes/index.d.ts +9 -0
  780. package/dist/modes/index.d.ts.map +1 -0
  781. package/dist/modes/index.js +8 -0
  782. package/dist/modes/index.js.map +1 -0
  783. package/dist/modes/interactive/components/armin.d.ts +34 -0
  784. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  785. package/dist/modes/interactive/components/armin.js +333 -0
  786. package/dist/modes/interactive/components/armin.js.map +1 -0
  787. package/dist/modes/interactive/components/assistant-message.d.ts +32 -0
  788. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  789. package/dist/modes/interactive/components/assistant-message.js +209 -0
  790. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  791. package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
  792. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  793. package/dist/modes/interactive/components/bash-execution.js +175 -0
  794. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  795. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  796. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  797. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  798. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  799. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  800. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  801. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  802. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  803. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  804. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  805. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  806. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  807. package/dist/modes/interactive/components/config-selector.d.ts +71 -0
  808. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  809. package/dist/modes/interactive/components/config-selector.js +503 -0
  810. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  811. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  812. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  813. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  814. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  815. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  816. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  817. package/dist/modes/interactive/components/custom-editor.js +70 -0
  818. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  819. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  820. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  821. package/dist/modes/interactive/components/custom-message.js +79 -0
  822. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  823. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  824. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  825. package/dist/modes/interactive/components/daxnuts.js +140 -0
  826. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  827. package/dist/modes/interactive/components/diff.d.ts +12 -0
  828. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  829. package/dist/modes/interactive/components/diff.js +133 -0
  830. package/dist/modes/interactive/components/diff.js.map +1 -0
  831. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  832. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  833. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  834. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  835. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  836. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  837. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  838. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  839. package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
  840. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  841. package/dist/modes/interactive/components/extension-editor.js +111 -0
  842. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  843. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  844. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  845. package/dist/modes/interactive/components/extension-input.js +61 -0
  846. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  847. package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
  848. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  849. package/dist/modes/interactive/components/extension-selector.js +78 -0
  850. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  851. package/dist/modes/interactive/components/favorite-models-selector.d.ts +42 -0
  852. package/dist/modes/interactive/components/favorite-models-selector.d.ts.map +1 -0
  853. package/dist/modes/interactive/components/favorite-models-selector.js +302 -0
  854. package/dist/modes/interactive/components/favorite-models-selector.js.map +1 -0
  855. package/dist/modes/interactive/components/footer.d.ts +27 -0
  856. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  857. package/dist/modes/interactive/components/footer.js +193 -0
  858. package/dist/modes/interactive/components/footer.js.map +1 -0
  859. package/dist/modes/interactive/components/index.d.ts +32 -0
  860. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  861. package/dist/modes/interactive/components/index.js +33 -0
  862. package/dist/modes/interactive/components/index.js.map +1 -0
  863. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  864. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  865. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  866. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  867. package/dist/modes/interactive/components/login-dialog.d.ts +46 -0
  868. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  869. package/dist/modes/interactive/components/login-dialog.js +160 -0
  870. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  871. package/dist/modes/interactive/components/model-selector.d.ts +48 -0
  872. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  873. package/dist/modes/interactive/components/model-selector.js +279 -0
  874. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  875. package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
  876. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  877. package/dist/modes/interactive/components/oauth-selector.js +165 -0
  878. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  879. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  880. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  881. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  882. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  883. package/dist/modes/interactive/components/session-selector.d.ts +96 -0
  884. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  885. package/dist/modes/interactive/components/session-selector.js +861 -0
  886. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  887. package/dist/modes/interactive/components/settings-selector.d.ts +67 -0
  888. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  889. package/dist/modes/interactive/components/settings-selector.js +376 -0
  890. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  891. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  892. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  893. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  894. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  895. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  896. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  897. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  898. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  899. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  900. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  901. package/dist/modes/interactive/components/theme-selector.js +50 -0
  902. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  903. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  904. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  905. package/dist/modes/interactive/components/thinking-selector.js +52 -0
  906. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  907. package/dist/modes/interactive/components/tool-execution.d.ts +66 -0
  908. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  909. package/dist/modes/interactive/components/tool-execution.js +339 -0
  910. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  911. package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
  912. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  913. package/dist/modes/interactive/components/tree-selector.js +1102 -0
  914. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  915. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  916. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  917. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  918. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  919. package/dist/modes/interactive/components/user-message.d.ts +10 -0
  920. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  921. package/dist/modes/interactive/components/user-message.js +29 -0
  922. package/dist/modes/interactive/components/user-message.js.map +1 -0
  923. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  924. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  925. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  926. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  927. package/dist/modes/interactive/interactive-mode.d.ts +360 -0
  928. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  929. package/dist/modes/interactive/interactive-mode.js +4615 -0
  930. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  931. package/dist/modes/interactive/startup-tools.d.ts +8 -0
  932. package/dist/modes/interactive/startup-tools.d.ts.map +1 -0
  933. package/dist/modes/interactive/startup-tools.js +6 -0
  934. package/dist/modes/interactive/startup-tools.js.map +1 -0
  935. package/dist/modes/interactive/theme/theme.d.ts +81 -0
  936. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  937. package/dist/modes/interactive/theme/theme.js +973 -0
  938. package/dist/modes/interactive/theme/theme.js.map +1 -0
  939. package/dist/modes/print-mode.d.ts +28 -0
  940. package/dist/modes/print-mode.d.ts.map +1 -0
  941. package/dist/modes/print-mode.js +144 -0
  942. package/dist/modes/print-mode.js.map +1 -0
  943. package/dist/modes/rpc/jsonl.d.ts +17 -0
  944. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  945. package/dist/modes/rpc/jsonl.js +49 -0
  946. package/dist/modes/rpc/jsonl.js.map +1 -0
  947. package/dist/modes/rpc/rpc-client.d.ts +224 -0
  948. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  949. package/dist/modes/rpc/rpc-client.js +410 -0
  950. package/dist/modes/rpc/rpc-client.js.map +1 -0
  951. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  952. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  953. package/dist/modes/rpc/rpc-mode.js +601 -0
  954. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  955. package/dist/modes/rpc/rpc-types.d.ts +419 -0
  956. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  957. package/dist/modes/rpc/rpc-types.js +8 -0
  958. package/dist/modes/rpc/rpc-types.js.map +1 -0
  959. package/dist/package-manager-cli.d.ts +4 -0
  960. package/dist/package-manager-cli.d.ts.map +1 -0
  961. package/dist/package-manager-cli.js +460 -0
  962. package/dist/package-manager-cli.js.map +1 -0
  963. package/dist/senpi +20 -0
  964. package/dist/utils/changelog.d.ts +21 -0
  965. package/dist/utils/changelog.d.ts.map +1 -0
  966. package/dist/utils/changelog.js +87 -0
  967. package/dist/utils/changelog.js.map +1 -0
  968. package/dist/utils/child-process.d.ts +12 -0
  969. package/dist/utils/child-process.d.ts.map +1 -0
  970. package/dist/utils/child-process.js +86 -0
  971. package/dist/utils/child-process.js.map +1 -0
  972. package/dist/utils/clipboard-image.d.ts +11 -0
  973. package/dist/utils/clipboard-image.d.ts.map +1 -0
  974. package/dist/utils/clipboard-image.js +245 -0
  975. package/dist/utils/clipboard-image.js.map +1 -0
  976. package/dist/utils/clipboard-native.d.ts +8 -0
  977. package/dist/utils/clipboard-native.d.ts.map +1 -0
  978. package/dist/utils/clipboard-native.js +14 -0
  979. package/dist/utils/clipboard-native.js.map +1 -0
  980. package/dist/utils/clipboard.d.ts +2 -0
  981. package/dist/utils/clipboard.d.ts.map +1 -0
  982. package/dist/utils/clipboard.js +117 -0
  983. package/dist/utils/clipboard.js.map +1 -0
  984. package/dist/utils/exif-orientation.d.ts +5 -0
  985. package/dist/utils/exif-orientation.d.ts.map +1 -0
  986. package/dist/utils/exif-orientation.js +158 -0
  987. package/dist/utils/exif-orientation.js.map +1 -0
  988. package/dist/utils/frontmatter.d.ts +8 -0
  989. package/dist/utils/frontmatter.d.ts.map +1 -0
  990. package/dist/utils/frontmatter.js +26 -0
  991. package/dist/utils/frontmatter.js.map +1 -0
  992. package/dist/utils/fs-watch.d.ts +5 -0
  993. package/dist/utils/fs-watch.d.ts.map +1 -0
  994. package/dist/utils/fs-watch.js +25 -0
  995. package/dist/utils/fs-watch.js.map +1 -0
  996. package/dist/utils/git.d.ts +26 -0
  997. package/dist/utils/git.d.ts.map +1 -0
  998. package/dist/utils/git.js +163 -0
  999. package/dist/utils/git.js.map +1 -0
  1000. package/dist/utils/image-convert.d.ts +9 -0
  1001. package/dist/utils/image-convert.d.ts.map +1 -0
  1002. package/dist/utils/image-convert.js +39 -0
  1003. package/dist/utils/image-convert.js.map +1 -0
  1004. package/dist/utils/image-resize.d.ts +36 -0
  1005. package/dist/utils/image-resize.d.ts.map +1 -0
  1006. package/dist/utils/image-resize.js +137 -0
  1007. package/dist/utils/image-resize.js.map +1 -0
  1008. package/dist/utils/mime.d.ts +2 -0
  1009. package/dist/utils/mime.d.ts.map +1 -0
  1010. package/dist/utils/mime.js +26 -0
  1011. package/dist/utils/mime.js.map +1 -0
  1012. package/dist/utils/paths.d.ts +16 -0
  1013. package/dist/utils/paths.d.ts.map +1 -0
  1014. package/dist/utils/paths.js +50 -0
  1015. package/dist/utils/paths.js.map +1 -0
  1016. package/dist/utils/photon.d.ts +21 -0
  1017. package/dist/utils/photon.d.ts.map +1 -0
  1018. package/dist/utils/photon.js +121 -0
  1019. package/dist/utils/photon.js.map +1 -0
  1020. package/dist/utils/pi-user-agent.d.ts +2 -0
  1021. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  1022. package/dist/utils/pi-user-agent.js +6 -0
  1023. package/dist/utils/pi-user-agent.js.map +1 -0
  1024. package/dist/utils/shell.d.ts +30 -0
  1025. package/dist/utils/shell.d.ts.map +1 -0
  1026. package/dist/utils/shell.js +190 -0
  1027. package/dist/utils/shell.js.map +1 -0
  1028. package/dist/utils/sleep.d.ts +5 -0
  1029. package/dist/utils/sleep.d.ts.map +1 -0
  1030. package/dist/utils/sleep.js +17 -0
  1031. package/dist/utils/sleep.js.map +1 -0
  1032. package/dist/utils/tools-manager.d.ts +3 -0
  1033. package/dist/utils/tools-manager.d.ts.map +1 -0
  1034. package/dist/utils/tools-manager.js +256 -0
  1035. package/dist/utils/tools-manager.js.map +1 -0
  1036. package/dist/utils/version-check.d.ts +14 -0
  1037. package/dist/utils/version-check.d.ts.map +1 -0
  1038. package/dist/utils/version-check.js +78 -0
  1039. package/dist/utils/version-check.js.map +1 -0
  1040. package/docs/agents.md +348 -0
  1041. package/docs/compaction-guide.md +240 -0
  1042. package/docs/compaction.md +394 -0
  1043. package/docs/custom-provider.md +646 -0
  1044. package/docs/development.md +80 -0
  1045. package/docs/docs.json +148 -0
  1046. package/docs/extensions.md +2596 -0
  1047. package/docs/images/doom-extension.png +0 -0
  1048. package/docs/images/exy.png +0 -0
  1049. package/docs/images/interactive-mode.png +0 -0
  1050. package/docs/images/tree-view.png +0 -0
  1051. package/docs/index.md +66 -0
  1052. package/docs/json.md +82 -0
  1053. package/docs/keybindings.md +197 -0
  1054. package/docs/models.md +474 -0
  1055. package/docs/packages.md +223 -0
  1056. package/docs/prompt-templates.md +88 -0
  1057. package/docs/providers.md +243 -0
  1058. package/docs/quickstart.md +142 -0
  1059. package/docs/rpc.md +1407 -0
  1060. package/docs/sdk.md +1149 -0
  1061. package/docs/session-format.md +412 -0
  1062. package/docs/sessions.md +137 -0
  1063. package/docs/settings.md +330 -0
  1064. package/docs/shell-aliases.md +13 -0
  1065. package/docs/skills.md +232 -0
  1066. package/docs/terminal-setup.md +106 -0
  1067. package/docs/termux.md +127 -0
  1068. package/docs/themes.md +295 -0
  1069. package/docs/tmux.md +61 -0
  1070. package/docs/tui.md +918 -0
  1071. package/docs/usage.md +277 -0
  1072. package/docs/windows.md +17 -0
  1073. package/examples/README.md +25 -0
  1074. package/examples/extensions/README.md +208 -0
  1075. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  1076. package/examples/extensions/bash-spawn-hook.ts +30 -0
  1077. package/examples/extensions/bookmark.ts +50 -0
  1078. package/examples/extensions/border-status-editor.ts +150 -0
  1079. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  1080. package/examples/extensions/claude-rules.ts +86 -0
  1081. package/examples/extensions/commands.ts +72 -0
  1082. package/examples/extensions/confirm-destructive.ts +59 -0
  1083. package/examples/extensions/custom-compaction.ts +127 -0
  1084. package/examples/extensions/custom-footer.ts +64 -0
  1085. package/examples/extensions/custom-header.ts +73 -0
  1086. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  1087. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  1088. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  1089. package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
  1090. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  1091. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  1092. package/examples/extensions/dirty-repo-guard.ts +56 -0
  1093. package/examples/extensions/doom-overlay/README.md +46 -0
  1094. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  1095. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  1096. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  1097. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  1098. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  1099. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  1100. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  1101. package/examples/extensions/doom-overlay/index.ts +74 -0
  1102. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  1103. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  1104. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  1105. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  1106. package/examples/extensions/dynamic-resources/index.ts +15 -0
  1107. package/examples/extensions/dynamic-tools.ts +74 -0
  1108. package/examples/extensions/event-bus.ts +43 -0
  1109. package/examples/extensions/file-trigger.ts +41 -0
  1110. package/examples/extensions/git-checkpoint.ts +53 -0
  1111. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  1112. package/examples/extensions/handoff.ts +191 -0
  1113. package/examples/extensions/hello.ts +26 -0
  1114. package/examples/extensions/hidden-thinking-label.ts +53 -0
  1115. package/examples/extensions/inline-bash.ts +94 -0
  1116. package/examples/extensions/input-transform.ts +43 -0
  1117. package/examples/extensions/interactive-shell.ts +196 -0
  1118. package/examples/extensions/mac-system-theme.ts +47 -0
  1119. package/examples/extensions/message-renderer.ts +59 -0
  1120. package/examples/extensions/minimal-mode.ts +426 -0
  1121. package/examples/extensions/modal-editor.ts +85 -0
  1122. package/examples/extensions/model-status.ts +31 -0
  1123. package/examples/extensions/notify.ts +55 -0
  1124. package/examples/extensions/overlay-qa-tests.ts +1348 -0
  1125. package/examples/extensions/overlay-test.ts +150 -0
  1126. package/examples/extensions/permission-gate.ts +34 -0
  1127. package/examples/extensions/pirate.ts +47 -0
  1128. package/examples/extensions/plan-mode/README.md +65 -0
  1129. package/examples/extensions/plan-mode/index.ts +340 -0
  1130. package/examples/extensions/plan-mode/utils.ts +168 -0
  1131. package/examples/extensions/preset.ts +436 -0
  1132. package/examples/extensions/prompt-customizer.ts +97 -0
  1133. package/examples/extensions/protected-paths.ts +30 -0
  1134. package/examples/extensions/provider-payload.ts +18 -0
  1135. package/examples/extensions/qna.ts +122 -0
  1136. package/examples/extensions/question.ts +264 -0
  1137. package/examples/extensions/questionnaire.ts +427 -0
  1138. package/examples/extensions/rainbow-editor.ts +88 -0
  1139. package/examples/extensions/reload-runtime.ts +37 -0
  1140. package/examples/extensions/rpc-demo.ts +118 -0
  1141. package/examples/extensions/sandbox/index.ts +321 -0
  1142. package/examples/extensions/sandbox/package-lock.json +92 -0
  1143. package/examples/extensions/sandbox/package.json +19 -0
  1144. package/examples/extensions/send-user-message.ts +97 -0
  1145. package/examples/extensions/session-name.ts +27 -0
  1146. package/examples/extensions/shutdown-command.ts +63 -0
  1147. package/examples/extensions/snake.ts +343 -0
  1148. package/examples/extensions/space-invaders.ts +560 -0
  1149. package/examples/extensions/ssh.ts +220 -0
  1150. package/examples/extensions/status-line.ts +32 -0
  1151. package/examples/extensions/structured-output.ts +65 -0
  1152. package/examples/extensions/subagent/README.md +172 -0
  1153. package/examples/extensions/subagent/agents/planner.md +37 -0
  1154. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  1155. package/examples/extensions/subagent/agents/scout.md +50 -0
  1156. package/examples/extensions/subagent/agents/worker.md +24 -0
  1157. package/examples/extensions/subagent/agents.ts +126 -0
  1158. package/examples/extensions/subagent/index.ts +987 -0
  1159. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  1160. package/examples/extensions/subagent/prompts/implement.md +10 -0
  1161. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  1162. package/examples/extensions/summarize.ts +206 -0
  1163. package/examples/extensions/system-prompt-header.ts +17 -0
  1164. package/examples/extensions/tic-tac-toe.ts +1008 -0
  1165. package/examples/extensions/timed-confirm.ts +70 -0
  1166. package/examples/extensions/titlebar-spinner.ts +58 -0
  1167. package/examples/extensions/todo.ts +297 -0
  1168. package/examples/extensions/tool-override.ts +144 -0
  1169. package/examples/extensions/tools.ts +141 -0
  1170. package/examples/extensions/trigger-compact.ts +50 -0
  1171. package/examples/extensions/truncated-tool.ts +195 -0
  1172. package/examples/extensions/widget-placement.ts +9 -0
  1173. package/examples/extensions/with-deps/index.ts +32 -0
  1174. package/examples/extensions/with-deps/package-lock.json +31 -0
  1175. package/examples/extensions/with-deps/package.json +22 -0
  1176. package/examples/extensions/working-indicator.ts +123 -0
  1177. package/examples/extensions/working-message-test.ts +25 -0
  1178. package/examples/rpc-extension-ui.ts +632 -0
  1179. package/examples/sdk/01-minimal.ts +22 -0
  1180. package/examples/sdk/02-custom-model.ts +49 -0
  1181. package/examples/sdk/03-custom-prompt.ts +72 -0
  1182. package/examples/sdk/04-skills.ts +55 -0
  1183. package/examples/sdk/05-tools.ts +44 -0
  1184. package/examples/sdk/06-extensions.ts +90 -0
  1185. package/examples/sdk/07-context-files.ts +42 -0
  1186. package/examples/sdk/08-prompt-templates.ts +51 -0
  1187. package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
  1188. package/examples/sdk/10-settings.ts +53 -0
  1189. package/examples/sdk/11-sessions.ts +48 -0
  1190. package/examples/sdk/12-full-control.ts +73 -0
  1191. package/examples/sdk/13-session-runtime.ts +67 -0
  1192. package/examples/sdk/README.md +147 -0
  1193. package/package.json +105 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-format.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/preview-format.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEX,iBAAiB,EAEjB,qBAAqB,EACrB,eAAe,EACf,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAkB5C,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAWjE;AAcD,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,iBAAiB,EAC1B,GAAG,GAAE,MAAsB,EAC3B,QAAQ,GAAE,OAAc,GACtB,MAAM,CA8BR;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMhE;AA4JD,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,qBAAqB,CA6BlH;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,iBAAiB,EAC1B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,OAAO,GACf,MAAM,CA6CR;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM,CAO5E","sourcesContent":["import path from \"node:path\";\nimport * as Diff from \"diff\";\nimport { getLanguageFromPath, highlightCode } from \"../../../../modes/interactive/theme/theme.js\";\nimport { parsePatch } from \"./parser.js\";\nimport { extractPatchedPaths } from \"./text.js\";\nimport type {\n\tApplyPatchOperation,\n\tApplyPatchPreview,\n\tApplyPatchPreviewFile,\n\tApplyPatchRenderState,\n\tApplyPatchTheme,\n} from \"./types.js\";\n\nexport const PATCH_PREVIEW_MAX_LINES = 16;\nexport const PATCH_PREVIEW_MAX_CHARS = 4000;\nconst PATCH_PREVIEW_HEAD_LINES = 8;\nconst PATCH_PREVIEW_TAIL_LINES = 8;\nconst applyPatchRenderStates = new Map<string, ApplyPatchRenderState>();\n\nfunction formatLineCountSummary(added: number, removed: number): string {\n\treturn `(+${added} -${removed})`;\n}\n\nfunction countLines(text: string): number {\n\tif (text.length === 0) return 0;\n\tlet lines = 1;\n\tfor (let index = 0; index < text.length; index++) {\n\t\tif (text.charCodeAt(index) === 10) lines += 1;\n\t}\n\treturn lines;\n}\n\nexport function truncatePreview(text: string): string {\n\tif (text.length <= PATCH_PREVIEW_MAX_CHARS && countLines(text) <= PATCH_PREVIEW_MAX_LINES) return text;\n\tconst lines = text.split(\"\\n\");\n\tconst head = lines.slice(0, PATCH_PREVIEW_HEAD_LINES);\n\tconst tail = lines.slice(-PATCH_PREVIEW_TAIL_LINES);\n\tlet preview = [...head, \"…\", ...tail].join(\"\\n\");\n\tif (preview.length > PATCH_PREVIEW_MAX_CHARS) preview = `${preview.slice(0, PATCH_PREVIEW_MAX_CHARS).trimEnd()}\\n…`;\n\treturn preview;\n}\n\nexport function displayPath(filePath: string, cwd: string): string {\n\tif (!path.isAbsolute(filePath)) return filePath;\n\tconst absoluteCwd = path.resolve(cwd);\n\tconst relativePath = path.relative(absoluteCwd, filePath);\n\tif (\n\t\trelativePath === \"\" ||\n\t\t(!relativePath.startsWith(`..${path.sep}`) && relativePath !== \"..\" && !path.isAbsolute(relativePath))\n\t) {\n\t\treturn relativePath || \".\";\n\t}\n\treturn filePath;\n}\n\nfunction formatPatchFilePath(file: ApplyPatchPreviewFile, cwd: string = process.cwd()): string {\n\tconst filePath = displayPath(file.filePath, cwd);\n\tif (!file.movePath) return filePath;\n\treturn `${filePath} → ${displayPath(file.movePath, cwd)}`;\n}\n\nfunction formatPatchOperation(operation: ApplyPatchOperation): string {\n\tif (operation === \"add\") return \"Added\";\n\tif (operation === \"delete\") return \"Deleted\";\n\treturn \"Edited\";\n}\n\nexport function formatPatchPreview(\n\tpreview: ApplyPatchPreview,\n\tcwd: string = process.cwd(),\n\texpanded: boolean = true,\n): string {\n\tconst lines: string[] = [];\n\tif (preview.files.length === 1) {\n\t\tconst file = preview.files[0];\n\t\tif (file) {\n\t\t\tlines.push(\n\t\t\t\t`• ${formatPatchOperation(file.operation)} ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`,\n\t\t\t);\n\t\t\tif (expanded && file.diff)\n\t\t\t\tlines.push(\n\t\t\t\t\t...truncatePreview(file.diff)\n\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t.map((line) => ` ${line}`),\n\t\t\t\t);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tconst noun = preview.files.length === 1 ? \"file\" : \"files\";\n\tlines.push(`• Edited ${preview.files.length} ${noun} ${formatLineCountSummary(preview.added, preview.removed)}`);\n\tfor (const file of preview.files) {\n\t\tlines.push(` └ ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`);\n\t\tif (expanded && file.diff)\n\t\t\tlines.push(\n\t\t\t\t...truncatePreview(file.diff)\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map((line) => ` ${line}`),\n\t\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatInFlightCallText(patchText: string): string {\n\tconst paths = extractPatchedPaths(patchText);\n\tif (paths.length === 0) return \"Patching\";\n\tconst noun = paths.length === 1 ? \"file\" : \"files\";\n\tconst count = paths.length > 1 ? ` (${paths.length} ${noun})` : \"\";\n\treturn `Patching${count}: ${paths.join(\", \")}`;\n}\n\ntype RenderableAddedDiffLine = { content: string; kind: \"added\"; lineNumber: string; sign: \"+\" };\ntype RenderableRemovedDiffLine = { content: string; kind: \"removed\"; lineNumber: string; sign: \"-\" };\ntype RenderableContextDiffLine = { content: string; kind: \"context\"; lineNumber: string; sign: \" \" };\ntype RenderableContentDiffLine = RenderableAddedDiffLine | RenderableContextDiffLine | RenderableRemovedDiffLine;\ntype RenderableDiffLine = RenderableContentDiffLine | { kind: \"meta\"; text: string };\n\nfunction parseRenderableDiffLine(line: string): RenderableDiffLine {\n\tconst match = line.match(/^([+\\- ])(\\s*\\d+)\\s(.*)$/);\n\tif (!match) return { kind: \"meta\", text: line };\n\n\tconst sign = match[1];\n\tconst lineNumber = match[2];\n\tif ((sign !== \"+\" && sign !== \"-\" && sign !== \" \") || lineNumber === undefined) return { kind: \"meta\", text: line };\n\n\tconst content = match[3] ?? \"\";\n\tif (sign === \"+\") return { content, kind: \"added\", lineNumber, sign };\n\tif (sign === \"-\") return { content, kind: \"removed\", lineNumber, sign };\n\treturn { content, kind: \"context\", lineNumber, sign };\n}\n\nfunction replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nfunction highlightDiffContent(content: string, filePath: string): string {\n\tconst plainContent = replaceTabs(content);\n\tconst language = getLanguageFromPath(filePath);\n\ttry {\n\t\treturn highlightCode(plainContent, language)[0] ?? plainContent;\n\t} catch {\n\t\treturn plainContent;\n\t}\n}\n\nfunction renderInlineDiff(\n\toldContent: string,\n\tnewContent: string,\n\ttheme: ApplyPatchTheme,\n): { added: string; removed: string } {\n\tconst parts = Diff.diffWords(replaceTabs(oldContent), replaceTabs(newContent));\n\tlet added = \"\";\n\tlet removed = \"\";\n\tlet firstAdded = true;\n\tlet firstRemoved = true;\n\n\tfor (const part of parts) {\n\t\tif (part.added) {\n\t\t\tlet value = part.value;\n\t\t\tif (firstAdded) {\n\t\t\t\tconst leadingWhitespace = value.match(/^(\\s*)/)?.[1] ?? \"\";\n\t\t\t\tadded += leadingWhitespace;\n\t\t\t\tvalue = value.slice(leadingWhitespace.length);\n\t\t\t\tfirstAdded = false;\n\t\t\t}\n\t\t\tif (value) added += theme.inverse(value);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (part.removed) {\n\t\t\tlet value = part.value;\n\t\t\tif (firstRemoved) {\n\t\t\t\tconst leadingWhitespace = value.match(/^(\\s*)/)?.[1] ?? \"\";\n\t\t\t\tremoved += leadingWhitespace;\n\t\t\t\tvalue = value.slice(leadingWhitespace.length);\n\t\t\t\tfirstRemoved = false;\n\t\t\t}\n\t\t\tif (value) removed += theme.inverse(value);\n\t\t\tcontinue;\n\t\t}\n\n\t\tadded += part.value;\n\t\tremoved += part.value;\n\t}\n\n\treturn { added, removed };\n}\n\nfunction renderOpenCodeLikeDiffLine(\n\tline: RenderableContentDiffLine,\n\tfilePath: string,\n\ttheme: ApplyPatchTheme,\n\tcontentOverride?: string,\n): string {\n\tconst lineNumber = theme.fg(\"muted\", line.lineNumber);\n\tif (line.kind === \"context\") {\n\t\treturn `${theme.fg(\"toolDiffContext\", line.sign)}${lineNumber} ${highlightDiffContent(line.content, filePath)}`;\n\t}\n\n\tconst diffColor = line.kind === \"added\" ? \"toolDiffAdded\" : \"toolDiffRemoved\";\n\tconst background = line.kind === \"added\" ? \"toolSuccessBg\" : \"toolErrorBg\";\n\tconst content =\n\t\tcontentOverride === undefined\n\t\t\t? highlightDiffContent(line.content, filePath)\n\t\t\t: theme.fg(diffColor, replaceTabs(contentOverride));\n\tconst rendered = `${theme.fg(diffColor, line.sign)}${lineNumber} ${content}`;\n\treturn theme.bg(background, rendered);\n}\n\nfunction renderOpenCodeLikeDiff(diffText: string, filePath: string, theme: ApplyPatchTheme): string {\n\tconst parsedLines = diffText.split(\"\\n\").map(parseRenderableDiffLine);\n\tconst rendered: string[] = [];\n\tlet index = 0;\n\n\twhile (index < parsedLines.length) {\n\t\tconst line = parsedLines[index];\n\t\tif (!line) {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (line.kind !== \"removed\") {\n\t\t\trendered.push(\n\t\t\t\tline.kind === \"meta\"\n\t\t\t\t\t? theme.fg(\"toolDiffContext\", line.text)\n\t\t\t\t\t: renderOpenCodeLikeDiffLine(line, filePath, theme),\n\t\t\t);\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst removedLines: RenderableRemovedDiffLine[] = [];\n\t\twhile (parsedLines[index]?.kind === \"removed\") {\n\t\t\tconst removedLine = parsedLines[index];\n\t\t\tif (removedLine?.kind === \"removed\") removedLines.push(removedLine);\n\t\t\tindex++;\n\t\t}\n\n\t\tconst addedLines: RenderableAddedDiffLine[] = [];\n\t\twhile (parsedLines[index]?.kind === \"added\") {\n\t\t\tconst addedLine = parsedLines[index];\n\t\t\tif (addedLine?.kind === \"added\") addedLines.push(addedLine);\n\t\t\tindex++;\n\t\t}\n\n\t\tconst pairedCount = Math.min(removedLines.length, addedLines.length);\n\t\tfor (let pairIndex = 0; pairIndex < pairedCount; pairIndex++) {\n\t\t\tconst removedLine = removedLines[pairIndex];\n\t\t\tconst addedLine = addedLines[pairIndex];\n\t\t\tif (!removedLine || !addedLine) continue;\n\n\t\t\tconst inline = renderInlineDiff(removedLine.content, addedLine.content, theme);\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(removedLine, filePath, theme, inline.removed));\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(addedLine, filePath, theme, inline.added));\n\t\t}\n\n\t\tfor (const removedLine of removedLines.slice(pairedCount))\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(removedLine, filePath, theme));\n\t\tfor (const addedLine of addedLines.slice(pairedCount))\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(addedLine, filePath, theme));\n\t}\n\n\treturn rendered.join(\"\\n\");\n}\n\nexport function getApplyPatchRenderState(toolCallId: string, cwd: string, patchText: string): ApplyPatchRenderState {\n\tconst existing = applyPatchRenderStates.get(toolCallId);\n\tif (existing && existing.cwd === cwd && existing.patchText === patchText) return existing;\n\n\tconst callText = formatInFlightCallText(patchText);\n\tlet collapsed = \"\";\n\tlet expanded = \"\";\n\ttry {\n\t\tconst hunks = parsePatch(patchText);\n\t\tif (hunks.length > 0) {\n\t\t\tconst files = hunks.map((hunk) => ({\n\t\t\t\tfilePath: hunk.filePath,\n\t\t\t\tmovePath: hunk.type === \"update\" ? hunk.movePath : undefined,\n\t\t\t\toperation: hunk.type,\n\t\t\t\tdiff: \"\",\n\t\t\t\tadded: 0,\n\t\t\t\tremoved: 0,\n\t\t\t})) satisfies ApplyPatchPreviewFile[];\n\t\t\tconst preview: ApplyPatchPreview = { files, added: 0, removed: 0 };\n\t\t\tcollapsed = formatPatchPreview(preview, cwd, false);\n\t\t\texpanded = formatPatchPreview(preview, cwd, true);\n\t\t}\n\t} catch {\n\t\t// ignore incomplete patch text\n\t}\n\n\tconst nextState: ApplyPatchRenderState = { ...existing, cwd, patchText, callText, collapsed, expanded };\n\tapplyPatchRenderStates.set(toolCallId, nextState);\n\treturn nextState;\n}\n\nexport function clearApplyPatchRenderState(): void {\n\tapplyPatchRenderStates.clear();\n}\n\nexport function renderPatchPreview(\n\tpreview: ApplyPatchPreview,\n\tcwd: string,\n\ttheme: ApplyPatchTheme,\n\texpanded: boolean,\n): string {\n\tif (expanded) {\n\t\ttry {\n\t\t\tconst renderFile = (file: ApplyPatchPreviewFile, headerPrefix: string): string => {\n\t\t\t\tconst header = `• ${formatPatchOperation(file.operation)} ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`;\n\t\t\t\tif (!file.diff) {\n\t\t\t\t\treturn headerPrefix.length > 0\n\t\t\t\t\t\t? `${headerPrefix}${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`\n\t\t\t\t\t\t: header;\n\t\t\t\t}\n\n\t\t\t\tconst renderedDiff = renderOpenCodeLikeDiff(\n\t\t\t\t\ttruncatePreview(file.diff),\n\t\t\t\t\tfile.movePath ?? file.filePath,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t\tif (headerPrefix.length > 0) {\n\t\t\t\t\tconst nestedHeader = `${headerPrefix}${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`;\n\t\t\t\t\treturn `${nestedHeader}\\n${renderedDiff\n\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t.map((line) => ` ${line}`)\n\t\t\t\t\t\t.join(\"\\n\")}`;\n\t\t\t\t}\n\t\t\t\treturn `${header}\\n${renderedDiff}`;\n\t\t\t};\n\n\t\t\tif (preview.files.length === 1) {\n\t\t\t\tconst file = preview.files[0];\n\t\t\t\treturn file ? renderFile(file, \"\") : \"\";\n\t\t\t}\n\n\t\t\tconst noun = preview.files.length === 1 ? \"file\" : \"files\";\n\t\t\tconst renderedFiles = preview.files.map((file) => renderFile(file, \" └ \")).join(\"\\n\");\n\t\t\tif (renderedFiles.length > 0) {\n\t\t\t\treturn `• Edited ${preview.files.length} ${noun} ${formatLineCountSummary(preview.added, preview.removed)}\\n${renderedFiles}`;\n\t\t\t}\n\t\t} catch {\n\t\t\t// fall back to manual themed line rendering\n\t\t}\n\t}\n\n\treturn formatPatchPreview(preview, cwd, expanded)\n\t\t.split(\"\\n\")\n\t\t.map((line) => renderPatchLine(line, theme))\n\t\t.join(\"\\n\");\n}\n\nexport function formatPendingPatchPaths(patchText: string): string {\n\tconst paths = extractPatchedPaths(patchText);\n\tif (paths.length === 0) return \"Applying patch...\";\n\treturn `Applying patch...\\n${paths.map((filePath) => `• ${filePath}`).join(\"\\n\")}`;\n}\n\nexport function renderPatchLine(line: string, theme: ApplyPatchTheme): string {\n\tconst trimmed = line.trimStart();\n\tif (trimmed.startsWith(\"+\")) return theme.fg(\"toolDiffAdded\", line);\n\tif (trimmed.startsWith(\"-\")) return theme.fg(\"toolDiffRemoved\", line);\n\tif (trimmed.startsWith(\"•\")) return theme.fg(\"toolTitle\", theme.bold(line));\n\tif (trimmed.startsWith(\"└\")) return theme.fg(\"accent\", line);\n\treturn theme.fg(\"toolDiffContext\", line);\n}\n"]}
@@ -0,0 +1,306 @@
1
+ import path from "node:path";
2
+ import * as Diff from "diff";
3
+ import { getLanguageFromPath, highlightCode } from "../../../../modes/interactive/theme/theme.js";
4
+ import { parsePatch } from "./parser.js";
5
+ import { extractPatchedPaths } from "./text.js";
6
+ export const PATCH_PREVIEW_MAX_LINES = 16;
7
+ export const PATCH_PREVIEW_MAX_CHARS = 4000;
8
+ const PATCH_PREVIEW_HEAD_LINES = 8;
9
+ const PATCH_PREVIEW_TAIL_LINES = 8;
10
+ const applyPatchRenderStates = new Map();
11
+ function formatLineCountSummary(added, removed) {
12
+ return `(+${added} -${removed})`;
13
+ }
14
+ function countLines(text) {
15
+ if (text.length === 0)
16
+ return 0;
17
+ let lines = 1;
18
+ for (let index = 0; index < text.length; index++) {
19
+ if (text.charCodeAt(index) === 10)
20
+ lines += 1;
21
+ }
22
+ return lines;
23
+ }
24
+ export function truncatePreview(text) {
25
+ if (text.length <= PATCH_PREVIEW_MAX_CHARS && countLines(text) <= PATCH_PREVIEW_MAX_LINES)
26
+ return text;
27
+ const lines = text.split("\n");
28
+ const head = lines.slice(0, PATCH_PREVIEW_HEAD_LINES);
29
+ const tail = lines.slice(-PATCH_PREVIEW_TAIL_LINES);
30
+ let preview = [...head, "…", ...tail].join("\n");
31
+ if (preview.length > PATCH_PREVIEW_MAX_CHARS)
32
+ preview = `${preview.slice(0, PATCH_PREVIEW_MAX_CHARS).trimEnd()}\n…`;
33
+ return preview;
34
+ }
35
+ export function displayPath(filePath, cwd) {
36
+ if (!path.isAbsolute(filePath))
37
+ return filePath;
38
+ const absoluteCwd = path.resolve(cwd);
39
+ const relativePath = path.relative(absoluteCwd, filePath);
40
+ if (relativePath === "" ||
41
+ (!relativePath.startsWith(`..${path.sep}`) && relativePath !== ".." && !path.isAbsolute(relativePath))) {
42
+ return relativePath || ".";
43
+ }
44
+ return filePath;
45
+ }
46
+ function formatPatchFilePath(file, cwd = process.cwd()) {
47
+ const filePath = displayPath(file.filePath, cwd);
48
+ if (!file.movePath)
49
+ return filePath;
50
+ return `${filePath} → ${displayPath(file.movePath, cwd)}`;
51
+ }
52
+ function formatPatchOperation(operation) {
53
+ if (operation === "add")
54
+ return "Added";
55
+ if (operation === "delete")
56
+ return "Deleted";
57
+ return "Edited";
58
+ }
59
+ export function formatPatchPreview(preview, cwd = process.cwd(), expanded = true) {
60
+ const lines = [];
61
+ if (preview.files.length === 1) {
62
+ const file = preview.files[0];
63
+ if (file) {
64
+ lines.push(`• ${formatPatchOperation(file.operation)} ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`);
65
+ if (expanded && file.diff)
66
+ lines.push(...truncatePreview(file.diff)
67
+ .split("\n")
68
+ .map((line) => ` ${line}`));
69
+ }
70
+ return lines.join("\n");
71
+ }
72
+ const noun = preview.files.length === 1 ? "file" : "files";
73
+ lines.push(`• Edited ${preview.files.length} ${noun} ${formatLineCountSummary(preview.added, preview.removed)}`);
74
+ for (const file of preview.files) {
75
+ lines.push(` └ ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`);
76
+ if (expanded && file.diff)
77
+ lines.push(...truncatePreview(file.diff)
78
+ .split("\n")
79
+ .map((line) => ` ${line}`));
80
+ }
81
+ return lines.join("\n");
82
+ }
83
+ export function formatInFlightCallText(patchText) {
84
+ const paths = extractPatchedPaths(patchText);
85
+ if (paths.length === 0)
86
+ return "Patching";
87
+ const noun = paths.length === 1 ? "file" : "files";
88
+ const count = paths.length > 1 ? ` (${paths.length} ${noun})` : "";
89
+ return `Patching${count}: ${paths.join(", ")}`;
90
+ }
91
+ function parseRenderableDiffLine(line) {
92
+ const match = line.match(/^([+\- ])(\s*\d+)\s(.*)$/);
93
+ if (!match)
94
+ return { kind: "meta", text: line };
95
+ const sign = match[1];
96
+ const lineNumber = match[2];
97
+ if ((sign !== "+" && sign !== "-" && sign !== " ") || lineNumber === undefined)
98
+ return { kind: "meta", text: line };
99
+ const content = match[3] ?? "";
100
+ if (sign === "+")
101
+ return { content, kind: "added", lineNumber, sign };
102
+ if (sign === "-")
103
+ return { content, kind: "removed", lineNumber, sign };
104
+ return { content, kind: "context", lineNumber, sign };
105
+ }
106
+ function replaceTabs(text) {
107
+ return text.replace(/\t/g, " ");
108
+ }
109
+ function highlightDiffContent(content, filePath) {
110
+ const plainContent = replaceTabs(content);
111
+ const language = getLanguageFromPath(filePath);
112
+ try {
113
+ return highlightCode(plainContent, language)[0] ?? plainContent;
114
+ }
115
+ catch {
116
+ return plainContent;
117
+ }
118
+ }
119
+ function renderInlineDiff(oldContent, newContent, theme) {
120
+ const parts = Diff.diffWords(replaceTabs(oldContent), replaceTabs(newContent));
121
+ let added = "";
122
+ let removed = "";
123
+ let firstAdded = true;
124
+ let firstRemoved = true;
125
+ for (const part of parts) {
126
+ if (part.added) {
127
+ let value = part.value;
128
+ if (firstAdded) {
129
+ const leadingWhitespace = value.match(/^(\s*)/)?.[1] ?? "";
130
+ added += leadingWhitespace;
131
+ value = value.slice(leadingWhitespace.length);
132
+ firstAdded = false;
133
+ }
134
+ if (value)
135
+ added += theme.inverse(value);
136
+ continue;
137
+ }
138
+ if (part.removed) {
139
+ let value = part.value;
140
+ if (firstRemoved) {
141
+ const leadingWhitespace = value.match(/^(\s*)/)?.[1] ?? "";
142
+ removed += leadingWhitespace;
143
+ value = value.slice(leadingWhitespace.length);
144
+ firstRemoved = false;
145
+ }
146
+ if (value)
147
+ removed += theme.inverse(value);
148
+ continue;
149
+ }
150
+ added += part.value;
151
+ removed += part.value;
152
+ }
153
+ return { added, removed };
154
+ }
155
+ function renderOpenCodeLikeDiffLine(line, filePath, theme, contentOverride) {
156
+ const lineNumber = theme.fg("muted", line.lineNumber);
157
+ if (line.kind === "context") {
158
+ return `${theme.fg("toolDiffContext", line.sign)}${lineNumber} ${highlightDiffContent(line.content, filePath)}`;
159
+ }
160
+ const diffColor = line.kind === "added" ? "toolDiffAdded" : "toolDiffRemoved";
161
+ const background = line.kind === "added" ? "toolSuccessBg" : "toolErrorBg";
162
+ const content = contentOverride === undefined
163
+ ? highlightDiffContent(line.content, filePath)
164
+ : theme.fg(diffColor, replaceTabs(contentOverride));
165
+ const rendered = `${theme.fg(diffColor, line.sign)}${lineNumber} ${content}`;
166
+ return theme.bg(background, rendered);
167
+ }
168
+ function renderOpenCodeLikeDiff(diffText, filePath, theme) {
169
+ const parsedLines = diffText.split("\n").map(parseRenderableDiffLine);
170
+ const rendered = [];
171
+ let index = 0;
172
+ while (index < parsedLines.length) {
173
+ const line = parsedLines[index];
174
+ if (!line) {
175
+ index++;
176
+ continue;
177
+ }
178
+ if (line.kind !== "removed") {
179
+ rendered.push(line.kind === "meta"
180
+ ? theme.fg("toolDiffContext", line.text)
181
+ : renderOpenCodeLikeDiffLine(line, filePath, theme));
182
+ index++;
183
+ continue;
184
+ }
185
+ const removedLines = [];
186
+ while (parsedLines[index]?.kind === "removed") {
187
+ const removedLine = parsedLines[index];
188
+ if (removedLine?.kind === "removed")
189
+ removedLines.push(removedLine);
190
+ index++;
191
+ }
192
+ const addedLines = [];
193
+ while (parsedLines[index]?.kind === "added") {
194
+ const addedLine = parsedLines[index];
195
+ if (addedLine?.kind === "added")
196
+ addedLines.push(addedLine);
197
+ index++;
198
+ }
199
+ const pairedCount = Math.min(removedLines.length, addedLines.length);
200
+ for (let pairIndex = 0; pairIndex < pairedCount; pairIndex++) {
201
+ const removedLine = removedLines[pairIndex];
202
+ const addedLine = addedLines[pairIndex];
203
+ if (!removedLine || !addedLine)
204
+ continue;
205
+ const inline = renderInlineDiff(removedLine.content, addedLine.content, theme);
206
+ rendered.push(renderOpenCodeLikeDiffLine(removedLine, filePath, theme, inline.removed));
207
+ rendered.push(renderOpenCodeLikeDiffLine(addedLine, filePath, theme, inline.added));
208
+ }
209
+ for (const removedLine of removedLines.slice(pairedCount))
210
+ rendered.push(renderOpenCodeLikeDiffLine(removedLine, filePath, theme));
211
+ for (const addedLine of addedLines.slice(pairedCount))
212
+ rendered.push(renderOpenCodeLikeDiffLine(addedLine, filePath, theme));
213
+ }
214
+ return rendered.join("\n");
215
+ }
216
+ export function getApplyPatchRenderState(toolCallId, cwd, patchText) {
217
+ const existing = applyPatchRenderStates.get(toolCallId);
218
+ if (existing && existing.cwd === cwd && existing.patchText === patchText)
219
+ return existing;
220
+ const callText = formatInFlightCallText(patchText);
221
+ let collapsed = "";
222
+ let expanded = "";
223
+ try {
224
+ const hunks = parsePatch(patchText);
225
+ if (hunks.length > 0) {
226
+ const files = hunks.map((hunk) => ({
227
+ filePath: hunk.filePath,
228
+ movePath: hunk.type === "update" ? hunk.movePath : undefined,
229
+ operation: hunk.type,
230
+ diff: "",
231
+ added: 0,
232
+ removed: 0,
233
+ }));
234
+ const preview = { files, added: 0, removed: 0 };
235
+ collapsed = formatPatchPreview(preview, cwd, false);
236
+ expanded = formatPatchPreview(preview, cwd, true);
237
+ }
238
+ }
239
+ catch {
240
+ // ignore incomplete patch text
241
+ }
242
+ const nextState = { ...existing, cwd, patchText, callText, collapsed, expanded };
243
+ applyPatchRenderStates.set(toolCallId, nextState);
244
+ return nextState;
245
+ }
246
+ export function clearApplyPatchRenderState() {
247
+ applyPatchRenderStates.clear();
248
+ }
249
+ export function renderPatchPreview(preview, cwd, theme, expanded) {
250
+ if (expanded) {
251
+ try {
252
+ const renderFile = (file, headerPrefix) => {
253
+ const header = `• ${formatPatchOperation(file.operation)} ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`;
254
+ if (!file.diff) {
255
+ return headerPrefix.length > 0
256
+ ? `${headerPrefix}${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`
257
+ : header;
258
+ }
259
+ const renderedDiff = renderOpenCodeLikeDiff(truncatePreview(file.diff), file.movePath ?? file.filePath, theme);
260
+ if (headerPrefix.length > 0) {
261
+ const nestedHeader = `${headerPrefix}${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`;
262
+ return `${nestedHeader}\n${renderedDiff
263
+ .split("\n")
264
+ .map((line) => ` ${line}`)
265
+ .join("\n")}`;
266
+ }
267
+ return `${header}\n${renderedDiff}`;
268
+ };
269
+ if (preview.files.length === 1) {
270
+ const file = preview.files[0];
271
+ return file ? renderFile(file, "") : "";
272
+ }
273
+ const noun = preview.files.length === 1 ? "file" : "files";
274
+ const renderedFiles = preview.files.map((file) => renderFile(file, " └ ")).join("\n");
275
+ if (renderedFiles.length > 0) {
276
+ return `• Edited ${preview.files.length} ${noun} ${formatLineCountSummary(preview.added, preview.removed)}\n${renderedFiles}`;
277
+ }
278
+ }
279
+ catch {
280
+ // fall back to manual themed line rendering
281
+ }
282
+ }
283
+ return formatPatchPreview(preview, cwd, expanded)
284
+ .split("\n")
285
+ .map((line) => renderPatchLine(line, theme))
286
+ .join("\n");
287
+ }
288
+ export function formatPendingPatchPaths(patchText) {
289
+ const paths = extractPatchedPaths(patchText);
290
+ if (paths.length === 0)
291
+ return "Applying patch...";
292
+ return `Applying patch...\n${paths.map((filePath) => `• ${filePath}`).join("\n")}`;
293
+ }
294
+ export function renderPatchLine(line, theme) {
295
+ const trimmed = line.trimStart();
296
+ if (trimmed.startsWith("+"))
297
+ return theme.fg("toolDiffAdded", line);
298
+ if (trimmed.startsWith("-"))
299
+ return theme.fg("toolDiffRemoved", line);
300
+ if (trimmed.startsWith("•"))
301
+ return theme.fg("toolTitle", theme.bold(line));
302
+ if (trimmed.startsWith("└"))
303
+ return theme.fg("accent", line);
304
+ return theme.fg("toolDiffContext", line);
305
+ }
306
+ //# sourceMappingURL=preview-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-format.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/preview-format.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAShD,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAC5C,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAiC,CAAC;AA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AAO,sBAAsB,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAK,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAAA,CACnF;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,KAAsB,EAAU;IAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IACjC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACpE,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IACtE,IAAI,OAAO,CAAC,UAAU,CAAC,KAAG,CAAC;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5E,IAAI,OAAO,CAAC,UAAU,CAAC,KAAG,CAAC;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7D,OAAO,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AAAA,CACzC","sourcesContent":["import path from \"node:path\";\nimport * as Diff from \"diff\";\nimport { getLanguageFromPath, highlightCode } from \"../../../../modes/interactive/theme/theme.js\";\nimport { parsePatch } from \"./parser.js\";\nimport { extractPatchedPaths } from \"./text.js\";\nimport type {\n\tApplyPatchOperation,\n\tApplyPatchPreview,\n\tApplyPatchPreviewFile,\n\tApplyPatchRenderState,\n\tApplyPatchTheme,\n} from \"./types.js\";\n\nexport const PATCH_PREVIEW_MAX_LINES = 16;\nexport const PATCH_PREVIEW_MAX_CHARS = 4000;\nconst PATCH_PREVIEW_HEAD_LINES = 8;\nconst PATCH_PREVIEW_TAIL_LINES = 8;\nconst applyPatchRenderStates = new Map<string, ApplyPatchRenderState>();\n\nfunction formatLineCountSummary(added: number, removed: number): string {\n\treturn `(+${added} -${removed})`;\n}\n\nfunction countLines(text: string): number {\n\tif (text.length === 0) return 0;\n\tlet lines = 1;\n\tfor (let index = 0; index < text.length; index++) {\n\t\tif (text.charCodeAt(index) === 10) lines += 1;\n\t}\n\treturn lines;\n}\n\nexport function truncatePreview(text: string): string {\n\tif (text.length <= PATCH_PREVIEW_MAX_CHARS && countLines(text) <= PATCH_PREVIEW_MAX_LINES) return text;\n\tconst lines = text.split(\"\\n\");\n\tconst head = lines.slice(0, PATCH_PREVIEW_HEAD_LINES);\n\tconst tail = lines.slice(-PATCH_PREVIEW_TAIL_LINES);\n\tlet preview = [...head, \"…\", ...tail].join(\"\\n\");\n\tif (preview.length > PATCH_PREVIEW_MAX_CHARS) preview = `${preview.slice(0, PATCH_PREVIEW_MAX_CHARS).trimEnd()}\\n…`;\n\treturn preview;\n}\n\nexport function displayPath(filePath: string, cwd: string): string {\n\tif (!path.isAbsolute(filePath)) return filePath;\n\tconst absoluteCwd = path.resolve(cwd);\n\tconst relativePath = path.relative(absoluteCwd, filePath);\n\tif (\n\t\trelativePath === \"\" ||\n\t\t(!relativePath.startsWith(`..${path.sep}`) && relativePath !== \"..\" && !path.isAbsolute(relativePath))\n\t) {\n\t\treturn relativePath || \".\";\n\t}\n\treturn filePath;\n}\n\nfunction formatPatchFilePath(file: ApplyPatchPreviewFile, cwd: string = process.cwd()): string {\n\tconst filePath = displayPath(file.filePath, cwd);\n\tif (!file.movePath) return filePath;\n\treturn `${filePath} → ${displayPath(file.movePath, cwd)}`;\n}\n\nfunction formatPatchOperation(operation: ApplyPatchOperation): string {\n\tif (operation === \"add\") return \"Added\";\n\tif (operation === \"delete\") return \"Deleted\";\n\treturn \"Edited\";\n}\n\nexport function formatPatchPreview(\n\tpreview: ApplyPatchPreview,\n\tcwd: string = process.cwd(),\n\texpanded: boolean = true,\n): string {\n\tconst lines: string[] = [];\n\tif (preview.files.length === 1) {\n\t\tconst file = preview.files[0];\n\t\tif (file) {\n\t\t\tlines.push(\n\t\t\t\t`• ${formatPatchOperation(file.operation)} ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`,\n\t\t\t);\n\t\t\tif (expanded && file.diff)\n\t\t\t\tlines.push(\n\t\t\t\t\t...truncatePreview(file.diff)\n\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t.map((line) => ` ${line}`),\n\t\t\t\t);\n\t\t}\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\tconst noun = preview.files.length === 1 ? \"file\" : \"files\";\n\tlines.push(`• Edited ${preview.files.length} ${noun} ${formatLineCountSummary(preview.added, preview.removed)}`);\n\tfor (const file of preview.files) {\n\t\tlines.push(` └ ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`);\n\t\tif (expanded && file.diff)\n\t\t\tlines.push(\n\t\t\t\t...truncatePreview(file.diff)\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map((line) => ` ${line}`),\n\t\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatInFlightCallText(patchText: string): string {\n\tconst paths = extractPatchedPaths(patchText);\n\tif (paths.length === 0) return \"Patching\";\n\tconst noun = paths.length === 1 ? \"file\" : \"files\";\n\tconst count = paths.length > 1 ? ` (${paths.length} ${noun})` : \"\";\n\treturn `Patching${count}: ${paths.join(\", \")}`;\n}\n\ntype RenderableAddedDiffLine = { content: string; kind: \"added\"; lineNumber: string; sign: \"+\" };\ntype RenderableRemovedDiffLine = { content: string; kind: \"removed\"; lineNumber: string; sign: \"-\" };\ntype RenderableContextDiffLine = { content: string; kind: \"context\"; lineNumber: string; sign: \" \" };\ntype RenderableContentDiffLine = RenderableAddedDiffLine | RenderableContextDiffLine | RenderableRemovedDiffLine;\ntype RenderableDiffLine = RenderableContentDiffLine | { kind: \"meta\"; text: string };\n\nfunction parseRenderableDiffLine(line: string): RenderableDiffLine {\n\tconst match = line.match(/^([+\\- ])(\\s*\\d+)\\s(.*)$/);\n\tif (!match) return { kind: \"meta\", text: line };\n\n\tconst sign = match[1];\n\tconst lineNumber = match[2];\n\tif ((sign !== \"+\" && sign !== \"-\" && sign !== \" \") || lineNumber === undefined) return { kind: \"meta\", text: line };\n\n\tconst content = match[3] ?? \"\";\n\tif (sign === \"+\") return { content, kind: \"added\", lineNumber, sign };\n\tif (sign === \"-\") return { content, kind: \"removed\", lineNumber, sign };\n\treturn { content, kind: \"context\", lineNumber, sign };\n}\n\nfunction replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nfunction highlightDiffContent(content: string, filePath: string): string {\n\tconst plainContent = replaceTabs(content);\n\tconst language = getLanguageFromPath(filePath);\n\ttry {\n\t\treturn highlightCode(plainContent, language)[0] ?? plainContent;\n\t} catch {\n\t\treturn plainContent;\n\t}\n}\n\nfunction renderInlineDiff(\n\toldContent: string,\n\tnewContent: string,\n\ttheme: ApplyPatchTheme,\n): { added: string; removed: string } {\n\tconst parts = Diff.diffWords(replaceTabs(oldContent), replaceTabs(newContent));\n\tlet added = \"\";\n\tlet removed = \"\";\n\tlet firstAdded = true;\n\tlet firstRemoved = true;\n\n\tfor (const part of parts) {\n\t\tif (part.added) {\n\t\t\tlet value = part.value;\n\t\t\tif (firstAdded) {\n\t\t\t\tconst leadingWhitespace = value.match(/^(\\s*)/)?.[1] ?? \"\";\n\t\t\t\tadded += leadingWhitespace;\n\t\t\t\tvalue = value.slice(leadingWhitespace.length);\n\t\t\t\tfirstAdded = false;\n\t\t\t}\n\t\t\tif (value) added += theme.inverse(value);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (part.removed) {\n\t\t\tlet value = part.value;\n\t\t\tif (firstRemoved) {\n\t\t\t\tconst leadingWhitespace = value.match(/^(\\s*)/)?.[1] ?? \"\";\n\t\t\t\tremoved += leadingWhitespace;\n\t\t\t\tvalue = value.slice(leadingWhitespace.length);\n\t\t\t\tfirstRemoved = false;\n\t\t\t}\n\t\t\tif (value) removed += theme.inverse(value);\n\t\t\tcontinue;\n\t\t}\n\n\t\tadded += part.value;\n\t\tremoved += part.value;\n\t}\n\n\treturn { added, removed };\n}\n\nfunction renderOpenCodeLikeDiffLine(\n\tline: RenderableContentDiffLine,\n\tfilePath: string,\n\ttheme: ApplyPatchTheme,\n\tcontentOverride?: string,\n): string {\n\tconst lineNumber = theme.fg(\"muted\", line.lineNumber);\n\tif (line.kind === \"context\") {\n\t\treturn `${theme.fg(\"toolDiffContext\", line.sign)}${lineNumber} ${highlightDiffContent(line.content, filePath)}`;\n\t}\n\n\tconst diffColor = line.kind === \"added\" ? \"toolDiffAdded\" : \"toolDiffRemoved\";\n\tconst background = line.kind === \"added\" ? \"toolSuccessBg\" : \"toolErrorBg\";\n\tconst content =\n\t\tcontentOverride === undefined\n\t\t\t? highlightDiffContent(line.content, filePath)\n\t\t\t: theme.fg(diffColor, replaceTabs(contentOverride));\n\tconst rendered = `${theme.fg(diffColor, line.sign)}${lineNumber} ${content}`;\n\treturn theme.bg(background, rendered);\n}\n\nfunction renderOpenCodeLikeDiff(diffText: string, filePath: string, theme: ApplyPatchTheme): string {\n\tconst parsedLines = diffText.split(\"\\n\").map(parseRenderableDiffLine);\n\tconst rendered: string[] = [];\n\tlet index = 0;\n\n\twhile (index < parsedLines.length) {\n\t\tconst line = parsedLines[index];\n\t\tif (!line) {\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (line.kind !== \"removed\") {\n\t\t\trendered.push(\n\t\t\t\tline.kind === \"meta\"\n\t\t\t\t\t? theme.fg(\"toolDiffContext\", line.text)\n\t\t\t\t\t: renderOpenCodeLikeDiffLine(line, filePath, theme),\n\t\t\t);\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst removedLines: RenderableRemovedDiffLine[] = [];\n\t\twhile (parsedLines[index]?.kind === \"removed\") {\n\t\t\tconst removedLine = parsedLines[index];\n\t\t\tif (removedLine?.kind === \"removed\") removedLines.push(removedLine);\n\t\t\tindex++;\n\t\t}\n\n\t\tconst addedLines: RenderableAddedDiffLine[] = [];\n\t\twhile (parsedLines[index]?.kind === \"added\") {\n\t\t\tconst addedLine = parsedLines[index];\n\t\t\tif (addedLine?.kind === \"added\") addedLines.push(addedLine);\n\t\t\tindex++;\n\t\t}\n\n\t\tconst pairedCount = Math.min(removedLines.length, addedLines.length);\n\t\tfor (let pairIndex = 0; pairIndex < pairedCount; pairIndex++) {\n\t\t\tconst removedLine = removedLines[pairIndex];\n\t\t\tconst addedLine = addedLines[pairIndex];\n\t\t\tif (!removedLine || !addedLine) continue;\n\n\t\t\tconst inline = renderInlineDiff(removedLine.content, addedLine.content, theme);\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(removedLine, filePath, theme, inline.removed));\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(addedLine, filePath, theme, inline.added));\n\t\t}\n\n\t\tfor (const removedLine of removedLines.slice(pairedCount))\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(removedLine, filePath, theme));\n\t\tfor (const addedLine of addedLines.slice(pairedCount))\n\t\t\trendered.push(renderOpenCodeLikeDiffLine(addedLine, filePath, theme));\n\t}\n\n\treturn rendered.join(\"\\n\");\n}\n\nexport function getApplyPatchRenderState(toolCallId: string, cwd: string, patchText: string): ApplyPatchRenderState {\n\tconst existing = applyPatchRenderStates.get(toolCallId);\n\tif (existing && existing.cwd === cwd && existing.patchText === patchText) return existing;\n\n\tconst callText = formatInFlightCallText(patchText);\n\tlet collapsed = \"\";\n\tlet expanded = \"\";\n\ttry {\n\t\tconst hunks = parsePatch(patchText);\n\t\tif (hunks.length > 0) {\n\t\t\tconst files = hunks.map((hunk) => ({\n\t\t\t\tfilePath: hunk.filePath,\n\t\t\t\tmovePath: hunk.type === \"update\" ? hunk.movePath : undefined,\n\t\t\t\toperation: hunk.type,\n\t\t\t\tdiff: \"\",\n\t\t\t\tadded: 0,\n\t\t\t\tremoved: 0,\n\t\t\t})) satisfies ApplyPatchPreviewFile[];\n\t\t\tconst preview: ApplyPatchPreview = { files, added: 0, removed: 0 };\n\t\t\tcollapsed = formatPatchPreview(preview, cwd, false);\n\t\t\texpanded = formatPatchPreview(preview, cwd, true);\n\t\t}\n\t} catch {\n\t\t// ignore incomplete patch text\n\t}\n\n\tconst nextState: ApplyPatchRenderState = { ...existing, cwd, patchText, callText, collapsed, expanded };\n\tapplyPatchRenderStates.set(toolCallId, nextState);\n\treturn nextState;\n}\n\nexport function clearApplyPatchRenderState(): void {\n\tapplyPatchRenderStates.clear();\n}\n\nexport function renderPatchPreview(\n\tpreview: ApplyPatchPreview,\n\tcwd: string,\n\ttheme: ApplyPatchTheme,\n\texpanded: boolean,\n): string {\n\tif (expanded) {\n\t\ttry {\n\t\t\tconst renderFile = (file: ApplyPatchPreviewFile, headerPrefix: string): string => {\n\t\t\t\tconst header = `• ${formatPatchOperation(file.operation)} ${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`;\n\t\t\t\tif (!file.diff) {\n\t\t\t\t\treturn headerPrefix.length > 0\n\t\t\t\t\t\t? `${headerPrefix}${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`\n\t\t\t\t\t\t: header;\n\t\t\t\t}\n\n\t\t\t\tconst renderedDiff = renderOpenCodeLikeDiff(\n\t\t\t\t\ttruncatePreview(file.diff),\n\t\t\t\t\tfile.movePath ?? file.filePath,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t\tif (headerPrefix.length > 0) {\n\t\t\t\t\tconst nestedHeader = `${headerPrefix}${formatPatchFilePath(file, cwd)} ${formatLineCountSummary(file.added, file.removed)}`;\n\t\t\t\t\treturn `${nestedHeader}\\n${renderedDiff\n\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t.map((line) => ` ${line}`)\n\t\t\t\t\t\t.join(\"\\n\")}`;\n\t\t\t\t}\n\t\t\t\treturn `${header}\\n${renderedDiff}`;\n\t\t\t};\n\n\t\t\tif (preview.files.length === 1) {\n\t\t\t\tconst file = preview.files[0];\n\t\t\t\treturn file ? renderFile(file, \"\") : \"\";\n\t\t\t}\n\n\t\t\tconst noun = preview.files.length === 1 ? \"file\" : \"files\";\n\t\t\tconst renderedFiles = preview.files.map((file) => renderFile(file, \" └ \")).join(\"\\n\");\n\t\t\tif (renderedFiles.length > 0) {\n\t\t\t\treturn `• Edited ${preview.files.length} ${noun} ${formatLineCountSummary(preview.added, preview.removed)}\\n${renderedFiles}`;\n\t\t\t}\n\t\t} catch {\n\t\t\t// fall back to manual themed line rendering\n\t\t}\n\t}\n\n\treturn formatPatchPreview(preview, cwd, expanded)\n\t\t.split(\"\\n\")\n\t\t.map((line) => renderPatchLine(line, theme))\n\t\t.join(\"\\n\");\n}\n\nexport function formatPendingPatchPaths(patchText: string): string {\n\tconst paths = extractPatchedPaths(patchText);\n\tif (paths.length === 0) return \"Applying patch...\";\n\treturn `Applying patch...\\n${paths.map((filePath) => `• ${filePath}`).join(\"\\n\")}`;\n}\n\nexport function renderPatchLine(line: string, theme: ApplyPatchTheme): string {\n\tconst trimmed = line.trimStart();\n\tif (trimmed.startsWith(\"+\")) return theme.fg(\"toolDiffAdded\", line);\n\tif (trimmed.startsWith(\"-\")) return theme.fg(\"toolDiffRemoved\", line);\n\tif (trimmed.startsWith(\"•\")) return theme.fg(\"toolTitle\", theme.bold(line));\n\tif (trimmed.startsWith(\"└\")) return theme.fg(\"accent\", line);\n\treturn theme.fg(\"toolDiffContext\", line);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { ApplyPatchPreview, ApplyPatchProgress, ApplyPatchToolDetails, ParsedPatch } from "./types.js";
2
+ export declare function createPatchPreview(cwd: string, hunks: ParsedPatch[]): Promise<ApplyPatchPreview>;
3
+ export declare function createPendingPatchUpdate(cwd: string, patchText: string, progress?: ApplyPatchProgress, previewOverride?: ApplyPatchPreview): Promise<{
4
+ text: string;
5
+ details: ApplyPatchToolDetails | undefined;
6
+ }>;
7
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/preview.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACX,iBAAiB,EAEjB,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACX,MAAM,YAAY,CAAC;AAYpB,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA+BtG;AAED,wBAAsB,wBAAwB,CAC7C,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,kBAAkB,EAC7B,eAAe,CAAC,EAAE,iBAAiB,GACjC,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS,CAAA;CAAE,CAAC,CAyBvE","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { parsePatch } from \"./parser.js\";\nimport { createPatchDiff } from \"./patch-diff.js\";\nimport { replaceChunks } from \"./patch-replace.js\";\nimport { formatPatchPreview, formatPendingPatchPaths } from \"./preview-format.js\";\nimport type {\n\tApplyPatchPreview,\n\tApplyPatchPreviewFile,\n\tApplyPatchProgress,\n\tApplyPatchToolDetails,\n\tParsedPatch,\n} from \"./types.js\";\nimport { resolvePatchPath } from \"./workspace.js\";\n\nasync function readExistingFileForPreview(absolutePath: string): Promise<string> {\n\ttry {\n\t\treturn await readFile(absolutePath, \"utf-8\");\n\t} catch (error) {\n\t\tif (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") return \"\";\n\t\tthrow error;\n\t}\n}\n\nexport async function createPatchPreview(cwd: string, hunks: ParsedPatch[]): Promise<ApplyPatchPreview> {\n\tconst files: ApplyPatchPreviewFile[] = [];\n\tfor (const hunk of hunks) {\n\t\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst oldContent = await readExistingFileForPreview(absolutePath);\n\t\t\tconst diff = createPatchDiff(oldContent, hunk.content);\n\t\t\tfiles.push({ filePath: hunk.filePath, operation: oldContent.length > 0 ? \"update\" : \"add\", ...diff });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\t\tconst diff = createPatchDiff(oldContent, \"\");\n\t\t\tfiles.push({ filePath: hunk.filePath, operation: \"delete\", ...diff });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\tconst newContent =\n\t\t\thunk.chunks.length === 0 ? oldContent : replaceChunks(oldContent, hunk.filePath, hunk.chunks).content;\n\t\tif (hunk.movePath) resolvePatchPath(cwd, hunk.movePath);\n\t\tconst diff = createPatchDiff(oldContent, newContent);\n\t\tfiles.push({ filePath: hunk.filePath, movePath: hunk.movePath, operation: \"update\", ...diff });\n\t}\n\n\treturn {\n\t\tfiles,\n\t\tadded: files.reduce((sum, file) => sum + file.added, 0),\n\t\tremoved: files.reduce((sum, file) => sum + file.removed, 0),\n\t};\n}\n\nexport async function createPendingPatchUpdate(\n\tcwd: string,\n\tpatchText: string,\n\tprogress?: ApplyPatchProgress,\n\tpreviewOverride?: ApplyPatchPreview,\n): Promise<{ text: string; details: ApplyPatchToolDetails | undefined }> {\n\tconst title = progress\n\t\t? `Applying patch (${progress.applied + progress.failed}/${progress.total})...`\n\t\t: \"Applying patch...\";\n\tif (previewOverride) {\n\t\treturn {\n\t\t\ttext: `${title}\\n${formatPatchPreview(previewOverride)}`,\n\t\t\tdetails: { preview: previewOverride, progress },\n\t\t};\n\t}\n\n\ttry {\n\t\tconst hunks = parsePatch(patchText);\n\t\tif (hunks.length === 0) return { text: title, details: progress ? { progress } : undefined };\n\t\tconst preview = await createPatchPreview(cwd, hunks);\n\t\tif (preview.files.some((file) => file.diff.trim().length > 0)) {\n\t\t\treturn { text: `${title}\\n${formatPatchPreview(preview)}`, details: { preview, progress } };\n\t\t}\n\t} catch {\n\t\treturn {\n\t\t\ttext: progress ? title : formatPendingPatchPaths(patchText),\n\t\t\tdetails: progress ? { progress } : undefined,\n\t\t};\n\t}\n\treturn { text: progress ? title : formatPendingPatchPaths(patchText), details: progress ? { progress } : undefined };\n}\n"]}
@@ -0,0 +1,73 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { parsePatch } from "./parser.js";
3
+ import { createPatchDiff } from "./patch-diff.js";
4
+ import { replaceChunks } from "./patch-replace.js";
5
+ import { formatPatchPreview, formatPendingPatchPaths } from "./preview-format.js";
6
+ import { resolvePatchPath } from "./workspace.js";
7
+ async function readExistingFileForPreview(absolutePath) {
8
+ try {
9
+ return await readFile(absolutePath, "utf-8");
10
+ }
11
+ catch (error) {
12
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
13
+ return "";
14
+ throw error;
15
+ }
16
+ }
17
+ export async function createPatchPreview(cwd, hunks) {
18
+ const files = [];
19
+ for (const hunk of hunks) {
20
+ const absolutePath = resolvePatchPath(cwd, hunk.filePath);
21
+ if (hunk.type === "add") {
22
+ const oldContent = await readExistingFileForPreview(absolutePath);
23
+ const diff = createPatchDiff(oldContent, hunk.content);
24
+ files.push({ filePath: hunk.filePath, operation: oldContent.length > 0 ? "update" : "add", ...diff });
25
+ continue;
26
+ }
27
+ if (hunk.type === "delete") {
28
+ const oldContent = await readFile(absolutePath, "utf-8");
29
+ const diff = createPatchDiff(oldContent, "");
30
+ files.push({ filePath: hunk.filePath, operation: "delete", ...diff });
31
+ continue;
32
+ }
33
+ const oldContent = await readFile(absolutePath, "utf-8");
34
+ const newContent = hunk.chunks.length === 0 ? oldContent : replaceChunks(oldContent, hunk.filePath, hunk.chunks).content;
35
+ if (hunk.movePath)
36
+ resolvePatchPath(cwd, hunk.movePath);
37
+ const diff = createPatchDiff(oldContent, newContent);
38
+ files.push({ filePath: hunk.filePath, movePath: hunk.movePath, operation: "update", ...diff });
39
+ }
40
+ return {
41
+ files,
42
+ added: files.reduce((sum, file) => sum + file.added, 0),
43
+ removed: files.reduce((sum, file) => sum + file.removed, 0),
44
+ };
45
+ }
46
+ export async function createPendingPatchUpdate(cwd, patchText, progress, previewOverride) {
47
+ const title = progress
48
+ ? `Applying patch (${progress.applied + progress.failed}/${progress.total})...`
49
+ : "Applying patch...";
50
+ if (previewOverride) {
51
+ return {
52
+ text: `${title}\n${formatPatchPreview(previewOverride)}`,
53
+ details: { preview: previewOverride, progress },
54
+ };
55
+ }
56
+ try {
57
+ const hunks = parsePatch(patchText);
58
+ if (hunks.length === 0)
59
+ return { text: title, details: progress ? { progress } : undefined };
60
+ const preview = await createPatchPreview(cwd, hunks);
61
+ if (preview.files.some((file) => file.diff.trim().length > 0)) {
62
+ return { text: `${title}\n${formatPatchPreview(preview)}`, details: { preview, progress } };
63
+ }
64
+ }
65
+ catch {
66
+ return {
67
+ text: progress ? title : formatPendingPatchPaths(patchText),
68
+ details: progress ? { progress } : undefined,
69
+ };
70
+ }
71
+ return { text: progress ? title : formatPendingPatchPaths(patchText), details: progress ? { progress } : undefined };
72
+ }
73
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAQlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEl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BAAuB,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAAA,CACrH","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { parsePatch } from \"./parser.js\";\nimport { createPatchDiff } from \"./patch-diff.js\";\nimport { replaceChunks } from \"./patch-replace.js\";\nimport { formatPatchPreview, formatPendingPatchPaths } from \"./preview-format.js\";\nimport type {\n\tApplyPatchPreview,\n\tApplyPatchPreviewFile,\n\tApplyPatchProgress,\n\tApplyPatchToolDetails,\n\tParsedPatch,\n} from \"./types.js\";\nimport { resolvePatchPath } from \"./workspace.js\";\n\nasync function readExistingFileForPreview(absolutePath: string): Promise<string> {\n\ttry {\n\t\treturn await readFile(absolutePath, \"utf-8\");\n\t} catch (error) {\n\t\tif (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") return \"\";\n\t\tthrow error;\n\t}\n}\n\nexport async function createPatchPreview(cwd: string, hunks: ParsedPatch[]): Promise<ApplyPatchPreview> {\n\tconst files: ApplyPatchPreviewFile[] = [];\n\tfor (const hunk of hunks) {\n\t\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst oldContent = await readExistingFileForPreview(absolutePath);\n\t\t\tconst diff = createPatchDiff(oldContent, hunk.content);\n\t\t\tfiles.push({ filePath: hunk.filePath, operation: oldContent.length > 0 ? \"update\" : \"add\", ...diff });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\t\tconst diff = createPatchDiff(oldContent, \"\");\n\t\t\tfiles.push({ filePath: hunk.filePath, operation: \"delete\", ...diff });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst oldContent = await readFile(absolutePath, \"utf-8\");\n\t\tconst newContent =\n\t\t\thunk.chunks.length === 0 ? oldContent : replaceChunks(oldContent, hunk.filePath, hunk.chunks).content;\n\t\tif (hunk.movePath) resolvePatchPath(cwd, hunk.movePath);\n\t\tconst diff = createPatchDiff(oldContent, newContent);\n\t\tfiles.push({ filePath: hunk.filePath, movePath: hunk.movePath, operation: \"update\", ...diff });\n\t}\n\n\treturn {\n\t\tfiles,\n\t\tadded: files.reduce((sum, file) => sum + file.added, 0),\n\t\tremoved: files.reduce((sum, file) => sum + file.removed, 0),\n\t};\n}\n\nexport async function createPendingPatchUpdate(\n\tcwd: string,\n\tpatchText: string,\n\tprogress?: ApplyPatchProgress,\n\tpreviewOverride?: ApplyPatchPreview,\n): Promise<{ text: string; details: ApplyPatchToolDetails | undefined }> {\n\tconst title = progress\n\t\t? `Applying patch (${progress.applied + progress.failed}/${progress.total})...`\n\t\t: \"Applying patch...\";\n\tif (previewOverride) {\n\t\treturn {\n\t\t\ttext: `${title}\\n${formatPatchPreview(previewOverride)}`,\n\t\t\tdetails: { preview: previewOverride, progress },\n\t\t};\n\t}\n\n\ttry {\n\t\tconst hunks = parsePatch(patchText);\n\t\tif (hunks.length === 0) return { text: title, details: progress ? { progress } : undefined };\n\t\tconst preview = await createPatchPreview(cwd, hunks);\n\t\tif (preview.files.some((file) => file.diff.trim().length > 0)) {\n\t\t\treturn { text: `${title}\\n${formatPatchPreview(preview)}`, details: { preview, progress } };\n\t\t}\n\t} catch {\n\t\treturn {\n\t\t\ttext: progress ? title : formatPendingPatchPaths(patchText),\n\t\t\tdetails: progress ? { progress } : undefined,\n\t\t};\n\t}\n\treturn { text: progress ? title : formatPendingPatchPaths(patchText), details: progress ? { progress } : undefined };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export declare function seekSequenceWithFuzz(lines: string[], pattern: string[], start: number, eof: boolean): {
2
+ index: number;
3
+ fuzz: 0 | 1 | 100 | 10000;
4
+ } | undefined;
5
+ export declare function seekSequence(lines: string[], pattern: string[], start: number, eof: boolean): number | undefined;
6
+ //# sourceMappingURL=seek-sequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seek-sequence.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/seek-sequence.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,GACV;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,KAAK,CAAA;CAAE,GAAG,SAAS,CAoC1D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEhH","sourcesContent":["function normalizeSeekLine(line: string): string {\n\treturn line\n\t\t.trim()\n\t\t.replace(/[‐‑‒–—―−]/g, \"-\")\n\t\t.replace(/[‘’‚‛]/g, \"'\")\n\t\t.replace(/[“”„‟]/g, '\"')\n\t\t.replace(/[\\u00A0\\u2002-\\u200A\\u202F\\u205F\\u3000]/g, \" \");\n}\n\nexport function seekSequenceWithFuzz(\n\tlines: string[],\n\tpattern: string[],\n\tstart: number,\n\teof: boolean,\n): { index: number; fuzz: 0 | 1 | 100 | 10000 } | undefined {\n\tif (pattern.length === 0) {\n\t\treturn { index: start, fuzz: 0 };\n\t}\n\tif (pattern.length > lines.length) {\n\t\treturn undefined;\n\t}\n\n\tconst searchStart = eof && lines.length >= pattern.length ? lines.length - pattern.length : start;\n\tconst lastStart = lines.length - pattern.length;\n\tconst matches = (index: number, compare: (left: string, right: string) => boolean): boolean => {\n\t\tfor (let patternIndex = 0; patternIndex < pattern.length; patternIndex++) {\n\t\t\tconst line = lines[index + patternIndex];\n\t\t\tconst expected = pattern[patternIndex];\n\t\t\tif (line === undefined || expected === undefined || !compare(line, expected)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t};\n\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => line === expected)) return { index, fuzz: 0 };\n\t}\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => line.trimEnd() === expected.trimEnd())) return { index, fuzz: 1 };\n\t}\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => line.trim() === expected.trim())) return { index, fuzz: 100 };\n\t}\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => normalizeSeekLine(line) === normalizeSeekLine(expected)))\n\t\t\treturn { index, fuzz: 10000 };\n\t}\n\n\treturn undefined;\n}\n\nexport function seekSequence(lines: string[], pattern: string[], start: number, eof: boolean): number | undefined {\n\treturn seekSequenceWithFuzz(lines, pattern, start, eof)?.index;\n}\n"]}
@@ -0,0 +1,49 @@
1
+ function normalizeSeekLine(line) {
2
+ return line
3
+ .trim()
4
+ .replace(/[‐‑‒–—―−]/g, "-")
5
+ .replace(/[‘’‚‛]/g, "'")
6
+ .replace(/[“”„‟]/g, '"')
7
+ .replace(/[\u00A0\u2002-\u200A\u202F\u205F\u3000]/g, " ");
8
+ }
9
+ export function seekSequenceWithFuzz(lines, pattern, start, eof) {
10
+ if (pattern.length === 0) {
11
+ return { index: start, fuzz: 0 };
12
+ }
13
+ if (pattern.length > lines.length) {
14
+ return undefined;
15
+ }
16
+ const searchStart = eof && lines.length >= pattern.length ? lines.length - pattern.length : start;
17
+ const lastStart = lines.length - pattern.length;
18
+ const matches = (index, compare) => {
19
+ for (let patternIndex = 0; patternIndex < pattern.length; patternIndex++) {
20
+ const line = lines[index + patternIndex];
21
+ const expected = pattern[patternIndex];
22
+ if (line === undefined || expected === undefined || !compare(line, expected)) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ };
28
+ for (let index = searchStart; index <= lastStart; index++) {
29
+ if (matches(index, (line, expected) => line === expected))
30
+ return { index, fuzz: 0 };
31
+ }
32
+ for (let index = searchStart; index <= lastStart; index++) {
33
+ if (matches(index, (line, expected) => line.trimEnd() === expected.trimEnd()))
34
+ return { index, fuzz: 1 };
35
+ }
36
+ for (let index = searchStart; index <= lastStart; index++) {
37
+ if (matches(index, (line, expected) => line.trim() === expected.trim()))
38
+ return { index, fuzz: 100 };
39
+ }
40
+ for (let index = searchStart; index <= lastStart; index++) {
41
+ if (matches(index, (line, expected) => normalizeSeekLine(line) === normalizeSeekLine(expected)))
42
+ return { index, fuzz: 10000 };
43
+ }
44
+ return undefined;
45
+ }
46
+ export function seekSequence(lines, pattern, start, eof) {
47
+ return seekSequenceWithFuzz(lines, pattern, start, eof)?.index;
48
+ }
49
+ //# sourceMappingURL=seek-sequence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seek-sequence.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/seek-sequence.ts"],"names":[],"mappings":"AAAA,SAAS,iBAAiB,CAAC,IAAY,EAAU;IAChD,OAAO,IAAI;SACT,IAAI,EAAE;SACN,OAAO,CAAC,0BAAY,EAAE,GAAG,CAAC;SAC1B,OAAO,CAAC,iBAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,iBAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,0CAA0C,EAAE,GAAG,CAAC,CAAC;AAAA,CAC3D;AAED,MAAM,UAAU,oBAAoB,CACnC,KAAe,EACf,OAAiB,EACjB,KAAa,EACb,GAAY,EAC+C;IAC3D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAClC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,WAAW,GAAG,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,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC1G,CAAC;IACD,KAAK,IAAI,KAAK,GAAG,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;QAC3D,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IACtG,CAAC;IACD,KAAK,IAAI,KAAK,GAAG,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;QAC3D,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YAC9F,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,SAAS,CAAC;AAAA,CACjB;AAED,MAAM,UAAU,YAAY,CAAC,KAAe,EAAE,OAAiB,EAAE,KAAa,EAAE,GAAY,EAAsB;IACjH,OAAO,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC;AAAA,CAC/D","sourcesContent":["function normalizeSeekLine(line: string): string {\n\treturn line\n\t\t.trim()\n\t\t.replace(/[‐‑‒–—―−]/g, \"-\")\n\t\t.replace(/[‘’‚‛]/g, \"'\")\n\t\t.replace(/[“”„‟]/g, '\"')\n\t\t.replace(/[\\u00A0\\u2002-\\u200A\\u202F\\u205F\\u3000]/g, \" \");\n}\n\nexport function seekSequenceWithFuzz(\n\tlines: string[],\n\tpattern: string[],\n\tstart: number,\n\teof: boolean,\n): { index: number; fuzz: 0 | 1 | 100 | 10000 } | undefined {\n\tif (pattern.length === 0) {\n\t\treturn { index: start, fuzz: 0 };\n\t}\n\tif (pattern.length > lines.length) {\n\t\treturn undefined;\n\t}\n\n\tconst searchStart = eof && lines.length >= pattern.length ? lines.length - pattern.length : start;\n\tconst lastStart = lines.length - pattern.length;\n\tconst matches = (index: number, compare: (left: string, right: string) => boolean): boolean => {\n\t\tfor (let patternIndex = 0; patternIndex < pattern.length; patternIndex++) {\n\t\t\tconst line = lines[index + patternIndex];\n\t\t\tconst expected = pattern[patternIndex];\n\t\t\tif (line === undefined || expected === undefined || !compare(line, expected)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t};\n\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => line === expected)) return { index, fuzz: 0 };\n\t}\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => line.trimEnd() === expected.trimEnd())) return { index, fuzz: 1 };\n\t}\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => line.trim() === expected.trim())) return { index, fuzz: 100 };\n\t}\n\tfor (let index = searchStart; index <= lastStart; index++) {\n\t\tif (matches(index, (line, expected) => normalizeSeekLine(line) === normalizeSeekLine(expected)))\n\t\t\treturn { index, fuzz: 10000 };\n\t}\n\n\treturn undefined;\n}\n\nexport function seekSequence(lines: string[], pattern: string[], start: number, eof: boolean): number | undefined {\n\treturn seekSequenceWithFuzz(lines, pattern, start, eof)?.index;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { ParsedPatch } from "./types.js";
2
+ export declare class StreamingPatchParser {
3
+ private lineBuffer;
4
+ private mode;
5
+ private hunks;
6
+ pushDelta(delta: string): ParsedPatch[];
7
+ finish(): ParsedPatch[];
8
+ private snapshot;
9
+ private ensureUpdateHunkIsNotEmpty;
10
+ private handleHeader;
11
+ private startAdd;
12
+ private startDelete;
13
+ private startUpdate;
14
+ private currentUpdate;
15
+ private currentChunk;
16
+ private processLine;
17
+ private processStarted;
18
+ private processAdd;
19
+ private processDelete;
20
+ private processUpdate;
21
+ private pushUpdateLine;
22
+ }
23
+ //# sourceMappingURL=streaming-parser.d.ts.map