@code-yeongyu/senpi 2026.6.4 → 2026.6.6-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1050) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/README.md +19 -4
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/register-bedrock.d.ts.map +1 -1
  6. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  7. package/dist/bun/restore-sandbox-env.js.map +1 -1
  8. package/dist/cli/args.d.ts +1 -0
  9. package/dist/cli/args.d.ts.map +1 -1
  10. package/dist/cli/args.js +12 -2
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/cli/config-selector.d.ts.map +1 -1
  13. package/dist/cli/config-selector.js.map +1 -1
  14. package/dist/cli/file-processor.d.ts.map +1 -1
  15. package/dist/cli/file-processor.js.map +1 -1
  16. package/dist/cli/initial-message.d.ts +1 -1
  17. package/dist/cli/initial-message.d.ts.map +1 -1
  18. package/dist/cli/initial-message.js.map +1 -1
  19. package/dist/cli/list-models.d.ts.map +1 -1
  20. package/dist/cli/list-models.js.map +1 -1
  21. package/dist/cli/session-picker.d.ts.map +1 -1
  22. package/dist/cli/session-picker.js.map +1 -1
  23. package/dist/cli-main.d.ts.map +1 -1
  24. package/dist/cli-main.js.map +1 -1
  25. package/dist/cli.d.ts.map +1 -1
  26. package/dist/cli.js.map +1 -1
  27. package/dist/config.d.ts.map +1 -1
  28. package/dist/config.js.map +1 -1
  29. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  30. package/dist/core/agent-session-runtime.js +0 -8
  31. package/dist/core/agent-session-runtime.js.map +1 -1
  32. package/dist/core/agent-session-services.d.ts.map +1 -1
  33. package/dist/core/agent-session-services.js.map +1 -1
  34. package/dist/core/agent-session.d.ts +32 -0
  35. package/dist/core/agent-session.d.ts.map +1 -1
  36. package/dist/core/agent-session.js +51 -79
  37. package/dist/core/agent-session.js.map +1 -1
  38. package/dist/core/auth-guidance.d.ts.map +1 -1
  39. package/dist/core/auth-guidance.js.map +1 -1
  40. package/dist/core/auth-storage.d.ts +4 -0
  41. package/dist/core/auth-storage.d.ts.map +1 -1
  42. package/dist/core/auth-storage.js +4 -8
  43. package/dist/core/auth-storage.js.map +1 -1
  44. package/dist/core/bash-executor.d.ts.map +1 -1
  45. package/dist/core/bash-executor.js.map +1 -1
  46. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  47. package/dist/core/compaction/branch-summarization.js.map +1 -1
  48. package/dist/core/compaction/compaction.d.ts.map +1 -1
  49. package/dist/core/compaction/compaction.js.map +1 -1
  50. package/dist/core/compaction/index.d.ts.map +1 -1
  51. package/dist/core/compaction/utils.d.ts.map +1 -1
  52. package/dist/core/compaction/utils.js.map +1 -1
  53. package/dist/core/defaults.d.ts.map +1 -1
  54. package/dist/core/diagnostics.d.ts.map +1 -1
  55. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  56. package/dist/core/dynamic-prompt/build.js.map +1 -1
  57. package/dist/core/dynamic-prompt/exploration.d.ts.map +1 -1
  58. package/dist/core/dynamic-prompt/exploration.js.map +1 -1
  59. package/dist/core/dynamic-prompt/identity.d.ts.map +1 -1
  60. package/dist/core/dynamic-prompt/identity.js.map +1 -1
  61. package/dist/core/dynamic-prompt/index.d.ts.map +1 -1
  62. package/dist/core/dynamic-prompt/intent-gate.d.ts.map +1 -1
  63. package/dist/core/dynamic-prompt/intent-gate.js.map +1 -1
  64. package/dist/core/dynamic-prompt/parallel-tools.d.ts.map +1 -1
  65. package/dist/core/dynamic-prompt/parallel-tools.js.map +1 -1
  66. package/dist/core/dynamic-prompt/policies.d.ts.map +1 -1
  67. package/dist/core/dynamic-prompt/policies.js.map +1 -1
  68. package/dist/core/dynamic-prompt/style.d.ts.map +1 -1
  69. package/dist/core/dynamic-prompt/style.js.map +1 -1
  70. package/dist/core/dynamic-prompt/tool-categorization.d.ts.map +1 -1
  71. package/dist/core/dynamic-prompt/tool-categorization.js.map +1 -1
  72. package/dist/core/dynamic-prompt/tool-section.d.ts.map +1 -1
  73. package/dist/core/dynamic-prompt/tool-section.js.map +1 -1
  74. package/dist/core/dynamic-prompt/types.d.ts.map +1 -1
  75. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
  76. package/dist/core/dynamic-prompt/verification.js.map +1 -1
  77. package/dist/core/event-bus.d.ts.map +1 -1
  78. package/dist/core/event-bus.js.map +1 -1
  79. package/dist/core/exec.d.ts.map +1 -1
  80. package/dist/core/exec.js.map +1 -1
  81. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  82. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  83. package/dist/core/export-html/index.d.ts.map +1 -1
  84. package/dist/core/export-html/index.js.map +1 -1
  85. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  86. package/dist/core/export-html/tool-renderer.js.map +1 -1
  87. package/dist/core/extensions/builtin/anthropic-bash/index.d.ts.map +1 -1
  88. package/dist/core/extensions/builtin/anthropic-bash/index.js.map +1 -1
  89. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/anthropic-web-search/index.js.map +1 -1
  91. package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
  92. package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
  93. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
  94. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  95. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
  96. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
  97. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts.map +1 -1
  98. package/dist/core/extensions/builtin/compaction/circuit-breaker.js.map +1 -1
  99. package/dist/core/extensions/builtin/compaction/context-reduction.d.ts.map +1 -1
  100. package/dist/core/extensions/builtin/compaction/context-reduction.js +1 -1
  101. package/dist/core/extensions/builtin/compaction/context-reduction.js.map +1 -1
  102. package/dist/core/extensions/builtin/compaction/degradation-monitor.d.ts.map +1 -1
  103. package/dist/core/extensions/builtin/compaction/degradation-monitor.js.map +1 -1
  104. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  106. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  107. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  108. package/dist/core/extensions/builtin/compaction/overflow-detection.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/compaction/overflow-detection.js.map +1 -1
  110. package/dist/core/extensions/builtin/compaction/per-turn-cap.d.ts.map +1 -1
  111. package/dist/core/extensions/builtin/compaction/per-turn-cap.js.map +1 -1
  112. package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
  114. package/dist/core/extensions/builtin/compaction/prompts.d.ts.map +1 -1
  115. package/dist/core/extensions/builtin/compaction/prompts.js.map +1 -1
  116. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
  118. package/dist/core/extensions/builtin/compaction/restoration-tracker.d.ts.map +1 -1
  119. package/dist/core/extensions/builtin/compaction/restoration-tracker.js.map +1 -1
  120. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  122. package/dist/core/extensions/builtin/compaction/state.d.ts.map +1 -1
  123. package/dist/core/extensions/builtin/compaction/state.js.map +1 -1
  124. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
  125. package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
  126. package/dist/core/extensions/builtin/compaction/tool-truncation.d.ts.map +1 -1
  127. package/dist/core/extensions/builtin/compaction/tool-truncation.js.map +1 -1
  128. package/dist/core/extensions/builtin/diff.d.ts.map +1 -1
  129. package/dist/core/extensions/builtin/diff.js.map +1 -1
  130. package/dist/core/extensions/builtin/files.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/files.js.map +1 -1
  132. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
  133. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
  134. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -1
  135. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -1
  136. package/dist/core/extensions/builtin/gpt-apply-patch/errors.d.ts.map +1 -1
  137. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js +0 -2
  138. package/dist/core/extensions/builtin/gpt-apply-patch/errors.js.map +1 -1
  139. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
  140. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
  141. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  142. package/dist/core/extensions/builtin/gpt-apply-patch/params.d.ts.map +1 -1
  143. package/dist/core/extensions/builtin/gpt-apply-patch/params.js.map +1 -1
  144. package/dist/core/extensions/builtin/gpt-apply-patch/parser.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/gpt-apply-patch/parser.js.map +1 -1
  146. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.d.ts.map +1 -1
  147. package/dist/core/extensions/builtin/gpt-apply-patch/patch-diff.js.map +1 -1
  148. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/gpt-apply-patch/patch-replace.js.map +1 -1
  150. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.d.ts.map +1 -1
  151. package/dist/core/extensions/builtin/gpt-apply-patch/preview-format.js.map +1 -1
  152. package/dist/core/extensions/builtin/gpt-apply-patch/preview.d.ts.map +1 -1
  153. package/dist/core/extensions/builtin/gpt-apply-patch/preview.js.map +1 -1
  154. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.d.ts.map +1 -1
  155. package/dist/core/extensions/builtin/gpt-apply-patch/seek-sequence.js.map +1 -1
  156. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.d.ts.map +1 -1
  157. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js +7 -5
  158. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-parser.js.map +1 -1
  159. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.d.ts.map +1 -1
  160. package/dist/core/extensions/builtin/gpt-apply-patch/streaming-render.js.map +1 -1
  161. package/dist/core/extensions/builtin/gpt-apply-patch/text.d.ts.map +1 -1
  162. package/dist/core/extensions/builtin/gpt-apply-patch/text.js.map +1 -1
  163. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  164. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  165. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
  166. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.d.ts.map +1 -1
  167. package/dist/core/extensions/builtin/gpt-apply-patch/workspace.js.map +1 -1
  168. package/dist/core/extensions/builtin/history-search/filter.d.ts.map +1 -1
  169. package/dist/core/extensions/builtin/history-search/filter.js.map +1 -1
  170. package/dist/core/extensions/builtin/history-search/index.d.ts.map +1 -1
  171. package/dist/core/extensions/builtin/history-search/index.js.map +1 -1
  172. package/dist/core/extensions/builtin/history-search/indexer.d.ts.map +1 -1
  173. package/dist/core/extensions/builtin/history-search/indexer.js.map +1 -1
  174. package/dist/core/extensions/builtin/history-search/overlay.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/history-search/overlay.js +3 -6
  176. package/dist/core/extensions/builtin/history-search/overlay.js.map +1 -1
  177. package/dist/core/extensions/builtin/history-search/types.d.ts.map +1 -1
  178. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  179. package/dist/core/extensions/builtin/kimi-web-search/index.d.ts.map +1 -1
  180. package/dist/core/extensions/builtin/kimi-web-search/index.js.map +1 -1
  181. package/dist/core/extensions/builtin/openai-web-search/index.d.ts.map +1 -1
  182. package/dist/core/extensions/builtin/openai-web-search/index.js.map +1 -1
  183. package/dist/core/extensions/builtin/permission-system/arity.d.ts.map +1 -1
  184. package/dist/core/extensions/builtin/permission-system/arity.js.map +1 -1
  185. package/dist/core/extensions/builtin/permission-system/cli.d.ts.map +1 -1
  186. package/dist/core/extensions/builtin/permission-system/cli.js.map +1 -1
  187. package/dist/core/extensions/builtin/permission-system/config.d.ts.map +1 -1
  188. package/dist/core/extensions/builtin/permission-system/config.js.map +1 -1
  189. package/dist/core/extensions/builtin/permission-system/evaluate.d.ts.map +1 -1
  190. package/dist/core/extensions/builtin/permission-system/evaluate.js.map +1 -1
  191. package/dist/core/extensions/builtin/permission-system/events.d.ts.map +1 -1
  192. package/dist/core/extensions/builtin/permission-system/events.js.map +1 -1
  193. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
  194. package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
  195. package/dist/core/extensions/builtin/permission-system/index.d.ts.map +1 -1
  196. package/dist/core/extensions/builtin/permission-system/index.js.map +1 -1
  197. package/dist/core/extensions/builtin/permission-system/non-interactive.d.ts.map +1 -1
  198. package/dist/core/extensions/builtin/permission-system/non-interactive.js.map +1 -1
  199. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
  200. package/dist/core/extensions/builtin/permission-system/parsers.js +3 -1
  201. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
  202. package/dist/core/extensions/builtin/permission-system/prompt.d.ts.map +1 -1
  203. package/dist/core/extensions/builtin/permission-system/prompt.js.map +1 -1
  204. package/dist/core/extensions/builtin/permission-system/service.d.ts.map +1 -1
  205. package/dist/core/extensions/builtin/permission-system/service.js +2 -5
  206. package/dist/core/extensions/builtin/permission-system/service.js.map +1 -1
  207. package/dist/core/extensions/builtin/permission-system/settings.d.ts.map +1 -1
  208. package/dist/core/extensions/builtin/permission-system/settings.js.map +1 -1
  209. package/dist/core/extensions/builtin/permission-system/storage.d.ts.map +1 -1
  210. package/dist/core/extensions/builtin/permission-system/storage.js.map +1 -1
  211. package/dist/core/extensions/builtin/permission-system/types.d.ts.map +1 -1
  212. package/dist/core/extensions/builtin/permission-system/types.js +3 -5
  213. package/dist/core/extensions/builtin/permission-system/types.js.map +1 -1
  214. package/dist/core/extensions/builtin/permission-system/wildcard.d.ts.map +1 -1
  215. package/dist/core/extensions/builtin/permission-system/wildcard.js.map +1 -1
  216. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
  217. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
  218. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
  219. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
  220. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
  221. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
  222. package/dist/core/extensions/builtin/prompt-preset/file-operations.d.ts.map +1 -1
  223. package/dist/core/extensions/builtin/prompt-preset/file-operations.js.map +1 -1
  224. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.d.ts.map +1 -1
  225. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
  226. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.d.ts.map +1 -1
  227. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
  228. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.d.ts.map +1 -1
  229. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
  230. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
  231. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
  232. package/dist/core/extensions/builtin/prompt-preset/gpt-5.d.ts.map +1 -1
  233. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
  234. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
  235. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
  236. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts.map +1 -1
  237. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
  238. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  239. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  240. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  241. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  242. package/dist/core/extensions/builtin/prompt-url-widget.d.ts.map +1 -1
  243. package/dist/core/extensions/builtin/prompt-url-widget.js.map +1 -1
  244. package/dist/core/extensions/builtin/redraws.d.ts.map +1 -1
  245. package/dist/core/extensions/builtin/redraws.js.map +1 -1
  246. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  247. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  248. package/dist/core/extensions/builtin/session-observer/index.d.ts.map +1 -1
  249. package/dist/core/extensions/builtin/session-observer/index.js.map +1 -1
  250. package/dist/core/extensions/builtin/session-observer/loader.d.ts.map +1 -1
  251. package/dist/core/extensions/builtin/session-observer/loader.js.map +1 -1
  252. package/dist/core/extensions/builtin/session-observer/overlay-format.d.ts.map +1 -1
  253. package/dist/core/extensions/builtin/session-observer/overlay-format.js.map +1 -1
  254. package/dist/core/extensions/builtin/session-observer/overlay.d.ts.map +1 -1
  255. package/dist/core/extensions/builtin/session-observer/overlay.js +13 -18
  256. package/dist/core/extensions/builtin/session-observer/overlay.js.map +1 -1
  257. package/dist/core/extensions/builtin/session-observer/scanner.d.ts.map +1 -1
  258. package/dist/core/extensions/builtin/session-observer/scanner.js.map +1 -1
  259. package/dist/core/extensions/builtin/session-observer/text.d.ts.map +1 -1
  260. package/dist/core/extensions/builtin/session-observer/text.js.map +1 -1
  261. package/dist/core/extensions/builtin/session-observer/transcript-entries.d.ts.map +1 -1
  262. package/dist/core/extensions/builtin/session-observer/transcript-entries.js.map +1 -1
  263. package/dist/core/extensions/builtin/session-observer/transcript-format.d.ts.map +1 -1
  264. package/dist/core/extensions/builtin/session-observer/transcript-format.js.map +1 -1
  265. package/dist/core/extensions/builtin/session-observer/transcript.d.ts.map +1 -1
  266. package/dist/core/extensions/builtin/session-observer/transcript.js.map +1 -1
  267. package/dist/core/extensions/builtin/session-observer/types.d.ts.map +1 -1
  268. package/dist/core/extensions/builtin/system-messages.d.ts.map +1 -1
  269. package/dist/core/extensions/builtin/system-messages.js.map +1 -1
  270. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts +1 -1
  271. package/dist/core/extensions/builtin/todotools/continuation/config.d.ts.map +1 -1
  272. package/dist/core/extensions/builtin/todotools/continuation/config.js.map +1 -1
  273. package/dist/core/extensions/builtin/todotools/continuation/index.d.ts.map +1 -1
  274. package/dist/core/extensions/builtin/todotools/continuation/prompt.d.ts.map +1 -1
  275. package/dist/core/extensions/builtin/todotools/continuation/prompt.js.map +1 -1
  276. package/dist/core/extensions/builtin/todotools/continuation/runtime.d.ts.map +1 -1
  277. package/dist/core/extensions/builtin/todotools/continuation/runtime.js.map +1 -1
  278. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
  279. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  280. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  281. package/dist/core/extensions/builtin/todotools/settings.d.ts.map +1 -1
  282. package/dist/core/extensions/builtin/todotools/settings.js.map +1 -1
  283. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  284. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  285. package/dist/core/extensions/builtin/todotools/system-messages.d.ts.map +1 -1
  286. package/dist/core/extensions/builtin/todotools/system-messages.js.map +1 -1
  287. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +1 -1
  288. package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +1 -1
  289. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +1 -1
  290. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +1 -1
  291. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
  292. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
  293. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +1 -1
  294. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +1 -1
  295. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.d.ts.map +1 -1
  296. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-chat-completions-payload.js.map +1 -1
  297. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.d.ts.map +1 -1
  298. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-openai-responses-payload.js.map +1 -1
  299. package/dist/core/extensions/builtin/tps.d.ts.map +1 -1
  300. package/dist/core/extensions/builtin/tps.js.map +1 -1
  301. package/dist/core/extensions/index.d.ts.map +1 -1
  302. package/dist/core/extensions/loader.d.ts.map +1 -1
  303. package/dist/core/extensions/loader.js.map +1 -1
  304. package/dist/core/extensions/runner.d.ts.map +1 -1
  305. package/dist/core/extensions/runner.js +35 -43
  306. package/dist/core/extensions/runner.js.map +1 -1
  307. package/dist/core/extensions/types.d.ts +1 -1
  308. package/dist/core/extensions/types.d.ts.map +1 -1
  309. package/dist/core/extensions/types.js.map +1 -1
  310. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  311. package/dist/core/extensions/wrapper.js.map +1 -1
  312. package/dist/core/footer-data-provider.d.ts.map +1 -1
  313. package/dist/core/footer-data-provider.js +17 -18
  314. package/dist/core/footer-data-provider.js.map +1 -1
  315. package/dist/core/http-dispatcher.d.ts.map +1 -1
  316. package/dist/core/http-dispatcher.js.map +1 -1
  317. package/dist/core/index.d.ts.map +1 -1
  318. package/dist/core/keybindings.d.ts +1 -1
  319. package/dist/core/keybindings.d.ts.map +1 -1
  320. package/dist/core/keybindings.js +0 -1
  321. package/dist/core/keybindings.js.map +1 -1
  322. package/dist/core/messages.d.ts.map +1 -1
  323. package/dist/core/messages.js.map +1 -1
  324. package/dist/core/model-registry.d.ts.map +1 -1
  325. package/dist/core/model-registry.js +8 -10
  326. package/dist/core/model-registry.js.map +1 -1
  327. package/dist/core/model-resolver.d.ts.map +1 -1
  328. package/dist/core/model-resolver.js.map +1 -1
  329. package/dist/core/output-guard.d.ts.map +1 -1
  330. package/dist/core/output-guard.js.map +1 -1
  331. package/dist/core/package-manager.d.ts +1 -0
  332. package/dist/core/package-manager.d.ts.map +1 -1
  333. package/dist/core/package-manager.js +25 -13
  334. package/dist/core/package-manager.js.map +1 -1
  335. package/dist/core/prompt-templates.d.ts.map +1 -1
  336. package/dist/core/prompt-templates.js.map +1 -1
  337. package/dist/core/provider-attribution.d.ts.map +1 -1
  338. package/dist/core/provider-attribution.js.map +1 -1
  339. package/dist/core/provider-display-names.d.ts.map +1 -1
  340. package/dist/core/resolve-config-value.d.ts.map +1 -1
  341. package/dist/core/resolve-config-value.js.map +1 -1
  342. package/dist/core/resource-loader.d.ts +1 -0
  343. package/dist/core/resource-loader.d.ts.map +1 -1
  344. package/dist/core/resource-loader.js +26 -53
  345. package/dist/core/resource-loader.js.map +1 -1
  346. package/dist/core/sdk.d.ts.map +1 -1
  347. package/dist/core/sdk.js.map +1 -1
  348. package/dist/core/session-cwd.d.ts.map +1 -1
  349. package/dist/core/session-cwd.js +0 -1
  350. package/dist/core/session-cwd.js.map +1 -1
  351. package/dist/core/session-manager.d.ts.map +1 -1
  352. package/dist/core/session-manager.js +7 -11
  353. package/dist/core/session-manager.js.map +1 -1
  354. package/dist/core/session-work-barrier.d.ts.map +1 -1
  355. package/dist/core/session-work-barrier.js +5 -3
  356. package/dist/core/session-work-barrier.js.map +1 -1
  357. package/dist/core/settings-manager.d.ts +10 -2
  358. package/dist/core/settings-manager.d.ts.map +1 -1
  359. package/dist/core/settings-manager.js +77 -46
  360. package/dist/core/settings-manager.js.map +1 -1
  361. package/dist/core/skills.d.ts.map +1 -1
  362. package/dist/core/skills.js.map +1 -1
  363. package/dist/core/slash-commands.d.ts.map +1 -1
  364. package/dist/core/slash-commands.js +1 -0
  365. package/dist/core/slash-commands.js.map +1 -1
  366. package/dist/core/source-info.d.ts.map +1 -1
  367. package/dist/core/source-info.js.map +1 -1
  368. package/dist/core/system-prompt.d.ts.map +1 -1
  369. package/dist/core/system-prompt.js.map +1 -1
  370. package/dist/core/telemetry.d.ts.map +1 -1
  371. package/dist/core/telemetry.js.map +1 -1
  372. package/dist/core/thinking-levels.d.ts.map +1 -1
  373. package/dist/core/thinking-levels.js.map +1 -1
  374. package/dist/core/timings.d.ts.map +1 -1
  375. package/dist/core/timings.js.map +1 -1
  376. package/dist/core/tools/bash.d.ts.map +1 -1
  377. package/dist/core/tools/bash.js +9 -6
  378. package/dist/core/tools/bash.js.map +1 -1
  379. package/dist/core/tools/diff-render.d.ts.map +1 -1
  380. package/dist/core/tools/diff-render.js.map +1 -1
  381. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  382. package/dist/core/tools/edit-diff.js.map +1 -1
  383. package/dist/core/tools/edit.d.ts.map +1 -1
  384. package/dist/core/tools/edit.js.map +1 -1
  385. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  386. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  387. package/dist/core/tools/find.d.ts.map +1 -1
  388. package/dist/core/tools/find.js +1 -1
  389. package/dist/core/tools/find.js.map +1 -1
  390. package/dist/core/tools/grep.d.ts.map +1 -1
  391. package/dist/core/tools/grep.js +1 -1
  392. package/dist/core/tools/grep.js.map +1 -1
  393. package/dist/core/tools/index.d.ts.map +1 -1
  394. package/dist/core/tools/index.js.map +1 -1
  395. package/dist/core/tools/ls.d.ts.map +1 -1
  396. package/dist/core/tools/ls.js +1 -1
  397. package/dist/core/tools/ls.js.map +1 -1
  398. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  399. package/dist/core/tools/output-accumulator.js +12 -18
  400. package/dist/core/tools/output-accumulator.js.map +1 -1
  401. package/dist/core/tools/path-utils.d.ts.map +1 -1
  402. package/dist/core/tools/path-utils.js.map +1 -1
  403. package/dist/core/tools/read.d.ts.map +1 -1
  404. package/dist/core/tools/read.js +1 -1
  405. package/dist/core/tools/read.js.map +1 -1
  406. package/dist/core/tools/render-utils.d.ts.map +1 -1
  407. package/dist/core/tools/render-utils.js.map +1 -1
  408. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  409. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  410. package/dist/core/tools/truncate.d.ts.map +1 -1
  411. package/dist/core/tools/truncate.js.map +1 -1
  412. package/dist/core/tools/write.d.ts.map +1 -1
  413. package/dist/core/tools/write.js +1 -2
  414. package/dist/core/tools/write.js.map +1 -1
  415. package/dist/core/trust-manager.d.ts +9 -0
  416. package/dist/core/trust-manager.d.ts.map +1 -0
  417. package/dist/core/trust-manager.js +133 -0
  418. package/dist/core/trust-manager.js.map +1 -0
  419. package/dist/index.d.ts +2 -1
  420. package/dist/index.d.ts.map +1 -1
  421. package/dist/index.js +1 -0
  422. package/dist/index.js.map +1 -1
  423. package/dist/main.d.ts.map +1 -1
  424. package/dist/main.js +54 -2
  425. package/dist/main.js.map +1 -1
  426. package/dist/migrations.d.ts.map +1 -1
  427. package/dist/migrations.js.map +1 -1
  428. package/dist/modes/index.d.ts.map +1 -1
  429. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  430. package/dist/modes/interactive/components/armin.js +6 -10
  431. package/dist/modes/interactive/components/armin.js.map +1 -1
  432. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  433. package/dist/modes/interactive/components/assistant-message.js +2 -11
  434. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  435. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  436. package/dist/modes/interactive/components/bash-execution.js +6 -11
  437. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  438. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  439. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  440. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  441. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  442. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  443. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  444. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  445. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  446. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  447. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  448. package/dist/modes/interactive/components/config-selector.js +5 -15
  449. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  450. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  451. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  452. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  453. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  454. package/dist/modes/interactive/components/custom-editor.js +1 -8
  455. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  456. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  457. package/dist/modes/interactive/components/custom-message.js +1 -6
  458. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  459. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  460. package/dist/modes/interactive/components/daxnuts.js +6 -8
  461. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  462. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  463. package/dist/modes/interactive/components/diff.js +2 -2
  464. package/dist/modes/interactive/components/diff.js.map +1 -1
  465. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  466. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  467. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  468. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  469. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  470. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  471. package/dist/modes/interactive/components/extension-editor.js +1 -6
  472. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  473. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  474. package/dist/modes/interactive/components/extension-input.js +2 -8
  475. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  476. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  477. package/dist/modes/interactive/components/extension-selector.js +1 -9
  478. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  479. package/dist/modes/interactive/components/favorite-models-selector.d.ts.map +1 -1
  480. package/dist/modes/interactive/components/favorite-models-selector.js +9 -15
  481. package/dist/modes/interactive/components/favorite-models-selector.js.map +1 -1
  482. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  483. package/dist/modes/interactive/components/footer.js +10 -3
  484. package/dist/modes/interactive/components/footer.js.map +1 -1
  485. package/dist/modes/interactive/components/index.d.ts +1 -0
  486. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  487. package/dist/modes/interactive/components/index.js +1 -0
  488. package/dist/modes/interactive/components/index.js.map +1 -1
  489. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  490. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  491. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  492. package/dist/modes/interactive/components/login-dialog.js +3 -9
  493. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  494. package/dist/modes/interactive/components/model-favorites.d.ts.map +1 -1
  495. package/dist/modes/interactive/components/model-favorites.js.map +1 -1
  496. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  497. package/dist/modes/interactive/components/model-selector.js +9 -22
  498. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  499. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  500. package/dist/modes/interactive/components/oauth-selector.js +3 -12
  501. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  502. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  503. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  504. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  505. package/dist/modes/interactive/components/session-selector.js +33 -58
  506. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  507. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  508. package/dist/modes/interactive/components/settings-selector.js +0 -4
  509. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  510. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  511. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  512. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  513. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  514. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  515. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  516. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  517. package/dist/modes/interactive/components/theme-selector.js +0 -2
  518. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  519. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  520. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  521. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  522. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/tool-execution.js +9 -28
  524. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  525. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  526. package/dist/modes/interactive/components/tree-selector.js +18 -32
  527. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  528. package/dist/modes/interactive/components/trust-selector.d.ts +20 -0
  529. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  530. package/dist/modes/interactive/components/trust-selector.js +81 -0
  531. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  532. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  533. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  534. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  535. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  536. package/dist/modes/interactive/components/user-message.js +0 -1
  537. package/dist/modes/interactive/components/user-message.js.map +1 -1
  538. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  539. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  540. package/dist/modes/interactive/interactive-mode.d.ts +24 -0
  541. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  542. package/dist/modes/interactive/interactive-mode.js +112 -101
  543. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  544. package/dist/modes/interactive/session-info-format.d.ts.map +1 -1
  545. package/dist/modes/interactive/session-info-format.js.map +1 -1
  546. package/dist/modes/interactive/startup-tools.d.ts.map +1 -1
  547. package/dist/modes/interactive/startup-tools.js.map +1 -1
  548. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  549. package/dist/modes/interactive/theme/theme.js +0 -6
  550. package/dist/modes/interactive/theme/theme.js.map +1 -1
  551. package/dist/modes/interactive/working-status.d.ts.map +1 -1
  552. package/dist/modes/interactive/working-status.js.map +1 -1
  553. package/dist/modes/print-mode.d.ts.map +1 -1
  554. package/dist/modes/print-mode.js.map +1 -1
  555. package/dist/modes/provider-native-rendering.d.ts.map +1 -1
  556. package/dist/modes/provider-native-rendering.js.map +1 -1
  557. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  558. package/dist/modes/rpc/jsonl.js.map +1 -1
  559. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  560. package/dist/modes/rpc/rpc-client.js +7 -8
  561. package/dist/modes/rpc/rpc-client.js.map +1 -1
  562. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  563. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  564. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  565. package/dist/package-manager-cli.d.ts.map +1 -1
  566. package/dist/package-manager-cli.js +56 -9
  567. package/dist/package-manager-cli.js.map +1 -1
  568. package/dist/self-update-bootstrap.d.ts.map +1 -1
  569. package/dist/self-update-bootstrap.js.map +1 -1
  570. package/dist/utils/ansi.d.ts.map +1 -1
  571. package/dist/utils/ansi.js.map +1 -1
  572. package/dist/utils/changelog.d.ts.map +1 -1
  573. package/dist/utils/changelog.js.map +1 -1
  574. package/dist/utils/child-process.d.ts.map +1 -1
  575. package/dist/utils/child-process.js.map +1 -1
  576. package/dist/utils/clipboard-image.d.ts.map +1 -1
  577. package/dist/utils/clipboard-image.js.map +1 -1
  578. package/dist/utils/clipboard-native.d.ts.map +1 -1
  579. package/dist/utils/clipboard-native.js.map +1 -1
  580. package/dist/utils/clipboard.d.ts.map +1 -1
  581. package/dist/utils/clipboard.js.map +1 -1
  582. package/dist/utils/deprecation.d.ts.map +1 -1
  583. package/dist/utils/deprecation.js.map +1 -1
  584. package/dist/utils/exif-orientation.d.ts.map +1 -1
  585. package/dist/utils/exif-orientation.js.map +1 -1
  586. package/dist/utils/frontmatter.d.ts.map +1 -1
  587. package/dist/utils/frontmatter.js.map +1 -1
  588. package/dist/utils/fs-watch.d.ts.map +1 -1
  589. package/dist/utils/fs-watch.js.map +1 -1
  590. package/dist/utils/git.d.ts.map +1 -1
  591. package/dist/utils/git.js.map +1 -1
  592. package/dist/utils/html.d.ts.map +1 -1
  593. package/dist/utils/html.js.map +1 -1
  594. package/dist/utils/image-convert.d.ts.map +1 -1
  595. package/dist/utils/image-convert.js.map +1 -1
  596. package/dist/utils/image-resize-core.d.ts.map +1 -1
  597. package/dist/utils/image-resize-core.js.map +1 -1
  598. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  599. package/dist/utils/image-resize-worker.js.map +1 -1
  600. package/dist/utils/image-resize.d.ts.map +1 -1
  601. package/dist/utils/image-resize.js.map +1 -1
  602. package/dist/utils/json.d.ts.map +1 -1
  603. package/dist/utils/json.js.map +1 -1
  604. package/dist/utils/mime.d.ts.map +1 -1
  605. package/dist/utils/mime.js.map +1 -1
  606. package/dist/utils/open-browser.d.ts.map +1 -1
  607. package/dist/utils/open-browser.js.map +1 -1
  608. package/dist/utils/paths.d.ts.map +1 -1
  609. package/dist/utils/paths.js.map +1 -1
  610. package/dist/utils/photon.d.ts.map +1 -1
  611. package/dist/utils/photon.js.map +1 -1
  612. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  613. package/dist/utils/pi-user-agent.js.map +1 -1
  614. package/dist/utils/shell.d.ts.map +1 -1
  615. package/dist/utils/shell.js.map +1 -1
  616. package/dist/utils/sleep.d.ts.map +1 -1
  617. package/dist/utils/sleep.js.map +1 -1
  618. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  619. package/dist/utils/syntax-highlight.js.map +1 -1
  620. package/dist/utils/tools-manager.d.ts.map +1 -1
  621. package/dist/utils/tools-manager.js.map +1 -1
  622. package/dist/utils/version-check.d.ts.map +1 -1
  623. package/dist/utils/version-check.js.map +1 -1
  624. package/dist/utils/windows-self-update.d.ts.map +1 -1
  625. package/dist/utils/windows-self-update.js.map +1 -1
  626. package/docs/extensions.md +1 -1
  627. package/docs/packages.md +3 -1
  628. package/docs/prompt-templates.md +1 -1
  629. package/docs/settings.md +10 -0
  630. package/docs/skills.md +3 -3
  631. package/docs/themes.md +1 -1
  632. package/docs/usage.md +15 -3
  633. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  634. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  635. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  636. package/examples/extensions/gondolin/package-lock.json +2 -2
  637. package/examples/extensions/gondolin/package.json +1 -1
  638. package/examples/extensions/minimal-mode.ts +6 -6
  639. package/examples/extensions/sandbox/package-lock.json +2 -2
  640. package/examples/extensions/sandbox/package.json +1 -1
  641. package/examples/extensions/with-deps/package-lock.json +2 -2
  642. package/examples/extensions/with-deps/package.json +1 -1
  643. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  644. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  645. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +7 -0
  646. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  647. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -27
  648. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  649. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  650. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +7 -20
  651. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  652. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  653. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
  654. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  655. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  656. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
  657. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
  658. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  659. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +0 -3
  660. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  661. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
  662. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
  663. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts.map +1 -1
  664. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js.map +1 -1
  665. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -1
  666. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -3
  667. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +1 -1
  668. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  669. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -7
  670. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
  671. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -1
  672. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +3 -1
  673. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +1 -1
  674. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
  675. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -5
  676. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
  677. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
  678. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
  679. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  680. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +0 -1
  681. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  682. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +1 -1
  683. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +1 -1
  684. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts.map +1 -1
  685. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js.map +1 -1
  686. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts.map +1 -1
  687. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js.map +1 -1
  688. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  689. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +0 -16
  690. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  691. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  692. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  693. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
  694. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
  695. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  696. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts.map +1 -1
  697. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  698. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  699. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  700. package/node_modules/@earendil-works/pi-agent-core/package.json +6 -6
  701. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
  702. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
  703. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts.map +1 -1
  704. package/node_modules/@earendil-works/pi-ai/dist/cli.d.ts.map +1 -1
  705. package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -1
  706. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  707. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  708. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts.map +1 -1
  709. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
  710. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  711. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +30 -0
  712. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  713. package/node_modules/@earendil-works/pi-ai/dist/image-models.js.map +1 -1
  714. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
  715. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
  716. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
  717. package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -1
  718. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  719. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  720. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +174 -29
  721. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  722. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +178 -54
  723. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  724. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  725. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -1
  726. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  727. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  728. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  729. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  730. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  731. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  732. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts.map +1 -1
  733. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js.map +1 -1
  734. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  735. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  736. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  737. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  738. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  739. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js.map +1 -1
  740. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
  741. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -1
  742. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts.map +1 -1
  743. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js.map +1 -1
  744. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts.map +1 -1
  745. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js.map +1 -1
  746. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -1
  747. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
  748. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts.map +1 -1
  749. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js +3 -3
  750. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js.map +1 -1
  751. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  752. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +0 -7
  753. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  754. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  755. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +1 -1
  756. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
  757. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -1
  758. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js.map +1 -1
  759. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -1
  760. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js.map +1 -1
  761. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  762. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
  763. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  764. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js.map +1 -1
  765. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  766. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
  767. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
  768. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.js.map +1 -1
  769. package/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts.map +1 -1
  770. package/node_modules/@earendil-works/pi-ai/dist/session-resources.js.map +1 -1
  771. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts.map +1 -1
  772. package/node_modules/@earendil-works/pi-ai/dist/stream.js.map +1 -1
  773. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
  774. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
  775. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
  776. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
  777. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
  778. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +10 -8
  779. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
  780. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.d.ts.map +1 -1
  781. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.js.map +1 -1
  782. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
  783. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
  784. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
  785. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
  786. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.d.ts.map +1 -1
  787. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.js.map +1 -1
  788. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
  789. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
  790. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
  791. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
  792. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
  793. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +1 -1
  794. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  795. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  796. package/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.d.ts.map +1 -1
  797. package/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js.map +1 -1
  798. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts.map +1 -1
  799. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js.map +1 -1
  800. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  801. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +3 -7
  802. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
  803. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.d.ts.map +1 -1
  804. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.js.map +1 -1
  805. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.d.ts.map +1 -1
  806. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js.map +1 -1
  807. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts.map +1 -1
  808. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js.map +1 -1
  809. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -1
  810. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -1
  811. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -1
  812. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +1 -1
  813. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts.map +1 -1
  814. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js.map +1 -1
  815. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
  816. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
  817. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +1 -1
  818. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +1 -1
  819. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts.map +1 -1
  820. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js.map +1 -1
  821. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -1
  822. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -1
  823. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -1
  824. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js.map +1 -1
  825. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +1 -1
  826. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  827. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  828. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -1
  829. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js.map +1 -1
  830. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
  831. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
  832. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -1
  833. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js.map +1 -1
  834. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -1
  835. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
  836. package/node_modules/@earendil-works/pi-ai/package.json +5 -5
  837. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +1 -1
  838. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  839. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -3
  840. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  841. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
  842. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +1 -6
  843. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -1
  844. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -1
  845. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +4 -3
  846. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +1 -1
  847. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  848. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +43 -54
  849. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  850. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  851. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -8
  852. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  853. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
  854. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +14 -14
  855. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
  856. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +1 -1
  857. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +11 -13
  858. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +1 -1
  859. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  860. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -11
  861. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  862. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -1
  863. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +4 -9
  864. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -1
  865. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  866. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +4 -12
  867. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  868. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +1 -1
  869. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -1
  870. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +1 -1
  871. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
  872. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -8
  873. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
  874. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +1 -1
  875. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -3
  876. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +1 -1
  877. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +1 -1
  878. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +1 -1
  879. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +1 -1
  880. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  881. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  882. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +2 -4
  883. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  884. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
  885. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
  886. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +1 -1
  887. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +3 -1
  888. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +1 -1
  889. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +1 -1
  890. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +1 -1
  891. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.d.ts.map +1 -1
  892. package/node_modules/@earendil-works/pi-tui/dist/slash-command-autocomplete.js.map +1 -1
  893. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  894. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +4 -6
  895. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  896. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  897. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  898. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  899. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +24 -29
  900. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  901. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  902. package/node_modules/@earendil-works/pi-tui/dist/tui.js +25 -27
  903. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  904. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +1 -1
  905. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +3 -1
  906. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +1 -1
  907. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  908. package/node_modules/@earendil-works/pi-tui/dist/utils.js +14 -12
  909. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  910. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +1 -1
  911. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +1 -1
  912. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  913. package/node_modules/@types/node/README.md +3 -3
  914. package/node_modules/@types/node/assert/strict.d.ts +3 -55
  915. package/node_modules/@types/node/assert.d.ts +49 -177
  916. package/node_modules/@types/node/async_hooks.d.ts +151 -43
  917. package/node_modules/@types/node/buffer.buffer.d.ts +2 -8
  918. package/node_modules/@types/node/buffer.d.ts +43 -212
  919. package/node_modules/@types/node/child_process.d.ts +23 -133
  920. package/node_modules/@types/node/cluster.d.ts +238 -384
  921. package/node_modules/@types/node/compatibility/iterators.d.ts +1 -0
  922. package/node_modules/@types/node/console.d.ts +45 -404
  923. package/node_modules/@types/node/constants.d.ts +3 -10
  924. package/node_modules/@types/node/crypto.d.ts +640 -1127
  925. package/node_modules/@types/node/dgram.d.ts +14 -77
  926. package/node_modules/@types/node/diagnostics_channel.d.ts +3 -29
  927. package/node_modules/@types/node/dns/promises.d.ts +4 -10
  928. package/node_modules/@types/node/dns.d.ts +130 -177
  929. package/node_modules/@types/node/domain.d.ts +12 -32
  930. package/node_modules/@types/node/events.d.ts +872 -840
  931. package/node_modules/@types/node/fs/promises.d.ts +193 -20
  932. package/node_modules/@types/node/fs.d.ts +754 -435
  933. package/node_modules/@types/node/globals.d.ts +8 -30
  934. package/node_modules/@types/node/globals.typedarray.d.ts +63 -0
  935. package/node_modules/@types/node/http.d.ts +363 -305
  936. package/node_modules/@types/node/http2.d.ts +545 -781
  937. package/node_modules/@types/node/https.d.ts +64 -243
  938. package/node_modules/@types/node/index.d.ts +26 -6
  939. package/node_modules/@types/node/inspector/promises.d.ts +35 -0
  940. package/node_modules/@types/node/inspector.d.ts +68 -57
  941. package/node_modules/@types/node/inspector.generated.d.ts +764 -410
  942. package/node_modules/@types/node/module.d.ts +53 -189
  943. package/node_modules/@types/node/net.d.ts +101 -207
  944. package/node_modules/@types/node/os.d.ts +11 -19
  945. package/node_modules/@types/node/package.json +13 -3
  946. package/node_modules/@types/node/path/posix.d.ts +8 -0
  947. package/node_modules/@types/node/path/win32.d.ts +8 -0
  948. package/node_modules/@types/node/path.d.ts +119 -141
  949. package/node_modules/@types/node/perf_hooks.d.ts +317 -673
  950. package/node_modules/@types/node/process.d.ts +277 -157
  951. package/node_modules/@types/node/punycode.d.ts +3 -31
  952. package/node_modules/@types/node/querystring.d.ts +3 -16
  953. package/node_modules/@types/node/quic.d.ts +897 -0
  954. package/node_modules/@types/node/readline/promises.d.ts +3 -6
  955. package/node_modules/@types/node/readline.d.ts +65 -152
  956. package/node_modules/@types/node/repl.d.ts +101 -109
  957. package/node_modules/@types/node/sea.d.ts +9 -115
  958. package/node_modules/@types/node/sqlite.d.ts +415 -68
  959. package/node_modules/@types/node/stream/consumers.d.ts +91 -15
  960. package/node_modules/@types/node/stream/iter.d.ts +301 -0
  961. package/node_modules/@types/node/stream/promises.d.ts +136 -15
  962. package/node_modules/@types/node/stream/web.d.ts +179 -501
  963. package/node_modules/@types/node/stream.d.ts +577 -490
  964. package/node_modules/@types/node/string_decoder.d.ts +3 -43
  965. package/node_modules/@types/node/test/reporters.d.ts +59 -0
  966. package/node_modules/@types/node/test.d.ts +402 -286
  967. package/node_modules/@types/node/timers/promises.d.ts +3 -18
  968. package/node_modules/@types/node/timers.d.ts +3 -141
  969. package/node_modules/@types/node/tls.d.ts +115 -241
  970. package/node_modules/@types/node/trace_events.d.ts +3 -97
  971. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +2 -8
  972. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  973. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +2 -0
  974. package/node_modules/@types/node/ts5.6/index.d.ts +28 -6
  975. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  976. package/node_modules/@types/node/ts5.7/index.d.ts +119 -0
  977. package/node_modules/@types/node/tty.d.ts +57 -40
  978. package/node_modules/@types/node/url.d.ts +156 -584
  979. package/node_modules/@types/node/util/types.d.ts +558 -0
  980. package/node_modules/@types/node/util.d.ts +167 -1096
  981. package/node_modules/@types/node/v8.d.ts +75 -15
  982. package/node_modules/@types/node/vm.d.ts +334 -198
  983. package/node_modules/@types/node/wasi.d.ts +24 -74
  984. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +27 -2
  985. package/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  986. package/node_modules/@types/node/web-globals/console.d.ts +9 -0
  987. package/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  988. package/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  989. package/node_modules/@types/node/web-globals/events.d.ts +9 -0
  990. package/node_modules/@types/node/web-globals/fetch.d.ts +14 -0
  991. package/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  992. package/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  993. package/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
  994. package/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  995. package/node_modules/@types/node/web-globals/streams.d.ts +115 -0
  996. package/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  997. package/node_modules/@types/node/web-globals/url.d.ts +24 -0
  998. package/node_modules/@types/node/worker_threads.d.ts +280 -393
  999. package/node_modules/@types/node/zlib/iter.d.ts +131 -0
  1000. package/node_modules/@types/node/zlib.d.ts +7 -165
  1001. package/node_modules/undici-types/agent.d.ts +13 -12
  1002. package/node_modules/undici-types/api.d.ts +26 -26
  1003. package/node_modules/undici-types/balanced-pool.d.ts +13 -12
  1004. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  1005. package/node_modules/undici-types/client-stats.d.ts +15 -0
  1006. package/node_modules/undici-types/client.d.ts +34 -19
  1007. package/node_modules/undici-types/connector.d.ts +4 -2
  1008. package/node_modules/undici-types/cookies.d.ts +2 -0
  1009. package/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
  1010. package/node_modules/undici-types/dispatcher.d.ts +127 -104
  1011. package/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
  1012. package/node_modules/undici-types/errors.d.ts +82 -54
  1013. package/node_modules/undici-types/eventsource.d.ts +9 -4
  1014. package/node_modules/undici-types/fetch.d.ts +22 -20
  1015. package/node_modules/undici-types/formdata.d.ts +7 -7
  1016. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  1017. package/node_modules/undici-types/global-origin.d.ts +5 -5
  1018. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  1019. package/node_modules/undici-types/handlers.d.ts +8 -8
  1020. package/node_modules/undici-types/header.d.ts +157 -1
  1021. package/node_modules/undici-types/index.d.ts +67 -47
  1022. package/node_modules/undici-types/interceptors.d.ts +71 -8
  1023. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  1024. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  1025. package/node_modules/undici-types/mock-client.d.ts +6 -4
  1026. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  1027. package/node_modules/undici-types/mock-interceptor.d.ts +21 -20
  1028. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  1029. package/node_modules/undici-types/package.json +1 -1
  1030. package/node_modules/undici-types/patch.d.ts +0 -4
  1031. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  1032. package/node_modules/undici-types/pool.d.ts +15 -13
  1033. package/node_modules/undici-types/proxy-agent.d.ts +5 -4
  1034. package/node_modules/undici-types/readable.d.ts +19 -16
  1035. package/node_modules/undici-types/retry-agent.d.ts +1 -1
  1036. package/node_modules/undici-types/retry-handler.d.ts +19 -10
  1037. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  1038. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  1039. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  1040. package/node_modules/undici-types/util.d.ts +3 -3
  1041. package/node_modules/undici-types/utility.d.ts +7 -0
  1042. package/node_modules/undici-types/webidl.d.ts +148 -29
  1043. package/node_modules/undici-types/websocket.d.ts +48 -10
  1044. package/npm-shrinkwrap.json +21 -21
  1045. package/package.json +13 -8
  1046. package/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  1047. package/node_modules/@types/node/compatibility/index.d.ts +0 -9
  1048. package/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  1049. package/node_modules/undici-types/file.d.ts +0 -39
  1050. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/state.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,kBAAkB,GAA6B;IAC9D,OAAO;QACN,mBAAmB,EAAE,CAAC;QACtB,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE,CAAC;QACnB,gBAAgB,EAAE,CAAC;QACnB,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;KACjB,CAAC;AAAA,CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA+B,EAAE,MAAc,EAA4B;IAC3G,OAAO,EAAE,GAAG,KAAK,EAAE,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;AAAA,CACjD","sourcesContent":["import type { RestorationTrackerState } from \"./restoration-tracker.ts\";\n\nexport interface CompactionYieldSnapshot {\n\tsavedTokens: number;\n\ttokensBefore: number;\n}\n\nexport interface CompactionExtensionState {\n\tconsecutiveFailures: number;\n\ttrippedAt: number | null;\n\tacceptedThisTurn: number;\n\tacceptedAbsolute: number;\n\tlastYield: CompactionYieldSnapshot | null;\n\tturnId: string | null;\n\trestoration: RestorationTrackerState | null;\n}\n\nexport function createInitialState(): CompactionExtensionState {\n\treturn {\n\t\tconsecutiveFailures: 0,\n\t\ttrippedAt: null,\n\t\tacceptedThisTurn: 0,\n\t\tacceptedAbsolute: 0,\n\t\tlastYield: null,\n\t\tturnId: null,\n\t\trestoration: null,\n\t};\n}\n\nexport function resetTurnCounter(state: CompactionExtensionState, turnId: string): CompactionExtensionState {\n\treturn { ...state, acceptedThisTurn: 0, turnId };\n}\n"]}
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/state.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,kBAAkB;IACjC,OAAO;QACN,mBAAmB,EAAE,CAAC;QACtB,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE,CAAC;QACnB,gBAAgB,EAAE,CAAC;QACnB,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;KACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA+B,EAAE,MAAc;IAC/E,OAAO,EAAE,GAAG,KAAK,EAAE,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC","sourcesContent":["import type { RestorationTrackerState } from \"./restoration-tracker.ts\";\n\nexport interface CompactionYieldSnapshot {\n\tsavedTokens: number;\n\ttokensBefore: number;\n}\n\nexport interface CompactionExtensionState {\n\tconsecutiveFailures: number;\n\ttrippedAt: number | null;\n\tacceptedThisTurn: number;\n\tacceptedAbsolute: number;\n\tlastYield: CompactionYieldSnapshot | null;\n\tturnId: string | null;\n\trestoration: RestorationTrackerState | null;\n}\n\nexport function createInitialState(): CompactionExtensionState {\n\treturn {\n\t\tconsecutiveFailures: 0,\n\t\ttrippedAt: null,\n\t\tacceptedThisTurn: 0,\n\t\tacceptedAbsolute: 0,\n\t\tlastYield: null,\n\t\tturnId: null,\n\t\trestoration: null,\n\t};\n}\n\nexport function resetTurnCounter(state: CompactionExtensionState, turnId: string): CompactionExtensionState {\n\treturn { ...state, acceptedThisTurn: 0, turnId };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"todo-bridge.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/todo-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGrE,QAAA,MAAM,oBAAoB,sCAAsC,CAAC;AAEjE,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC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,EACzB,EAAE,EAAE,iBAAiB,GACnB,aAAa,CAAC","sourcesContent":["import type { CustomEntry, SessionEntry } from \"../../../session-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\n\nconst TODO_SNAPSHOT_CUSTOM_TYPE = \"compaction.todo-snapshot\";\nconst TODO_SNAPSHOT_SCHEMA = \"senpi.compaction.todo-snapshot.v1\";\n\nexport interface TodoEntry {\n\tid: string;\n\tcontent?: string;\n\ttext?: string;\n\tstatus?: \"pending\" | \"in_progress\" | \"completed\" | \"cancelled\";\n}\n\nexport interface TodoSnapshotPayload {\n\tschema: typeof TODO_SNAPSHOT_SCHEMA;\n\ttodos: TodoEntry[] | SessionEntry[];\n\tcapturedAt: number;\n}\n\ninterface AppendEntryTarget {\n\tappendEntry<T = unknown>(customType: string, data?: T): void;\n}\n\ninterface SendMessageTarget extends AppendEntryTarget {\n\tsendMessage<T = unknown>(\n\t\tmessage: { customType: string; content: string; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): void;\n}\n\ninterface RestoreResult {\n\tapplied: boolean;\n\trestoredTodos: TodoEntry[];\n}\n\nfunction isCustomTodoEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType.startsWith(\"todowrite\");\n}\n\nfunction isLegacyTodoListEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType === \"todo-list\";\n}\n\nfunction readTodosFromEntry(entry: CustomEntry): TodoEntry[] {\n\tconst data = entry.data;\n\tif (typeof data !== \"object\" || data === null || !(\"todos\" in data) || !Array.isArray(data.todos)) {\n\t\treturn [];\n\t}\n\treturn data.todos.filter((todo): todo is TodoEntry => {\n\t\treturn typeof todo === \"object\" && todo !== null && \"id\" in todo && typeof todo.id === \"string\";\n\t});\n}\n\nfunction findLatestTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload | null {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== TODO_SNAPSHOT_CUSTOM_TYPE) continue;\n\t\tconst data = entry.data;\n\t\tif (typeof data === \"object\" && data !== null && \"schema\" in data && data.schema === TODO_SNAPSHOT_SCHEMA) {\n\t\t\treturn data as TodoSnapshotPayload;\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function findTodoEntries(ctx: ExtensionContext): SessionEntry[];\nexport function findTodoEntries(entries: SessionEntry[], options?: { branchId?: string }): TodoEntry[];\nexport function findTodoEntries(\n\tctxOrEntries: ExtensionContext | SessionEntry[],\n\toptions?: { branchId?: string },\n): SessionEntry[] | TodoEntry[] {\n\tif (Array.isArray(ctxOrEntries)) {\n\t\treturn ctxOrEntries\n\t\t\t.filter(isLegacyTodoListEntry)\n\t\t\t.filter((entry) => options?.branchId === undefined || entry.parentId === options.branchId)\n\t\t\t.flatMap(readTodosFromEntry);\n\t}\n\n\treturn ctxOrEntries.sessionManager.getEntries().filter(isCustomTodoEntry);\n}\n\nexport function createTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload {\n\treturn {\n\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\ttodos: findTodoEntries(ctx),\n\t\tcapturedAt: Date.now(),\n\t};\n}\n\nexport function persistTodoSnapshot(pi: AppendEntryTarget, snapshot: TodoSnapshotPayload): void {\n\tpi.appendEntry(TODO_SNAPSHOT_CUSTOM_TYPE, snapshot);\n}\n\nexport function captureTodoSnapshot(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function captureTodoSnapshot(currentTodos: TodoEntry[], pi: AppendEntryTarget, branchId?: string): void;\nexport function captureTodoSnapshot(\n\tpiOrTodos: ExtensionAPI | TodoEntry[],\n\tctxOrPi: ExtensionContext | AppendEntryTarget,\n\t_branchId?: string,\n): void {\n\tif (Array.isArray(piOrTodos)) {\n\t\tconst pi = ctxOrPi as AppendEntryTarget;\n\t\tpersistTodoSnapshot(pi, {\n\t\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\t\ttodos: piOrTodos,\n\t\t\tcapturedAt: Date.now(),\n\t\t});\n\t\treturn;\n\t}\n\n\tpersistTodoSnapshot(piOrTodos, createTodoSnapshot(ctxOrPi as ExtensionContext));\n}\n\nexport function restoreTodosIfMissing(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function restoreTodosIfMissing(\n\tsnapshot: TodoEntry[],\n\tcurrentTodos: TodoEntry[],\n\tpi: AppendEntryTarget,\n): RestoreResult;\nexport function restoreTodosIfMissing(\n\tpiOrSnapshot: ExtensionAPI | TodoEntry[],\n\tctxOrCurrentTodos: ExtensionContext | TodoEntry[],\n\t_pi?: AppendEntryTarget,\n): undefined | RestoreResult {\n\tif (Array.isArray(piOrSnapshot) && Array.isArray(ctxOrCurrentTodos)) {\n\t\tif (ctxOrCurrentTodos.length > 0) {\n\t\t\treturn { applied: false, restoredTodos: ctxOrCurrentTodos };\n\t\t}\n\t\treturn { applied: piOrSnapshot.length > 0, restoredTodos: piOrSnapshot };\n\t}\n\n\tconst pi = piOrSnapshot as SendMessageTarget;\n\tconst ctx = ctxOrCurrentTodos as ExtensionContext;\n\tif (findTodoEntries(ctx).length > 0) return;\n\n\tconst snapshot = findLatestTodoSnapshot(ctx);\n\tif (!snapshot || snapshot.todos.length === 0) return;\n\n\tpi.sendMessage(\n\t\t{\n\t\t\tcustomType: \"compaction.todo-restore-request\",\n\t\t\tcontent: `Restore missing todowrite todos from snapshot: ${JSON.stringify(snapshot.todos)}`,\n\t\t\tdisplay: false,\n\t\t\tdetails: snapshot,\n\t\t},\n\t\t{ triggerTurn: true, deliverAs: \"nextTurn\" },\n\t);\n}\n"]}
1
+ {"version":3,"file":"todo-bridge.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/todo-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,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IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO;IAE5C,MAAM,QAAQ,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAErD,EAAE,CAAC,WAAW,CACb;QACC,UAAU,EAAE,iCAAiC;QAC7C,OAAO,EAAE,kDAAkD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3F,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,QAAQ;KACjB,EACD,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAC5C,CAAC;AAAA,CACF","sourcesContent":["import type { CustomEntry, SessionEntry } from \"../../../session-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\n\nconst TODO_SNAPSHOT_CUSTOM_TYPE = \"compaction.todo-snapshot\";\nconst TODO_SNAPSHOT_SCHEMA = \"senpi.compaction.todo-snapshot.v1\";\n\nexport interface TodoEntry {\n\tid: string;\n\tcontent?: string;\n\ttext?: string;\n\tstatus?: \"pending\" | \"in_progress\" | \"completed\" | \"cancelled\";\n}\n\nexport interface TodoSnapshotPayload {\n\tschema: typeof TODO_SNAPSHOT_SCHEMA;\n\ttodos: TodoEntry[] | SessionEntry[];\n\tcapturedAt: number;\n}\n\ninterface AppendEntryTarget {\n\tappendEntry<T = unknown>(customType: string, data?: T): void;\n}\n\ninterface SendMessageTarget extends AppendEntryTarget {\n\tsendMessage<T = unknown>(\n\t\tmessage: { customType: string; content: string; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): void;\n}\n\ninterface RestoreResult {\n\tapplied: boolean;\n\trestoredTodos: TodoEntry[];\n}\n\nfunction isCustomTodoEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType.startsWith(\"todowrite\");\n}\n\nfunction isLegacyTodoListEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType === \"todo-list\";\n}\n\nfunction readTodosFromEntry(entry: CustomEntry): TodoEntry[] {\n\tconst data = entry.data;\n\tif (typeof data !== \"object\" || data === null || !(\"todos\" in data) || !Array.isArray(data.todos)) {\n\t\treturn [];\n\t}\n\treturn data.todos.filter((todo): todo is TodoEntry => {\n\t\treturn typeof todo === \"object\" && todo !== null && \"id\" in todo && typeof todo.id === \"string\";\n\t});\n}\n\nfunction findLatestTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload | null {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== TODO_SNAPSHOT_CUSTOM_TYPE) continue;\n\t\tconst data = entry.data;\n\t\tif (typeof data === \"object\" && data !== null && \"schema\" in data && data.schema === TODO_SNAPSHOT_SCHEMA) {\n\t\t\treturn data as TodoSnapshotPayload;\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function findTodoEntries(ctx: ExtensionContext): SessionEntry[];\nexport function findTodoEntries(entries: SessionEntry[], options?: { branchId?: string }): TodoEntry[];\nexport function findTodoEntries(\n\tctxOrEntries: ExtensionContext | SessionEntry[],\n\toptions?: { branchId?: string },\n): SessionEntry[] | TodoEntry[] {\n\tif (Array.isArray(ctxOrEntries)) {\n\t\treturn ctxOrEntries\n\t\t\t.filter(isLegacyTodoListEntry)\n\t\t\t.filter((entry) => options?.branchId === undefined || entry.parentId === options.branchId)\n\t\t\t.flatMap(readTodosFromEntry);\n\t}\n\n\treturn ctxOrEntries.sessionManager.getEntries().filter(isCustomTodoEntry);\n}\n\nexport function createTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload {\n\treturn {\n\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\ttodos: findTodoEntries(ctx),\n\t\tcapturedAt: Date.now(),\n\t};\n}\n\nexport function persistTodoSnapshot(pi: AppendEntryTarget, snapshot: TodoSnapshotPayload): void {\n\tpi.appendEntry(TODO_SNAPSHOT_CUSTOM_TYPE, snapshot);\n}\n\nexport function captureTodoSnapshot(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function captureTodoSnapshot(currentTodos: TodoEntry[], pi: AppendEntryTarget, branchId?: string): void;\nexport function captureTodoSnapshot(\n\tpiOrTodos: ExtensionAPI | TodoEntry[],\n\tctxOrPi: ExtensionContext | AppendEntryTarget,\n\t_branchId?: string,\n): void {\n\tif (Array.isArray(piOrTodos)) {\n\t\tconst pi = ctxOrPi as AppendEntryTarget;\n\t\tpersistTodoSnapshot(pi, {\n\t\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\t\ttodos: piOrTodos,\n\t\t\tcapturedAt: Date.now(),\n\t\t});\n\t\treturn;\n\t}\n\n\tpersistTodoSnapshot(piOrTodos, createTodoSnapshot(ctxOrPi as ExtensionContext));\n}\n\nexport function restoreTodosIfMissing(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function restoreTodosIfMissing(\n\tsnapshot: TodoEntry[],\n\tcurrentTodos: TodoEntry[],\n\tpi: AppendEntryTarget,\n): RestoreResult;\nexport function restoreTodosIfMissing(\n\tpiOrSnapshot: ExtensionAPI | TodoEntry[],\n\tctxOrCurrentTodos: ExtensionContext | TodoEntry[],\n\t_pi?: AppendEntryTarget,\n): undefined | RestoreResult {\n\tif (Array.isArray(piOrSnapshot) && Array.isArray(ctxOrCurrentTodos)) {\n\t\tif (ctxOrCurrentTodos.length > 0) {\n\t\t\treturn { applied: false, restoredTodos: ctxOrCurrentTodos };\n\t\t}\n\t\treturn { applied: piOrSnapshot.length > 0, restoredTodos: piOrSnapshot };\n\t}\n\n\tconst pi = piOrSnapshot as SendMessageTarget;\n\tconst ctx = ctxOrCurrentTodos as ExtensionContext;\n\tif (findTodoEntries(ctx).length > 0) return;\n\n\tconst snapshot = findLatestTodoSnapshot(ctx);\n\tif (!snapshot || snapshot.todos.length === 0) return;\n\n\tpi.sendMessage(\n\t\t{\n\t\t\tcustomType: \"compaction.todo-restore-request\",\n\t\t\tcontent: `Restore missing todowrite todos from snapshot: ${JSON.stringify(snapshot.todos)}`,\n\t\t\tdisplay: false,\n\t\t\tdetails: snapshot,\n\t\t},\n\t\t{ triggerTurn: true, deliverAs: \"nextTurn\" },\n\t);\n}\n"]}
1
+ {"version":3,"file":"todo-bridge.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/todo-bridge.ts"],"names":[],"mappings":"AAGA,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AA+BjE,SAAS,iBAAiB,CAAC,KAAmB;IAC7C,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAmB;IACjD,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,KAAK,WAAW,CAAC;AACpE,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAkB;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACnG,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAqB,EAAE;QACpD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,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QAAQ,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAErD,EAAE,CAAC,WAAW,CACb;QACC,UAAU,EAAE,iCAAiC;QAC7C,OAAO,EAAE,kDAAkD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3F,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,QAAQ;KACjB,EACD,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAC5C,CAAC;AACH,CAAC","sourcesContent":["import type { CustomEntry, SessionEntry } from \"../../../session-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\n\nconst TODO_SNAPSHOT_CUSTOM_TYPE = \"compaction.todo-snapshot\";\nconst TODO_SNAPSHOT_SCHEMA = \"senpi.compaction.todo-snapshot.v1\";\n\nexport interface TodoEntry {\n\tid: string;\n\tcontent?: string;\n\ttext?: string;\n\tstatus?: \"pending\" | \"in_progress\" | \"completed\" | \"cancelled\";\n}\n\nexport interface TodoSnapshotPayload {\n\tschema: typeof TODO_SNAPSHOT_SCHEMA;\n\ttodos: TodoEntry[] | SessionEntry[];\n\tcapturedAt: number;\n}\n\ninterface AppendEntryTarget {\n\tappendEntry<T = unknown>(customType: string, data?: T): void;\n}\n\ninterface SendMessageTarget extends AppendEntryTarget {\n\tsendMessage<T = unknown>(\n\t\tmessage: { customType: string; content: string; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): void;\n}\n\ninterface RestoreResult {\n\tapplied: boolean;\n\trestoredTodos: TodoEntry[];\n}\n\nfunction isCustomTodoEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType.startsWith(\"todowrite\");\n}\n\nfunction isLegacyTodoListEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType === \"todo-list\";\n}\n\nfunction readTodosFromEntry(entry: CustomEntry): TodoEntry[] {\n\tconst data = entry.data;\n\tif (typeof data !== \"object\" || data === null || !(\"todos\" in data) || !Array.isArray(data.todos)) {\n\t\treturn [];\n\t}\n\treturn data.todos.filter((todo): todo is TodoEntry => {\n\t\treturn typeof todo === \"object\" && todo !== null && \"id\" in todo && typeof todo.id === \"string\";\n\t});\n}\n\nfunction findLatestTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload | null {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== TODO_SNAPSHOT_CUSTOM_TYPE) continue;\n\t\tconst data = entry.data;\n\t\tif (typeof data === \"object\" && data !== null && \"schema\" in data && data.schema === TODO_SNAPSHOT_SCHEMA) {\n\t\t\treturn data as TodoSnapshotPayload;\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function findTodoEntries(ctx: ExtensionContext): SessionEntry[];\nexport function findTodoEntries(entries: SessionEntry[], options?: { branchId?: string }): TodoEntry[];\nexport function findTodoEntries(\n\tctxOrEntries: ExtensionContext | SessionEntry[],\n\toptions?: { branchId?: string },\n): SessionEntry[] | TodoEntry[] {\n\tif (Array.isArray(ctxOrEntries)) {\n\t\treturn ctxOrEntries\n\t\t\t.filter(isLegacyTodoListEntry)\n\t\t\t.filter((entry) => options?.branchId === undefined || entry.parentId === options.branchId)\n\t\t\t.flatMap(readTodosFromEntry);\n\t}\n\n\treturn ctxOrEntries.sessionManager.getEntries().filter(isCustomTodoEntry);\n}\n\nexport function createTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload {\n\treturn {\n\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\ttodos: findTodoEntries(ctx),\n\t\tcapturedAt: Date.now(),\n\t};\n}\n\nexport function persistTodoSnapshot(pi: AppendEntryTarget, snapshot: TodoSnapshotPayload): void {\n\tpi.appendEntry(TODO_SNAPSHOT_CUSTOM_TYPE, snapshot);\n}\n\nexport function captureTodoSnapshot(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function captureTodoSnapshot(currentTodos: TodoEntry[], pi: AppendEntryTarget, branchId?: string): void;\nexport function captureTodoSnapshot(\n\tpiOrTodos: ExtensionAPI | TodoEntry[],\n\tctxOrPi: ExtensionContext | AppendEntryTarget,\n\t_branchId?: string,\n): void {\n\tif (Array.isArray(piOrTodos)) {\n\t\tconst pi = ctxOrPi as AppendEntryTarget;\n\t\tpersistTodoSnapshot(pi, {\n\t\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\t\ttodos: piOrTodos,\n\t\t\tcapturedAt: Date.now(),\n\t\t});\n\t\treturn;\n\t}\n\n\tpersistTodoSnapshot(piOrTodos, createTodoSnapshot(ctxOrPi as ExtensionContext));\n}\n\nexport function restoreTodosIfMissing(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function restoreTodosIfMissing(\n\tsnapshot: TodoEntry[],\n\tcurrentTodos: TodoEntry[],\n\tpi: AppendEntryTarget,\n): RestoreResult;\nexport function restoreTodosIfMissing(\n\tpiOrSnapshot: ExtensionAPI | TodoEntry[],\n\tctxOrCurrentTodos: ExtensionContext | TodoEntry[],\n\t_pi?: AppendEntryTarget,\n): undefined | RestoreResult {\n\tif (Array.isArray(piOrSnapshot) && Array.isArray(ctxOrCurrentTodos)) {\n\t\tif (ctxOrCurrentTodos.length > 0) {\n\t\t\treturn { applied: false, restoredTodos: ctxOrCurrentTodos };\n\t\t}\n\t\treturn { applied: piOrSnapshot.length > 0, restoredTodos: piOrSnapshot };\n\t}\n\n\tconst pi = piOrSnapshot as SendMessageTarget;\n\tconst ctx = ctxOrCurrentTodos as ExtensionContext;\n\tif (findTodoEntries(ctx).length > 0) return;\n\n\tconst snapshot = findLatestTodoSnapshot(ctx);\n\tif (!snapshot || snapshot.todos.length === 0) return;\n\n\tpi.sendMessage(\n\t\t{\n\t\t\tcustomType: \"compaction.todo-restore-request\",\n\t\t\tcontent: `Restore missing todowrite todos from snapshot: ${JSON.stringify(snapshot.todos)}`,\n\t\t\tdisplay: false,\n\t\t\tdetails: snapshot,\n\t\t},\n\t\t{ triggerTurn: true, deliverAs: \"nextTurn\" },\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-truncation.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/tool-truncation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiFrE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,GAAG,eAAe,CAAC,OAAO,CAAC,EAAE,CAE5G;AAED,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,EACnC,YAAY,EAAE,MAAM,GAClB,eAAe,CAAC,OAAO,CAAC,EAAE,CAS5B","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\n\nconst PER_RESULT_TRUNCATE_THRESHOLD_BYTES = 4096;\nconst TRUNCATION_HEAD_CHARS = 800;\nconst TRUNCATION_TAIL_CHARS = 400;\nconst TRUNCATION_MARKER_RE = /<truncated:\\d+ bytes original>/;\n\nfunction utf8Bytes(text: string): number {\n\treturn new TextEncoder().encode(text).length;\n}\n\nfunction approxTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\nfunction totalTokens(results: AgentToolResult<unknown>[]): number {\n\tlet total = 0;\n\tfor (const result of results) {\n\t\tfor (const block of result.content) {\n\t\t\tif (block.type === \"text\") {\n\t\t\t\ttotal += approxTokens(block.text);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.type === \"image\") {\n\t\t\t\ttotal += approxTokens(block.data);\n\t\t\t}\n\t\t}\n\t}\n\treturn total;\n}\n\nfunction buildMarker(originalBytes: number): string {\n\treturn `<truncated:${originalBytes} bytes original>`;\n}\n\nfunction truncateTextBlock(block: TextContent, headChars: number, tailChars: number): TextContent | null {\n\tconst text = block.text;\n\tconst bytes = utf8Bytes(text);\n\tif (bytes <= PER_RESULT_TRUNCATE_THRESHOLD_BYTES) return null;\n\tif (TRUNCATION_MARKER_RE.test(text)) return null;\n\tconst head = text.slice(0, headChars);\n\tconst tail = text.slice(text.length - tailChars);\n\tconst marker = buildMarker(bytes);\n\treturn { ...block, text: `${head}\\n${marker}\\n${tail}` };\n}\n\nfunction applyHeadTailTruncation(\n\tresult: AgentToolResult<unknown>,\n\theadChars: number,\n\ttailChars: number,\n): AgentToolResult<unknown> {\n\tlet modified = false;\n\tconst newContent: (TextContent | ImageContent)[] = result.content.map((block) => {\n\t\tif (block.type !== \"text\") return block;\n\t\tconst truncated = truncateTextBlock(block, headChars, tailChars);\n\t\tif (truncated) {\n\t\t\tmodified = true;\n\t\t\treturn truncated;\n\t\t}\n\t\treturn block;\n\t});\n\tif (!modified) return result;\n\treturn { ...result, content: newContent };\n}\n\nfunction reduceMarkedTextToMarker(result: AgentToolResult<unknown>): AgentToolResult<unknown> {\n\tlet modified = false;\n\tconst newContent: (TextContent | ImageContent)[] = result.content.map((block) => {\n\t\tif (block.type !== \"text\") return block;\n\t\tconst markerMatch = block.text.match(TRUNCATION_MARKER_RE);\n\t\tif (markerMatch && block.text !== markerMatch[0]) {\n\t\t\tmodified = true;\n\t\t\treturn { ...block, text: markerMatch[0] };\n\t\t}\n\t\treturn block;\n\t});\n\tif (!modified) return result;\n\treturn { ...result, content: newContent };\n}\n\nexport function truncateOversizedToolResults(results: AgentToolResult<unknown>[]): AgentToolResult<unknown>[] {\n\treturn results.map((result) => applyHeadTailTruncation(result, TRUNCATION_HEAD_CHARS, TRUNCATION_TAIL_CHARS));\n}\n\nexport function prePruneToolOutputsToBudget(\n\tresults: AgentToolResult<unknown>[],\n\ttargetTokens: number,\n): AgentToolResult<unknown>[] {\n\tif (totalTokens(results) <= targetTokens) {\n\t\treturn results.map((result) => ({ ...result }));\n\t}\n\n\tconst firstPass = truncateOversizedToolResults(results);\n\tif (totalTokens(firstPass) <= targetTokens) return firstPass;\n\n\treturn firstPass.map((result) => reduceMarkedTextToMarker(result));\n}\n"]}
1
+ {"version":3,"file":"tool-truncation.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/tool-truncation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiFrE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,GAAG,eAAe,CAAC,OAAO,CAAC,EAAE,CAE5G;AAED,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,EACnC,YAAY,EAAE,MAAM,GAClB,eAAe,CAAC,OAAO,CAAC,EAAE,CAS5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-truncation.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/tool-truncation.ts"],"names":[],"mappings":"AAGA,MAAM,mCAAmC,GAAG,IAAI,CAAC;AACjD,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAE9D,SAAS,SAAS,CAAC,IAAY,EAAU;IACxC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AAAA,CAC7C;AAED,SAAS,YAAY,CAAC,IAAY,EAAU;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAAA,CAClC;AAED,SAAS,WAAW,CAAC,OAAmC,EAAU;IACjE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,M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AED,MAAM,UAAU,4BAA4B,CAAC,OAAmC,EAA8B;IAC7G,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAAA,CAC9G;AAED,MAAM,UAAU,2BAA2B,CAC1C,OAAmC,EACnC,YAAoB,EACS;IAC7B,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,YAAY,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,SAAS,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,YAAY;QAAE,OAAO,SAAS,CAAC;IAE7D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;AAAA,CACnE","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\n\nconst PER_RESULT_TRUNCATE_THRESHOLD_BYTES = 4096;\nconst TRUNCATION_HEAD_CHARS = 800;\nconst TRUNCATION_TAIL_CHARS = 400;\nconst TRUNCATION_MARKER_RE = /<truncated:\\d+ bytes original>/;\n\nfunction utf8Bytes(text: string): number {\n\treturn new TextEncoder().encode(text).length;\n}\n\nfunction approxTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\nfunction totalTokens(results: AgentToolResult<unknown>[]): number {\n\tlet total = 0;\n\tfor (const result of results) {\n\t\tfor (const block of result.content) {\n\t\t\tif (block.type === \"text\") {\n\t\t\t\ttotal += approxTokens(block.text);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.type === \"image\") {\n\t\t\t\ttotal += approxTokens(block.data);\n\t\t\t}\n\t\t}\n\t}\n\treturn total;\n}\n\nfunction buildMarker(originalBytes: number): string {\n\treturn `<truncated:${originalBytes} bytes original>`;\n}\n\nfunction truncateTextBlock(block: TextContent, headChars: number, tailChars: number): TextContent | null {\n\tconst text = block.text;\n\tconst bytes = utf8Bytes(text);\n\tif (bytes <= PER_RESULT_TRUNCATE_THRESHOLD_BYTES) return null;\n\tif (TRUNCATION_MARKER_RE.test(text)) return null;\n\tconst head = text.slice(0, headChars);\n\tconst tail = text.slice(text.length - tailChars);\n\tconst marker = buildMarker(bytes);\n\treturn { ...block, text: `${head}\\n${marker}\\n${tail}` };\n}\n\nfunction applyHeadTailTruncation(\n\tresult: AgentToolResult<unknown>,\n\theadChars: number,\n\ttailChars: number,\n): AgentToolResult<unknown> {\n\tlet modified = false;\n\tconst newContent: (TextContent | ImageContent)[] = result.content.map((block) => {\n\t\tif (block.type !== \"text\") return block;\n\t\tconst truncated = truncateTextBlock(block, headChars, tailChars);\n\t\tif (truncated) {\n\t\t\tmodified = true;\n\t\t\treturn truncated;\n\t\t}\n\t\treturn block;\n\t});\n\tif (!modified) return result;\n\treturn { ...result, content: newContent };\n}\n\nfunction reduceMarkedTextToMarker(result: AgentToolResult<unknown>): AgentToolResult<unknown> {\n\tlet modified = false;\n\tconst newContent: (TextContent | ImageContent)[] = result.content.map((block) => {\n\t\tif (block.type !== \"text\") return block;\n\t\tconst markerMatch = block.text.match(TRUNCATION_MARKER_RE);\n\t\tif (markerMatch && block.text !== markerMatch[0]) {\n\t\t\tmodified = true;\n\t\t\treturn { ...block, text: markerMatch[0] };\n\t\t}\n\t\treturn block;\n\t});\n\tif (!modified) return result;\n\treturn { ...result, content: newContent };\n}\n\nexport function truncateOversizedToolResults(results: AgentToolResult<unknown>[]): AgentToolResult<unknown>[] {\n\treturn results.map((result) => applyHeadTailTruncation(result, TRUNCATION_HEAD_CHARS, TRUNCATION_TAIL_CHARS));\n}\n\nexport function prePruneToolOutputsToBudget(\n\tresults: AgentToolResult<unknown>[],\n\ttargetTokens: number,\n): AgentToolResult<unknown>[] {\n\tif (totalTokens(results) <= targetTokens) {\n\t\treturn results.map((result) => ({ ...result }));\n\t}\n\n\tconst firstPass = truncateOversizedToolResults(results);\n\tif (totalTokens(firstPass) <= targetTokens) return firstPass;\n\n\treturn firstPass.map((result) => reduceMarkedTextToMarker(result));\n}\n"]}
1
+ {"version":3,"file":"tool-truncation.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/tool-truncation.ts"],"names":[],"mappings":"AAGA,MAAM,mCAAmC,GAAG,IAAI,CAAC;AACjD,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAE9D,SAAS,SAAS,CAAC,IAAY;IAC9B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,WAAW,CAAC,OAAmC;IACvD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC3B,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAClC,SAAS;YACV,CAAC;YACD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBAC5B,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CA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AS,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,YAAY;QAAE,OAAO,SAAS,CAAC;IAE7D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\n\nconst PER_RESULT_TRUNCATE_THRESHOLD_BYTES = 4096;\nconst TRUNCATION_HEAD_CHARS = 800;\nconst TRUNCATION_TAIL_CHARS = 400;\nconst TRUNCATION_MARKER_RE = /<truncated:\\d+ bytes original>/;\n\nfunction utf8Bytes(text: string): number {\n\treturn new TextEncoder().encode(text).length;\n}\n\nfunction approxTokens(text: string): number {\n\treturn Math.ceil(text.length / 4);\n}\n\nfunction totalTokens(results: AgentToolResult<unknown>[]): number {\n\tlet total = 0;\n\tfor (const result of results) {\n\t\tfor (const block of result.content) {\n\t\t\tif (block.type === \"text\") {\n\t\t\t\ttotal += approxTokens(block.text);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.type === \"image\") {\n\t\t\t\ttotal += approxTokens(block.data);\n\t\t\t}\n\t\t}\n\t}\n\treturn total;\n}\n\nfunction buildMarker(originalBytes: number): string {\n\treturn `<truncated:${originalBytes} bytes original>`;\n}\n\nfunction truncateTextBlock(block: TextContent, headChars: number, tailChars: number): TextContent | null {\n\tconst text = block.text;\n\tconst bytes = utf8Bytes(text);\n\tif (bytes <= PER_RESULT_TRUNCATE_THRESHOLD_BYTES) return null;\n\tif (TRUNCATION_MARKER_RE.test(text)) return null;\n\tconst head = text.slice(0, headChars);\n\tconst tail = text.slice(text.length - tailChars);\n\tconst marker = buildMarker(bytes);\n\treturn { ...block, text: `${head}\\n${marker}\\n${tail}` };\n}\n\nfunction applyHeadTailTruncation(\n\tresult: AgentToolResult<unknown>,\n\theadChars: number,\n\ttailChars: number,\n): AgentToolResult<unknown> {\n\tlet modified = false;\n\tconst newContent: (TextContent | ImageContent)[] = result.content.map((block) => {\n\t\tif (block.type !== \"text\") return block;\n\t\tconst truncated = truncateTextBlock(block, headChars, tailChars);\n\t\tif (truncated) {\n\t\t\tmodified = true;\n\t\t\treturn truncated;\n\t\t}\n\t\treturn block;\n\t});\n\tif (!modified) return result;\n\treturn { ...result, content: newContent };\n}\n\nfunction reduceMarkedTextToMarker(result: AgentToolResult<unknown>): AgentToolResult<unknown> {\n\tlet modified = false;\n\tconst newContent: (TextContent | ImageContent)[] = result.content.map((block) => {\n\t\tif (block.type !== \"text\") return block;\n\t\tconst markerMatch = block.text.match(TRUNCATION_MARKER_RE);\n\t\tif (markerMatch && block.text !== markerMatch[0]) {\n\t\t\tmodified = true;\n\t\t\treturn { ...block, text: markerMatch[0] };\n\t\t}\n\t\treturn block;\n\t});\n\tif (!modified) return result;\n\treturn { ...result, content: newContent };\n}\n\nexport function truncateOversizedToolResults(results: AgentToolResult<unknown>[]): AgentToolResult<unknown>[] {\n\treturn results.map((result) => applyHeadTailTruncation(result, TRUNCATION_HEAD_CHARS, TRUNCATION_TAIL_CHARS));\n}\n\nexport function prePruneToolOutputsToBudget(\n\tresults: AgentToolResult<unknown>[],\n\ttargetTokens: number,\n): AgentToolResult<unknown>[] {\n\tif (totalTokens(results) <= targetTokens) {\n\t\treturn results.map((result) => ({ ...result }));\n\t}\n\n\tconst firstPass = truncateOversizedToolResults(results);\n\tif (totalTokens(firstPass) <= targetTokens) return firstPass;\n\n\treturn firstPass.map((result) => reduceMarkedTextToMarker(result));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/diff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQhD,MAAM,CAAC,OAAO,WAAW,EAAE,EAAE,YAAY,QA0MxC","sourcesContent":["/**\n * Diff Extension\n *\n * /diff command shows modified/deleted/new files from git status and opens\n * the selected file in VS Code's diff view.\n */\n\nimport { Container, Key, matchesKey, type SelectItem, SelectList, Text } from \"@earendil-works/pi-tui\";\nimport { DynamicBorder } from \"../../../modes/interactive/components/dynamic-border.ts\";\nimport type { ExtensionAPI } from \"../types.ts\";\n\ninterface FileInfo {\n\tstatus: string;\n\tstatusLabel: string;\n\tfile: string;\n}\n\nexport default function (pi: ExtensionAPI) {\n\tpi.registerCommand(\"diff\", {\n\t\tdescription: \"Show git changes and open in VS Code diff view\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"No UI available\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get changed files from git status\n\t\t\tconst result = await pi.exec(\"git\", [\"status\", \"--porcelain\"], { cwd: ctx.cwd });\n\n\t\t\tif (result.code !== 0) {\n\t\t\t\tctx.ui.notify(`git status failed: ${result.stderr}`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!result.stdout?.trim()) {\n\t\t\t\tctx.ui.notify(\"No changes in working tree\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Parse git status output\n\t\t\t// Format: XY filename (where XY is two-letter status, then space, then filename)\n\t\t\tconst lines = result.stdout.split(\"\\n\");\n\t\t\tconst files: FileInfo[] = [];\n\n\t\t\tfor (const line of lines) {\n\t\t\t\tif (line.length < 4) continue; // Need at least \"XY f\"\n\n\t\t\t\tconst status = line.slice(0, 2);\n\t\t\t\tconst file = line.slice(2).trimStart();\n\n\t\t\t\t// Translate status codes to short labels\n\t\t\t\tlet statusLabel: string;\n\t\t\t\tif (status.includes(\"M\")) statusLabel = \"M\";\n\t\t\t\telse if (status.includes(\"A\")) statusLabel = \"A\";\n\t\t\t\telse if (status.includes(\"D\")) statusLabel = \"D\";\n\t\t\t\telse if (status.includes(\"?\")) statusLabel = \"?\";\n\t\t\t\telse if (status.includes(\"R\")) statusLabel = \"R\";\n\t\t\t\telse if (status.includes(\"C\")) statusLabel = \"C\";\n\t\t\t\telse statusLabel = status.trim() || \"~\";\n\n\t\t\t\tfiles.push({ status: statusLabel, statusLabel, file });\n\t\t\t}\n\n\t\t\tif (files.length === 0) {\n\t\t\t\tctx.ui.notify(\"No changes found\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\\r\\n]/;\n\t\t\tconst quoteCmdArg = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n\n\t\t\tconst openWithCode = async (file: string) => {\n\t\t\t\tif (process.platform === \"win32\") {\n\t\t\t\t\tif (WINDOWS_UNSAFE_CMD_CHARS_RE.test(file)) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Refusing to open ${file}: path contains Windows cmd metacharacters (& | < > ^ % or newline).`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst commandLine = `code -g ${quoteCmdArg(file)}`;\n\t\t\t\t\treturn pi.exec(\"cmd\", [\"/d\", \"/s\", \"/c\", commandLine], { cwd: ctx.cwd });\n\t\t\t\t}\n\t\t\t\treturn pi.exec(\"code\", [\"-g\", file], { cwd: ctx.cwd });\n\t\t\t};\n\n\t\t\tconst openSelected = async (fileInfo: FileInfo): Promise<void> => {\n\t\t\t\ttry {\n\t\t\t\t\t// Open in VS Code diff view.\n\t\t\t\t\t// For untracked files, git difftool won't work, so fall back to just opening the file.\n\t\t\t\t\tif (fileInfo.status === \"?\") {\n\t\t\t\t\t\tconst openResult = await openWithCode(fileInfo.file);\n\t\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Failed to open ${fileInfo.file} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst diffResult = await pi.exec(\"git\", [\"difftool\", \"-y\", \"--tool=vscode\", fileInfo.file], {\n\t\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\t});\n\t\t\t\t\tif (diffResult.code !== 0) {\n\t\t\t\t\t\tconst diffStderr = diffResult.stderr.trim();\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to show diff with vscode for ${fileInfo.file} (exit ${diffResult.code})${diffStderr ? `: ${diffStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\"Troubleshooting: check git difftool config (e.g. `git config --get difftool.vscode.cmd`).\",\n\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst openResult = await openWithCode(fileInfo.file);\n\t\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Failed to open ${fileInfo.file} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tctx.ui.notify(`Failed to open ${fileInfo.file}: ${message}`, \"error\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Show file picker with SelectList\n\t\t\tawait ctx.ui.custom<void>((tui, theme, _kb, done) => {\n\t\t\t\tconst container = new Container();\n\n\t\t\t\t// Top border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\t// Title\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"accent\", theme.bold(\" Select file to diff\")), 0, 0));\n\n\t\t\t\t// Build select items with colored status\n\t\t\t\tconst filesByValue = new Map<string, FileInfo>();\n\t\t\t\tconst items: SelectItem[] = files.map((f, i) => {\n\t\t\t\t\tconst key = String(i);\n\t\t\t\t\tfilesByValue.set(key, f);\n\t\t\t\t\tlet statusColor: string;\n\t\t\t\t\tswitch (f.status) {\n\t\t\t\t\t\tcase \"M\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"warning\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"A\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"success\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"D\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"error\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"?\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"muted\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"dim\", f.status);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tlabel: `${statusColor} ${f.file}`,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst visibleRows = Math.min(files.length, 15);\n\t\t\t\tlet currentIndex = 0;\n\n\t\t\t\tconst selectList = new SelectList(items, visibleRows, {\n\t\t\t\t\tselectedPrefix: (t) => theme.fg(\"accent\", t),\n\t\t\t\t\tselectedText: (t) => t, // Keep existing colors\n\t\t\t\t\tdescription: (t) => theme.fg(\"muted\", t),\n\t\t\t\t\tscrollInfo: (t) => theme.fg(\"dim\", t),\n\t\t\t\t\tnoMatch: (t) => theme.fg(\"warning\", t),\n\t\t\t\t});\n\t\t\t\tselectList.onSelect = (item) => {\n\t\t\t\t\tconst fileInfo = filesByValue.get(item.value);\n\t\t\t\t\tif (fileInfo) void openSelected(fileInfo);\n\t\t\t\t};\n\t\t\t\tselectList.onCancel = () => done();\n\t\t\t\tselectList.onSelectionChange = (item) => {\n\t\t\t\t\tcurrentIndex = items.indexOf(item);\n\t\t\t\t};\n\t\t\t\tcontainer.addChild(selectList);\n\n\t\t\t\t// Help text\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"dim\", \" ↑↓ navigate • ←→ page • enter open • esc close\"), 0, 0));\n\n\t\t\t\t// Bottom border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\treturn {\n\t\t\t\t\trender: (w) => container.render(w),\n\t\t\t\t\tinvalidate: () => container.invalidate(),\n\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t// Add paging with left/right\n\t\t\t\t\t\tif (matchesKey(data, Key.left)) {\n\t\t\t\t\t\t\t// Page up - clamp to 0\n\t\t\t\t\t\t\tcurrentIndex = Math.max(0, currentIndex - visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else if (matchesKey(data, Key.right)) {\n\t\t\t\t\t\t\t// Page down - clamp to last\n\t\t\t\t\t\t\tcurrentIndex = Math.min(items.length - 1, currentIndex + visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectList.handleInput(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/diff.ts"],"names":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E,CAAC,SAAS,CAAC,UAAU,EAAE;oBACxC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;wBACtB,6BAA6B;wBAC7B,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;4BAChC,uBAAuB;4BACvB,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;4BACvD,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;wBAC3C,CAAC;6BAAM,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;4BACxC,4BAA4B;4BAC5B,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;4BACtE,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;wBAC3C,CAAC;6BAAM,CAAC;4BACP,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBAC9B,CAAC;wBACD,GAAG,CAAC,aAAa,EAAE,CAAC;oBAAA,CACpB;iBACD,CAAC;YAAA,CACF,CAAC,CAAC;QAAA,CACH;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Diff Extension\n *\n * /diff command shows modified/deleted/new files from git status and opens\n * the selected file in VS Code's diff view.\n */\n\nimport { Container, Key, matchesKey, type SelectItem, SelectList, Text } from \"@earendil-works/pi-tui\";\nimport { DynamicBorder } from \"../../../modes/interactive/components/dynamic-border.ts\";\nimport type { ExtensionAPI } from \"../types.ts\";\n\ninterface FileInfo {\n\tstatus: string;\n\tstatusLabel: string;\n\tfile: string;\n}\n\nexport default function (pi: ExtensionAPI) {\n\tpi.registerCommand(\"diff\", {\n\t\tdescription: \"Show git changes and open in VS Code diff view\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"No UI available\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get changed files from git status\n\t\t\tconst result = await pi.exec(\"git\", [\"status\", \"--porcelain\"], { cwd: ctx.cwd });\n\n\t\t\tif (result.code !== 0) {\n\t\t\t\tctx.ui.notify(`git status failed: ${result.stderr}`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!result.stdout?.trim()) {\n\t\t\t\tctx.ui.notify(\"No changes in working tree\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Parse git status output\n\t\t\t// Format: XY filename (where XY is two-letter status, then space, then filename)\n\t\t\tconst lines = result.stdout.split(\"\\n\");\n\t\t\tconst files: FileInfo[] = [];\n\n\t\t\tfor (const line of lines) {\n\t\t\t\tif (line.length < 4) continue; // Need at least \"XY f\"\n\n\t\t\t\tconst status = line.slice(0, 2);\n\t\t\t\tconst file = line.slice(2).trimStart();\n\n\t\t\t\t// Translate status codes to short labels\n\t\t\t\tlet statusLabel: string;\n\t\t\t\tif (status.includes(\"M\")) statusLabel = \"M\";\n\t\t\t\telse if (status.includes(\"A\")) statusLabel = \"A\";\n\t\t\t\telse if (status.includes(\"D\")) statusLabel = \"D\";\n\t\t\t\telse if (status.includes(\"?\")) statusLabel = \"?\";\n\t\t\t\telse if (status.includes(\"R\")) statusLabel = \"R\";\n\t\t\t\telse if (status.includes(\"C\")) statusLabel = \"C\";\n\t\t\t\telse statusLabel = status.trim() || \"~\";\n\n\t\t\t\tfiles.push({ status: statusLabel, statusLabel, file });\n\t\t\t}\n\n\t\t\tif (files.length === 0) {\n\t\t\t\tctx.ui.notify(\"No changes found\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\\r\\n]/;\n\t\t\tconst quoteCmdArg = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n\n\t\t\tconst openWithCode = async (file: string) => {\n\t\t\t\tif (process.platform === \"win32\") {\n\t\t\t\t\tif (WINDOWS_UNSAFE_CMD_CHARS_RE.test(file)) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Refusing to open ${file}: path contains Windows cmd metacharacters (& | < > ^ % or newline).`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst commandLine = `code -g ${quoteCmdArg(file)}`;\n\t\t\t\t\treturn pi.exec(\"cmd\", [\"/d\", \"/s\", \"/c\", commandLine], { cwd: ctx.cwd });\n\t\t\t\t}\n\t\t\t\treturn pi.exec(\"code\", [\"-g\", file], { cwd: ctx.cwd });\n\t\t\t};\n\n\t\t\tconst openSelected = async (fileInfo: FileInfo): Promise<void> => {\n\t\t\t\ttry {\n\t\t\t\t\t// Open in VS Code diff view.\n\t\t\t\t\t// For untracked files, git difftool won't work, so fall back to just opening the file.\n\t\t\t\t\tif (fileInfo.status === \"?\") {\n\t\t\t\t\t\tconst openResult = await openWithCode(fileInfo.file);\n\t\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Failed to open ${fileInfo.file} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst diffResult = await pi.exec(\"git\", [\"difftool\", \"-y\", \"--tool=vscode\", fileInfo.file], {\n\t\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\t});\n\t\t\t\t\tif (diffResult.code !== 0) {\n\t\t\t\t\t\tconst diffStderr = diffResult.stderr.trim();\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to show diff with vscode for ${fileInfo.file} (exit ${diffResult.code})${diffStderr ? `: ${diffStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\"Troubleshooting: check git difftool config (e.g. `git config --get difftool.vscode.cmd`).\",\n\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst openResult = await openWithCode(fileInfo.file);\n\t\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Failed to open ${fileInfo.file} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tctx.ui.notify(`Failed to open ${fileInfo.file}: ${message}`, \"error\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Show file picker with SelectList\n\t\t\tawait ctx.ui.custom<void>((tui, theme, _kb, done) => {\n\t\t\t\tconst container = new Container();\n\n\t\t\t\t// Top border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\t// Title\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"accent\", theme.bold(\" Select file to diff\")), 0, 0));\n\n\t\t\t\t// Build select items with colored status\n\t\t\t\tconst filesByValue = new Map<string, FileInfo>();\n\t\t\t\tconst items: SelectItem[] = files.map((f, i) => {\n\t\t\t\t\tconst key = String(i);\n\t\t\t\t\tfilesByValue.set(key, f);\n\t\t\t\t\tlet statusColor: string;\n\t\t\t\t\tswitch (f.status) {\n\t\t\t\t\t\tcase \"M\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"warning\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"A\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"success\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"D\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"error\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"?\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"muted\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"dim\", f.status);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tlabel: `${statusColor} ${f.file}`,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst visibleRows = Math.min(files.length, 15);\n\t\t\t\tlet currentIndex = 0;\n\n\t\t\t\tconst selectList = new SelectList(items, visibleRows, {\n\t\t\t\t\tselectedPrefix: (t) => theme.fg(\"accent\", t),\n\t\t\t\t\tselectedText: (t) => t, // Keep existing colors\n\t\t\t\t\tdescription: (t) => theme.fg(\"muted\", t),\n\t\t\t\t\tscrollInfo: (t) => theme.fg(\"dim\", t),\n\t\t\t\t\tnoMatch: (t) => theme.fg(\"warning\", t),\n\t\t\t\t});\n\t\t\t\tselectList.onSelect = (item) => {\n\t\t\t\t\tconst fileInfo = filesByValue.get(item.value);\n\t\t\t\t\tif (fileInfo) void openSelected(fileInfo);\n\t\t\t\t};\n\t\t\t\tselectList.onCancel = () => done();\n\t\t\t\tselectList.onSelectionChange = (item) => {\n\t\t\t\t\tcurrentIndex = items.indexOf(item);\n\t\t\t\t};\n\t\t\t\tcontainer.addChild(selectList);\n\n\t\t\t\t// Help text\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"dim\", \" ↑↓ navigate • ←→ page • enter open • esc close\"), 0, 0));\n\n\t\t\t\t// Bottom border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\treturn {\n\t\t\t\t\trender: (w) => container.render(w),\n\t\t\t\t\tinvalidate: () => container.invalidate(),\n\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t// Add paging with left/right\n\t\t\t\t\t\tif (matchesKey(data, Key.left)) {\n\t\t\t\t\t\t\t// Page up - clamp to 0\n\t\t\t\t\t\t\tcurrentIndex = Math.max(0, currentIndex - visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else if (matchesKey(data, Key.right)) {\n\t\t\t\t\t\t\t// Page down - clamp to last\n\t\t\t\t\t\t\tcurrentIndex = Math.min(items.length - 1, currentIndex + visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectList.handleInput(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/diff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAmB,UAAU,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AASxF,MAAM,CAAC,OAAO,WAAW,EAAgB;IACxC,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE;QAC1B,WAAW,EAAE,gDAAgD;QAC7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;gBAChB,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,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AAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Diff Extension\n *\n * /diff command shows modified/deleted/new files from git status and opens\n * the selected file in VS Code's diff view.\n */\n\nimport { Container, Key, matchesKey, type SelectItem, SelectList, Text } from \"@earendil-works/pi-tui\";\nimport { DynamicBorder } from \"../../../modes/interactive/components/dynamic-border.ts\";\nimport type { ExtensionAPI } from \"../types.ts\";\n\ninterface FileInfo {\n\tstatus: string;\n\tstatusLabel: string;\n\tfile: string;\n}\n\nexport default function (pi: ExtensionAPI) {\n\tpi.registerCommand(\"diff\", {\n\t\tdescription: \"Show git changes and open in VS Code diff view\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"No UI available\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get changed files from git status\n\t\t\tconst result = await pi.exec(\"git\", [\"status\", \"--porcelain\"], { cwd: ctx.cwd });\n\n\t\t\tif (result.code !== 0) {\n\t\t\t\tctx.ui.notify(`git status failed: ${result.stderr}`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!result.stdout?.trim()) {\n\t\t\t\tctx.ui.notify(\"No changes in working tree\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Parse git status output\n\t\t\t// Format: XY filename (where XY is two-letter status, then space, then filename)\n\t\t\tconst lines = result.stdout.split(\"\\n\");\n\t\t\tconst files: FileInfo[] = [];\n\n\t\t\tfor (const line of lines) {\n\t\t\t\tif (line.length < 4) continue; // Need at least \"XY f\"\n\n\t\t\t\tconst status = line.slice(0, 2);\n\t\t\t\tconst file = line.slice(2).trimStart();\n\n\t\t\t\t// Translate status codes to short labels\n\t\t\t\tlet statusLabel: string;\n\t\t\t\tif (status.includes(\"M\")) statusLabel = \"M\";\n\t\t\t\telse if (status.includes(\"A\")) statusLabel = \"A\";\n\t\t\t\telse if (status.includes(\"D\")) statusLabel = \"D\";\n\t\t\t\telse if (status.includes(\"?\")) statusLabel = \"?\";\n\t\t\t\telse if (status.includes(\"R\")) statusLabel = \"R\";\n\t\t\t\telse if (status.includes(\"C\")) statusLabel = \"C\";\n\t\t\t\telse statusLabel = status.trim() || \"~\";\n\n\t\t\t\tfiles.push({ status: statusLabel, statusLabel, file });\n\t\t\t}\n\n\t\t\tif (files.length === 0) {\n\t\t\t\tctx.ui.notify(\"No changes found\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\\r\\n]/;\n\t\t\tconst quoteCmdArg = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n\n\t\t\tconst openWithCode = async (file: string) => {\n\t\t\t\tif (process.platform === \"win32\") {\n\t\t\t\t\tif (WINDOWS_UNSAFE_CMD_CHARS_RE.test(file)) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Refusing to open ${file}: path contains Windows cmd metacharacters (& | < > ^ % or newline).`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst commandLine = `code -g ${quoteCmdArg(file)}`;\n\t\t\t\t\treturn pi.exec(\"cmd\", [\"/d\", \"/s\", \"/c\", commandLine], { cwd: ctx.cwd });\n\t\t\t\t}\n\t\t\t\treturn pi.exec(\"code\", [\"-g\", file], { cwd: ctx.cwd });\n\t\t\t};\n\n\t\t\tconst openSelected = async (fileInfo: FileInfo): Promise<void> => {\n\t\t\t\ttry {\n\t\t\t\t\t// Open in VS Code diff view.\n\t\t\t\t\t// For untracked files, git difftool won't work, so fall back to just opening the file.\n\t\t\t\t\tif (fileInfo.status === \"?\") {\n\t\t\t\t\t\tconst openResult = await openWithCode(fileInfo.file);\n\t\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Failed to open ${fileInfo.file} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst diffResult = await pi.exec(\"git\", [\"difftool\", \"-y\", \"--tool=vscode\", fileInfo.file], {\n\t\t\t\t\t\tcwd: ctx.cwd,\n\t\t\t\t\t});\n\t\t\t\t\tif (diffResult.code !== 0) {\n\t\t\t\t\t\tconst diffStderr = diffResult.stderr.trim();\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to show diff with vscode for ${fileInfo.file} (exit ${diffResult.code})${diffStderr ? `: ${diffStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\"Troubleshooting: check git difftool config (e.g. `git config --get difftool.vscode.cmd`).\",\n\t\t\t\t\t\t\t\"info\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst openResult = await openWithCode(fileInfo.file);\n\t\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Failed to open ${fileInfo.file} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tctx.ui.notify(`Failed to open ${fileInfo.file}: ${message}`, \"error\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Show file picker with SelectList\n\t\t\tawait ctx.ui.custom<void>((tui, theme, _kb, done) => {\n\t\t\t\tconst container = new Container();\n\n\t\t\t\t// Top border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\t// Title\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"accent\", theme.bold(\" Select file to diff\")), 0, 0));\n\n\t\t\t\t// Build select items with colored status\n\t\t\t\tconst filesByValue = new Map<string, FileInfo>();\n\t\t\t\tconst items: SelectItem[] = files.map((f, i) => {\n\t\t\t\t\tconst key = String(i);\n\t\t\t\t\tfilesByValue.set(key, f);\n\t\t\t\t\tlet statusColor: string;\n\t\t\t\t\tswitch (f.status) {\n\t\t\t\t\t\tcase \"M\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"warning\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"A\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"success\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"D\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"error\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"?\":\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"muted\", f.status);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tstatusColor = theme.fg(\"dim\", f.status);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tlabel: `${statusColor} ${f.file}`,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst visibleRows = Math.min(files.length, 15);\n\t\t\t\tlet currentIndex = 0;\n\n\t\t\t\tconst selectList = new SelectList(items, visibleRows, {\n\t\t\t\t\tselectedPrefix: (t) => theme.fg(\"accent\", t),\n\t\t\t\t\tselectedText: (t) => t, // Keep existing colors\n\t\t\t\t\tdescription: (t) => theme.fg(\"muted\", t),\n\t\t\t\t\tscrollInfo: (t) => theme.fg(\"dim\", t),\n\t\t\t\t\tnoMatch: (t) => theme.fg(\"warning\", t),\n\t\t\t\t});\n\t\t\t\tselectList.onSelect = (item) => {\n\t\t\t\t\tconst fileInfo = filesByValue.get(item.value);\n\t\t\t\t\tif (fileInfo) void openSelected(fileInfo);\n\t\t\t\t};\n\t\t\t\tselectList.onCancel = () => done();\n\t\t\t\tselectList.onSelectionChange = (item) => {\n\t\t\t\t\tcurrentIndex = items.indexOf(item);\n\t\t\t\t};\n\t\t\t\tcontainer.addChild(selectList);\n\n\t\t\t\t// Help text\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"dim\", \" ↑↓ navigate • ←→ page • enter open • esc close\"), 0, 0));\n\n\t\t\t\t// Bottom border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\treturn {\n\t\t\t\t\trender: (w) => container.render(w),\n\t\t\t\t\tinvalidate: () => container.invalidate(),\n\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t// Add paging with left/right\n\t\t\t\t\t\tif (matchesKey(data, Key.left)) {\n\t\t\t\t\t\t\t// Page up - clamp to 0\n\t\t\t\t\t\t\tcurrentIndex = Math.max(0, currentIndex - visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else if (matchesKey(data, Key.right)) {\n\t\t\t\t\t\t\t// Page down - clamp to last\n\t\t\t\t\t\t\tcurrentIndex = Math.min(items.length - 1, currentIndex + visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectList.handleInput(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWhD,MAAM,CAAC,OAAO,WAAW,EAAE,EAAE,YAAY,QA8LxC","sourcesContent":["/**\n * Files Extension\n *\n * /files command lists all files the model has read/written/edited in the active session branch,\n * coalesced by path and sorted newest first. Selecting a file opens it in VS Code.\n */\n\nimport { Container, Key, matchesKey, type SelectItem, SelectList, Text } from \"@earendil-works/pi-tui\";\nimport { DynamicBorder } from \"../../../modes/interactive/components/dynamic-border.ts\";\nimport type { ExtensionAPI } from \"../types.ts\";\nimport { extractPatchedPaths } from \"./gpt-apply-patch/index.ts\";\n\ninterface FileEntry {\n\tpath: string;\n\toperations: Set<\"read\" | \"write\" | \"edit\">;\n\tlastTimestamp: number;\n}\n\ntype FileToolName = \"read\" | \"write\" | \"edit\";\n\nexport default function (pi: ExtensionAPI) {\n\tpi.registerCommand(\"files\", {\n\t\tdescription: \"Show files read/written/edited in this session\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"No UI available\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get the current branch (path from leaf to root)\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\n\t\t\t// First pass: collect tool calls (id -> {path, name}) from assistant messages\n\t\t\tconst toolCalls = new Map<string, { paths: string[]; name: FileToolName; timestamp: number }>();\n\n\t\t\tfor (const entry of branch) {\n\t\t\t\tif (entry.type !== \"message\") continue;\n\t\t\t\tconst msg = entry.message;\n\n\t\t\t\tif (msg.role === \"assistant\" && Array.isArray(msg.content)) {\n\t\t\t\t\tfor (const block of msg.content) {\n\t\t\t\t\t\tif (block.type === \"toolCall\") {\n\t\t\t\t\t\t\tconst name = block.name;\n\t\t\t\t\t\t\tif (name === \"read\" || name === \"write\" || name === \"edit\") {\n\t\t\t\t\t\t\t\tconst path = block.arguments?.path;\n\t\t\t\t\t\t\t\tif (path && typeof path === \"string\") {\n\t\t\t\t\t\t\t\t\ttoolCalls.set(block.id, { paths: [path], name, timestamp: msg.timestamp });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (name === \"apply_patch\") {\n\t\t\t\t\t\t\t\tconst input = block.arguments?.input;\n\t\t\t\t\t\t\t\tif (typeof input === \"string\") {\n\t\t\t\t\t\t\t\t\tconst paths = extractPatchedPaths(input);\n\t\t\t\t\t\t\t\t\tif (paths.length > 0) {\n\t\t\t\t\t\t\t\t\t\ttoolCalls.set(block.id, { paths, name: \"edit\", timestamp: msg.timestamp });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Second pass: match tool results to get the actual execution timestamp\n\t\t\tconst fileMap = new Map<string, FileEntry>();\n\n\t\t\tfor (const entry of branch) {\n\t\t\t\tif (entry.type !== \"message\") continue;\n\t\t\t\tconst msg = entry.message;\n\n\t\t\t\tif (msg.role === \"toolResult\") {\n\t\t\t\t\tconst toolCall = toolCalls.get(msg.toolCallId);\n\t\t\t\t\tif (!toolCall) continue;\n\n\t\t\t\t\tconst { paths, name } = toolCall;\n\t\t\t\t\tconst timestamp = msg.timestamp;\n\t\t\t\t\tfor (const path of paths) {\n\t\t\t\t\t\tconst existing = fileMap.get(path);\n\t\t\t\t\t\tif (existing) {\n\t\t\t\t\t\t\texisting.operations.add(name);\n\t\t\t\t\t\t\tif (timestamp > existing.lastTimestamp) {\n\t\t\t\t\t\t\t\texisting.lastTimestamp = timestamp;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfileMap.set(path, {\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\toperations: new Set([name]),\n\t\t\t\t\t\t\t\tlastTimestamp: timestamp,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fileMap.size === 0) {\n\t\t\t\tctx.ui.notify(\"No files read/written/edited in this session\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Sort by most recent first\n\t\t\tconst files = Array.from(fileMap.values()).sort((a, b) => b.lastTimestamp - a.lastTimestamp);\n\n\t\t\tconst WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\\r\\n]/;\n\t\t\tconst quoteCmdArg = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n\n\t\t\tconst openWithCode = async (path: string) => {\n\t\t\t\tif (process.platform === \"win32\") {\n\t\t\t\t\tif (WINDOWS_UNSAFE_CMD_CHARS_RE.test(path)) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Refusing to open ${path}: path contains Windows cmd metacharacters (& | < > ^ % or newline).`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst commandLine = `code -g ${quoteCmdArg(path)}`;\n\t\t\t\t\treturn pi.exec(\"cmd\", [\"/d\", \"/s\", \"/c\", commandLine], { cwd: ctx.cwd });\n\t\t\t\t}\n\t\t\t\treturn pi.exec(\"code\", [\"-g\", path], { cwd: ctx.cwd });\n\t\t\t};\n\n\t\t\tconst openSelected = async (file: FileEntry): Promise<void> => {\n\t\t\t\ttry {\n\t\t\t\t\tconst openResult = await openWithCode(file.path);\n\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to open ${file.path} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tctx.ui.notify(`Failed to open ${file.path}: ${message}`, \"error\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Show file picker with SelectList\n\t\t\tawait ctx.ui.custom<void>((tui, theme, _kb, done) => {\n\t\t\t\tconst container = new Container();\n\n\t\t\t\t// Top border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\t// Title\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"accent\", theme.bold(\" Select file to open\")), 0, 0));\n\n\t\t\t\t// Build select items with colored operations\n\t\t\t\tconst filesByValue = new Map<string, FileEntry>();\n\t\t\t\tconst items: SelectItem[] = files.map((f, i) => {\n\t\t\t\t\tconst key = String(i);\n\t\t\t\t\tfilesByValue.set(key, f);\n\t\t\t\t\tconst ops: string[] = [];\n\t\t\t\t\tif (f.operations.has(\"read\")) ops.push(theme.fg(\"muted\", \"R\"));\n\t\t\t\t\tif (f.operations.has(\"write\")) ops.push(theme.fg(\"success\", \"W\"));\n\t\t\t\t\tif (f.operations.has(\"edit\")) ops.push(theme.fg(\"warning\", \"E\"));\n\t\t\t\t\tconst opsLabel = ops.join(\"\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tlabel: `${opsLabel} ${f.path}`,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst visibleRows = Math.min(files.length, 15);\n\t\t\t\tlet currentIndex = 0;\n\n\t\t\t\tconst selectList = new SelectList(items, visibleRows, {\n\t\t\t\t\tselectedPrefix: (t) => theme.fg(\"accent\", t),\n\t\t\t\t\tselectedText: (t) => t, // Keep existing colors\n\t\t\t\t\tdescription: (t) => theme.fg(\"muted\", t),\n\t\t\t\t\tscrollInfo: (t) => theme.fg(\"dim\", t),\n\t\t\t\t\tnoMatch: (t) => theme.fg(\"warning\", t),\n\t\t\t\t});\n\t\t\t\tselectList.onSelect = (item) => {\n\t\t\t\t\tconst fileEntry = filesByValue.get(item.value);\n\t\t\t\t\tif (fileEntry) void openSelected(fileEntry);\n\t\t\t\t};\n\t\t\t\tselectList.onCancel = () => done();\n\t\t\t\tselectList.onSelectionChange = (item) => {\n\t\t\t\t\tcurrentIndex = items.indexOf(item);\n\t\t\t\t};\n\t\t\t\tcontainer.addChild(selectList);\n\n\t\t\t\t// Help text\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"dim\", \" ↑↓ navigate • ←→ page • enter open • esc close\"), 0, 0));\n\n\t\t\t\t// Bottom border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\treturn {\n\t\t\t\t\trender: (w) => container.render(w),\n\t\t\t\t\tinvalidate: () => container.invalidate(),\n\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t// Add paging with left/right\n\t\t\t\t\t\tif (matchesKey(data, Key.left)) {\n\t\t\t\t\t\t\t// Page up - clamp to 0\n\t\t\t\t\t\t\tcurrentIndex = Math.max(0, currentIndex - visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else if (matchesKey(data, Key.right)) {\n\t\t\t\t\t\t\t// Page down - clamp to last\n\t\t\t\t\t\t\tcurrentIndex = Math.min(items.length - 1, currentIndex + visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectList.handleInput(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CA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E,CAAC;4BAChC,uBAAuB;4BACvB,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;4BACvD,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;wBAC3C,CAAC;6BAAM,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;4BACxC,4BAA4B;4BAC5B,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;4BACtE,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;wBAC3C,CAAC;6BAAM,CAAC;4BACP,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBAC9B,CAAC;wBACD,GAAG,CAAC,aAAa,EAAE,CAAC;oBAAA,CACpB;iBACD,CAAC;YAAA,CACF,CAAC,CAAC;QAAA,CACH;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Files Extension\n *\n * /files command lists all files the model has read/written/edited in the active session branch,\n * coalesced by path and sorted newest first. Selecting a file opens it in VS Code.\n */\n\nimport { Container, Key, matchesKey, type SelectItem, SelectList, Text } from \"@earendil-works/pi-tui\";\nimport { DynamicBorder } from \"../../../modes/interactive/components/dynamic-border.ts\";\nimport type { ExtensionAPI } from \"../types.ts\";\nimport { extractPatchedPaths } from \"./gpt-apply-patch/index.ts\";\n\ninterface FileEntry {\n\tpath: string;\n\toperations: Set<\"read\" | \"write\" | \"edit\">;\n\tlastTimestamp: number;\n}\n\ntype FileToolName = \"read\" | \"write\" | \"edit\";\n\nexport default function (pi: ExtensionAPI) {\n\tpi.registerCommand(\"files\", {\n\t\tdescription: \"Show files read/written/edited in this session\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"No UI available\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get the current branch (path from leaf to root)\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\n\t\t\t// First pass: collect tool calls (id -> {path, name}) from assistant messages\n\t\t\tconst toolCalls = new Map<string, { paths: string[]; name: FileToolName; timestamp: number }>();\n\n\t\t\tfor (const entry of branch) {\n\t\t\t\tif (entry.type !== \"message\") continue;\n\t\t\t\tconst msg = entry.message;\n\n\t\t\t\tif (msg.role === \"assistant\" && Array.isArray(msg.content)) {\n\t\t\t\t\tfor (const block of msg.content) {\n\t\t\t\t\t\tif (block.type === \"toolCall\") {\n\t\t\t\t\t\t\tconst name = block.name;\n\t\t\t\t\t\t\tif (name === \"read\" || name === \"write\" || name === \"edit\") {\n\t\t\t\t\t\t\t\tconst path = block.arguments?.path;\n\t\t\t\t\t\t\t\tif (path && typeof path === \"string\") {\n\t\t\t\t\t\t\t\t\ttoolCalls.set(block.id, { paths: [path], name, timestamp: msg.timestamp });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (name === \"apply_patch\") {\n\t\t\t\t\t\t\t\tconst input = block.arguments?.input;\n\t\t\t\t\t\t\t\tif (typeof input === \"string\") {\n\t\t\t\t\t\t\t\t\tconst paths = extractPatchedPaths(input);\n\t\t\t\t\t\t\t\t\tif (paths.length > 0) {\n\t\t\t\t\t\t\t\t\t\ttoolCalls.set(block.id, { paths, name: \"edit\", timestamp: msg.timestamp });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Second pass: match tool results to get the actual execution timestamp\n\t\t\tconst fileMap = new Map<string, FileEntry>();\n\n\t\t\tfor (const entry of branch) {\n\t\t\t\tif (entry.type !== \"message\") continue;\n\t\t\t\tconst msg = entry.message;\n\n\t\t\t\tif (msg.role === \"toolResult\") {\n\t\t\t\t\tconst toolCall = toolCalls.get(msg.toolCallId);\n\t\t\t\t\tif (!toolCall) continue;\n\n\t\t\t\t\tconst { paths, name } = toolCall;\n\t\t\t\t\tconst timestamp = msg.timestamp;\n\t\t\t\t\tfor (const path of paths) {\n\t\t\t\t\t\tconst existing = fileMap.get(path);\n\t\t\t\t\t\tif (existing) {\n\t\t\t\t\t\t\texisting.operations.add(name);\n\t\t\t\t\t\t\tif (timestamp > existing.lastTimestamp) {\n\t\t\t\t\t\t\t\texisting.lastTimestamp = timestamp;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfileMap.set(path, {\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\toperations: new Set([name]),\n\t\t\t\t\t\t\t\tlastTimestamp: timestamp,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fileMap.size === 0) {\n\t\t\t\tctx.ui.notify(\"No files read/written/edited in this session\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Sort by most recent first\n\t\t\tconst files = Array.from(fileMap.values()).sort((a, b) => b.lastTimestamp - a.lastTimestamp);\n\n\t\t\tconst WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\\r\\n]/;\n\t\t\tconst quoteCmdArg = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n\n\t\t\tconst openWithCode = async (path: string) => {\n\t\t\t\tif (process.platform === \"win32\") {\n\t\t\t\t\tif (WINDOWS_UNSAFE_CMD_CHARS_RE.test(path)) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Refusing to open ${path}: path contains Windows cmd metacharacters (& | < > ^ % or newline).`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst commandLine = `code -g ${quoteCmdArg(path)}`;\n\t\t\t\t\treturn pi.exec(\"cmd\", [\"/d\", \"/s\", \"/c\", commandLine], { cwd: ctx.cwd });\n\t\t\t\t}\n\t\t\t\treturn pi.exec(\"code\", [\"-g\", path], { cwd: ctx.cwd });\n\t\t\t};\n\n\t\t\tconst openSelected = async (file: FileEntry): Promise<void> => {\n\t\t\t\ttry {\n\t\t\t\t\tconst openResult = await openWithCode(file.path);\n\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to open ${file.path} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tctx.ui.notify(`Failed to open ${file.path}: ${message}`, \"error\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Show file picker with SelectList\n\t\t\tawait ctx.ui.custom<void>((tui, theme, _kb, done) => {\n\t\t\t\tconst container = new Container();\n\n\t\t\t\t// Top border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\t// Title\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"accent\", theme.bold(\" Select file to open\")), 0, 0));\n\n\t\t\t\t// Build select items with colored operations\n\t\t\t\tconst filesByValue = new Map<string, FileEntry>();\n\t\t\t\tconst items: SelectItem[] = files.map((f, i) => {\n\t\t\t\t\tconst key = String(i);\n\t\t\t\t\tfilesByValue.set(key, f);\n\t\t\t\t\tconst ops: string[] = [];\n\t\t\t\t\tif (f.operations.has(\"read\")) ops.push(theme.fg(\"muted\", \"R\"));\n\t\t\t\t\tif (f.operations.has(\"write\")) ops.push(theme.fg(\"success\", \"W\"));\n\t\t\t\t\tif (f.operations.has(\"edit\")) ops.push(theme.fg(\"warning\", \"E\"));\n\t\t\t\t\tconst opsLabel = ops.join(\"\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tlabel: `${opsLabel} ${f.path}`,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst visibleRows = Math.min(files.length, 15);\n\t\t\t\tlet currentIndex = 0;\n\n\t\t\t\tconst selectList = new SelectList(items, visibleRows, {\n\t\t\t\t\tselectedPrefix: (t) => theme.fg(\"accent\", t),\n\t\t\t\t\tselectedText: (t) => t, // Keep existing colors\n\t\t\t\t\tdescription: (t) => theme.fg(\"muted\", t),\n\t\t\t\t\tscrollInfo: (t) => theme.fg(\"dim\", t),\n\t\t\t\t\tnoMatch: (t) => theme.fg(\"warning\", t),\n\t\t\t\t});\n\t\t\t\tselectList.onSelect = (item) => {\n\t\t\t\t\tconst fileEntry = filesByValue.get(item.value);\n\t\t\t\t\tif (fileEntry) void openSelected(fileEntry);\n\t\t\t\t};\n\t\t\t\tselectList.onCancel = () => done();\n\t\t\t\tselectList.onSelectionChange = (item) => {\n\t\t\t\t\tcurrentIndex = items.indexOf(item);\n\t\t\t\t};\n\t\t\t\tcontainer.addChild(selectList);\n\n\t\t\t\t// Help text\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"dim\", \" ↑↓ navigate • ←→ page • enter open • esc close\"), 0, 0));\n\n\t\t\t\t// Bottom border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\treturn {\n\t\t\t\t\trender: (w) => container.render(w),\n\t\t\t\t\tinvalidate: () => container.invalidate(),\n\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t// Add paging with left/right\n\t\t\t\t\t\tif (matchesKey(data, Key.left)) {\n\t\t\t\t\t\t\t// Page up - clamp to 0\n\t\t\t\t\t\t\tcurrentIndex = Math.max(0, currentIndex - visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else if (matchesKey(data, Key.right)) {\n\t\t\t\t\t\t\t// Page down - clamp to last\n\t\t\t\t\t\t\tcurrentIndex = Math.min(items.length - 1, currentIndex + visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectList.handleInput(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAmB,UAAU,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAUjE,MAAM,CAAC,OAAO,WAAW,EAAgB;IACxC,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE;QAC3B,WAAW,EAAE,gDAAgD;QAC7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;gBAChB,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;gBAC1C,OAAO;YACR,CAAC;YAED,kDAAkD;YAClD,MAAM,MAAM,GAAG,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;YAE9C,8EAA8E;YAC9E,MAAM,SAAS,GAAG,IAAI,GAAG,EAAsE,CAAC;YAEhG,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC5B,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;oBAAE,SAAS;gBACvC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;gBAE1B,IAA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,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE;oBACxC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE;wBACrB,6BAA6B;wBAC7B,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;4BAChC,uBAAuB;4BACvB,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;4BACvD,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;wBAC3C,CAAC;6BAAM,IAAI,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;4BACxC,4BAA4B;4BAC5B,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC,CAAC;4BACtE,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;wBAC3C,CAAC;6BAAM,CAAC;4BACP,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBAC9B,CAAC;wBACD,GAAG,CAAC,aAAa,EAAE,CAAC;oBACrB,CAAC;iBACD,CAAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Files Extension\n *\n * /files command lists all files the model has read/written/edited in the active session branch,\n * coalesced by path and sorted newest first. Selecting a file opens it in VS Code.\n */\n\nimport { Container, Key, matchesKey, type SelectItem, SelectList, Text } from \"@earendil-works/pi-tui\";\nimport { DynamicBorder } from \"../../../modes/interactive/components/dynamic-border.ts\";\nimport type { ExtensionAPI } from \"../types.ts\";\nimport { extractPatchedPaths } from \"./gpt-apply-patch/index.ts\";\n\ninterface FileEntry {\n\tpath: string;\n\toperations: Set<\"read\" | \"write\" | \"edit\">;\n\tlastTimestamp: number;\n}\n\ntype FileToolName = \"read\" | \"write\" | \"edit\";\n\nexport default function (pi: ExtensionAPI) {\n\tpi.registerCommand(\"files\", {\n\t\tdescription: \"Show files read/written/edited in this session\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"No UI available\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get the current branch (path from leaf to root)\n\t\t\tconst branch = ctx.sessionManager.getBranch();\n\n\t\t\t// First pass: collect tool calls (id -> {path, name}) from assistant messages\n\t\t\tconst toolCalls = new Map<string, { paths: string[]; name: FileToolName; timestamp: number }>();\n\n\t\t\tfor (const entry of branch) {\n\t\t\t\tif (entry.type !== \"message\") continue;\n\t\t\t\tconst msg = entry.message;\n\n\t\t\t\tif (msg.role === \"assistant\" && Array.isArray(msg.content)) {\n\t\t\t\t\tfor (const block of msg.content) {\n\t\t\t\t\t\tif (block.type === \"toolCall\") {\n\t\t\t\t\t\t\tconst name = block.name;\n\t\t\t\t\t\t\tif (name === \"read\" || name === \"write\" || name === \"edit\") {\n\t\t\t\t\t\t\t\tconst path = block.arguments?.path;\n\t\t\t\t\t\t\t\tif (path && typeof path === \"string\") {\n\t\t\t\t\t\t\t\t\ttoolCalls.set(block.id, { paths: [path], name, timestamp: msg.timestamp });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (name === \"apply_patch\") {\n\t\t\t\t\t\t\t\tconst input = block.arguments?.input;\n\t\t\t\t\t\t\t\tif (typeof input === \"string\") {\n\t\t\t\t\t\t\t\t\tconst paths = extractPatchedPaths(input);\n\t\t\t\t\t\t\t\t\tif (paths.length > 0) {\n\t\t\t\t\t\t\t\t\t\ttoolCalls.set(block.id, { paths, name: \"edit\", timestamp: msg.timestamp });\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Second pass: match tool results to get the actual execution timestamp\n\t\t\tconst fileMap = new Map<string, FileEntry>();\n\n\t\t\tfor (const entry of branch) {\n\t\t\t\tif (entry.type !== \"message\") continue;\n\t\t\t\tconst msg = entry.message;\n\n\t\t\t\tif (msg.role === \"toolResult\") {\n\t\t\t\t\tconst toolCall = toolCalls.get(msg.toolCallId);\n\t\t\t\t\tif (!toolCall) continue;\n\n\t\t\t\t\tconst { paths, name } = toolCall;\n\t\t\t\t\tconst timestamp = msg.timestamp;\n\t\t\t\t\tfor (const path of paths) {\n\t\t\t\t\t\tconst existing = fileMap.get(path);\n\t\t\t\t\t\tif (existing) {\n\t\t\t\t\t\t\texisting.operations.add(name);\n\t\t\t\t\t\t\tif (timestamp > existing.lastTimestamp) {\n\t\t\t\t\t\t\t\texisting.lastTimestamp = timestamp;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfileMap.set(path, {\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\toperations: new Set([name]),\n\t\t\t\t\t\t\t\tlastTimestamp: timestamp,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fileMap.size === 0) {\n\t\t\t\tctx.ui.notify(\"No files read/written/edited in this session\", \"info\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Sort by most recent first\n\t\t\tconst files = Array.from(fileMap.values()).sort((a, b) => b.lastTimestamp - a.lastTimestamp);\n\n\t\t\tconst WINDOWS_UNSAFE_CMD_CHARS_RE = /[&|<>^%\\r\\n]/;\n\t\t\tconst quoteCmdArg = (value: string) => `\"${value.replace(/\"/g, '\"\"')}\"`;\n\n\t\t\tconst openWithCode = async (path: string) => {\n\t\t\t\tif (process.platform === \"win32\") {\n\t\t\t\t\tif (WINDOWS_UNSAFE_CMD_CHARS_RE.test(path)) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Refusing to open ${path}: path contains Windows cmd metacharacters (& | < > ^ % or newline).`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tconst commandLine = `code -g ${quoteCmdArg(path)}`;\n\t\t\t\t\treturn pi.exec(\"cmd\", [\"/d\", \"/s\", \"/c\", commandLine], { cwd: ctx.cwd });\n\t\t\t\t}\n\t\t\t\treturn pi.exec(\"code\", [\"-g\", path], { cwd: ctx.cwd });\n\t\t\t};\n\n\t\t\tconst openSelected = async (file: FileEntry): Promise<void> => {\n\t\t\t\ttry {\n\t\t\t\t\tconst openResult = await openWithCode(file.path);\n\t\t\t\t\tif (!openResult) return;\n\t\t\t\t\tif (openResult.code !== 0) {\n\t\t\t\t\t\tconst openStderr = openResult.stderr.trim();\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Failed to open ${file.path} (exit ${openResult.code})${openStderr ? `: ${openStderr}` : \"\"}`,\n\t\t\t\t\t\t\t\"error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tctx.ui.notify(`Failed to open ${file.path}: ${message}`, \"error\");\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Show file picker with SelectList\n\t\t\tawait ctx.ui.custom<void>((tui, theme, _kb, done) => {\n\t\t\t\tconst container = new Container();\n\n\t\t\t\t// Top border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\t// Title\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"accent\", theme.bold(\" Select file to open\")), 0, 0));\n\n\t\t\t\t// Build select items with colored operations\n\t\t\t\tconst filesByValue = new Map<string, FileEntry>();\n\t\t\t\tconst items: SelectItem[] = files.map((f, i) => {\n\t\t\t\t\tconst key = String(i);\n\t\t\t\t\tfilesByValue.set(key, f);\n\t\t\t\t\tconst ops: string[] = [];\n\t\t\t\t\tif (f.operations.has(\"read\")) ops.push(theme.fg(\"muted\", \"R\"));\n\t\t\t\t\tif (f.operations.has(\"write\")) ops.push(theme.fg(\"success\", \"W\"));\n\t\t\t\t\tif (f.operations.has(\"edit\")) ops.push(theme.fg(\"warning\", \"E\"));\n\t\t\t\t\tconst opsLabel = ops.join(\"\");\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tlabel: `${opsLabel} ${f.path}`,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst visibleRows = Math.min(files.length, 15);\n\t\t\t\tlet currentIndex = 0;\n\n\t\t\t\tconst selectList = new SelectList(items, visibleRows, {\n\t\t\t\t\tselectedPrefix: (t) => theme.fg(\"accent\", t),\n\t\t\t\t\tselectedText: (t) => t, // Keep existing colors\n\t\t\t\t\tdescription: (t) => theme.fg(\"muted\", t),\n\t\t\t\t\tscrollInfo: (t) => theme.fg(\"dim\", t),\n\t\t\t\t\tnoMatch: (t) => theme.fg(\"warning\", t),\n\t\t\t\t});\n\t\t\t\tselectList.onSelect = (item) => {\n\t\t\t\t\tconst fileEntry = filesByValue.get(item.value);\n\t\t\t\t\tif (fileEntry) void openSelected(fileEntry);\n\t\t\t\t};\n\t\t\t\tselectList.onCancel = () => done();\n\t\t\t\tselectList.onSelectionChange = (item) => {\n\t\t\t\t\tcurrentIndex = items.indexOf(item);\n\t\t\t\t};\n\t\t\t\tcontainer.addChild(selectList);\n\n\t\t\t\t// Help text\n\t\t\t\tcontainer.addChild(new Text(theme.fg(\"dim\", \" ↑↓ navigate • ←→ page • enter open • esc close\"), 0, 0));\n\n\t\t\t\t// Bottom border\n\t\t\t\tcontainer.addChild(new DynamicBorder((s: string) => theme.fg(\"accent\", s)));\n\n\t\t\t\treturn {\n\t\t\t\t\trender: (w) => container.render(w),\n\t\t\t\t\tinvalidate: () => container.invalidate(),\n\t\t\t\t\thandleInput: (data) => {\n\t\t\t\t\t\t// Add paging with left/right\n\t\t\t\t\t\tif (matchesKey(data, Key.left)) {\n\t\t\t\t\t\t\t// Page up - clamp to 0\n\t\t\t\t\t\t\tcurrentIndex = Math.max(0, currentIndex - visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else if (matchesKey(data, Key.right)) {\n\t\t\t\t\t\t\t// Page down - clamp to last\n\t\t\t\t\t\t\tcurrentIndex = Math.min(items.length - 1, currentIndex + visibleRows);\n\t\t\t\t\t\t\tselectList.setSelectedIndex(currentIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectList.handleInput(data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttui.requestRender();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEX,0BAA0B,EAE1B,gBAAgB,EAChB,qBAAqB,EAErB,MAAM,YAAY,CAAC;AAoCpB,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,qBAAqB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAEf;AAiDD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgBxE;AAYD,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,0BAA0B,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAkC3B;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyBlF","sourcesContent":["import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{ summary: string; appliedFile: string; fuzz: number }> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tif (hunk.type === \"add\") {\n\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0 };\n\t}\n\n\tif (hunk.type === \"delete\") {\n\t\tawait stat(absolutePath);\n\t\tawait rm(absolutePath);\n\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0 };\n\t}\n\n\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\tconst chunkResult =\n\t\thunk.chunks.length === 0\n\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\tif (hunk.movePath) {\n\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\treturn {\n\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\tappliedFile: hunk.movePath,\n\t\t\tfuzz: chunkResult.fuzz,\n\t\t};\n\t}\n\n\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz };\n}\n\nfunction createRecoveryInstructions(\n\tresult: Pick<ApplyPatchResult, \"appliedFiles\" | \"failures\">,\n): ApplyPatchRecoveryInstructions {\n\tconst mustReadFiles = [...new Set(result.failures.map((failure) => failure.filePath))];\n\tconst mustNotReadFiles = [...new Set(result.appliedFiles.filter((filePath) => !mustReadFiles.includes(filePath)))];\n\treturn { mustReadFiles, mustNotReadFiles };\n}\n\nexport function buildPartialFailureText(result: ApplyPatchResult): string {\n\tconst failed = result.recoveryInstructions.mustReadFiles.join(\", \");\n\tconst mustReadText = failed.includes(\",\") ? failed.split(\", \").join(\" and \") : failed;\n\treturn [\n\t\t\"apply_patch partially failed.\",\n\t\t`Failed: ${failed}`,\n\t\t`Recovery: MUST read ${mustReadText} before retrying.`,\n\t\tresult.appliedFiles.length > 0\n\t\t\t? \"Earlier file actions in this patch were already applied.\"\n\t\t\t: \"No file actions were applied.\",\n\t\tresult.recoveryInstructions.mustNotReadFiles.length > 0\n\t\t\t? \"Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it.\"\n\t\t\t: \"\",\n\t]\n\t\t.filter((line) => line.length > 0)\n\t\t.join(\"\\n\");\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const hunk of hunks) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tfailures.push({ filePath: hunk.filePath, operation: hunk.type, message });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [] },\n\t\tdetails: { fuzz },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tfor (const hunk of hunks) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [{ filePath: hunk.filePath, operation: hunk.type, message }];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0 },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, result);\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEX,0BAA0B,EAE1B,gBAAgB,EAChB,qBAAqB,EAErB,MAAM,YAAY,CAAC;AAoCpB,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,qBAAqB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAEf;AAiDD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgBxE;AAYD,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,0BAA0B,G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CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,QAAQ,GAAwB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YACnG,MAAM,MAAM,GAAqB;gBAChC,SAAS;gBACT,YAAY;gBACZ,QAAQ;gBACR,iBAAiB,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC;gBAC1C,oBAAoB,EAAE,0BAA0B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;gBAC5E,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACpB,CAAC;YACF,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAAA,CACjB","sourcesContent":["import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{ summary: string; appliedFile: string; fuzz: number }> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tif (hunk.type === \"add\") {\n\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0 };\n\t}\n\n\tif (hunk.type === \"delete\") {\n\t\tawait stat(absolutePath);\n\t\tawait rm(absolutePath);\n\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0 };\n\t}\n\n\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\tconst chunkResult =\n\t\thunk.chunks.length === 0\n\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\tif (hunk.movePath) {\n\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\treturn {\n\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\tappliedFile: hunk.movePath,\n\t\t\tfuzz: chunkResult.fuzz,\n\t\t};\n\t}\n\n\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz };\n}\n\nfunction createRecoveryInstructions(\n\tresult: Pick<ApplyPatchResult, \"appliedFiles\" | \"failures\">,\n): ApplyPatchRecoveryInstructions {\n\tconst mustReadFiles = [...new Set(result.failures.map((failure) => failure.filePath))];\n\tconst mustNotReadFiles = [...new Set(result.appliedFiles.filter((filePath) => !mustReadFiles.includes(filePath)))];\n\treturn { mustReadFiles, mustNotReadFiles };\n}\n\nexport function buildPartialFailureText(result: ApplyPatchResult): string {\n\tconst failed = result.recoveryInstructions.mustReadFiles.join(\", \");\n\tconst mustReadText = failed.includes(\",\") ? failed.split(\", \").join(\" and \") : failed;\n\treturn [\n\t\t\"apply_patch partially failed.\",\n\t\t`Failed: ${failed}`,\n\t\t`Recovery: MUST read ${mustReadText} before retrying.`,\n\t\tresult.appliedFiles.length > 0\n\t\t\t? \"Earlier file actions in this patch were already applied.\"\n\t\t\t: \"No file actions were applied.\",\n\t\tresult.recoveryInstructions.mustNotReadFiles.length > 0\n\t\t\t? \"Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it.\"\n\t\t\t: \"\",\n\t]\n\t\t.filter((line) => line.length > 0)\n\t\t.join(\"\\n\");\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const hunk of hunks) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tfailures.push({ filePath: hunk.filePath, operation: hunk.type, message });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [] },\n\t\tdetails: { fuzz },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tfor (const hunk of hunks) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [{ filePath: hunk.filePath, operation: hunk.type, message }];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0 },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, result);\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
1
+ {"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAS/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,uBAAuB,GAA0B,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAErF,KAAK,UAAU,wBAAwB,CACtC,UAAkD,EAClD,QAAmD;IAEnD,IAAI,CAAC;QACJ,MAAM,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,4EAA4E;IAC7E,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,IAAY;IACjD,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,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,CAAC,OAAO,CAAC,CAAC;YAChC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,QAAQ,GAAwB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YACnG,MAAM,MAAM,GAAqB;gBAChC,SAAS;gBACT,YAAY;gBACZ,QAAQ;gBACR,iBAAiB,EAAE,YAAY,CAAC,MAAM,GAAG,CAAC;gBAC1C,oBAAoB,EAAE,0BAA0B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;gBAC5E,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACpB,CAAC;YACF,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { ApplyPatchError } from \"./errors.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { replaceChunks } from \"./patch-replace.ts\";\nimport { normalizePatchText } from \"./text.ts\";\nimport type {\n\tApplyPatchFailure,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchResult,\n\tAtomicWriteOperations,\n\tParsedPatch,\n} from \"./types.ts\";\nimport { resolvePatchPath } from \"./workspace.ts\";\n\nconst ATOMIC_WRITE_OPERATIONS: AtomicWriteOperations = { writeFile, rename, unlink };\n\nasync function notifyApplyPatchProgress(\n\tonProgress: ApplyPatchProgressCallback | undefined,\n\tprogress: Parameters<ApplyPatchProgressCallback>[0],\n): Promise<void> {\n\ttry {\n\t\tawait onProgress?.(progress);\n\t} catch {\n\t\t// Rendering progress must not affect patch application or recovery details.\n\t}\n}\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n\treturn Boolean(error && typeof error === \"object\" && \"code\" in error && error.code === code);\n}\n\nasync function writeFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations = ATOMIC_WRITE_OPERATIONS,\n): Promise<void> {\n\tconst tempPath = `${absPath}.tmp.${process.pid}.${Math.random().toString(16).slice(2)}`;\n\tawait operations.writeFile(tempPath, content, \"utf-8\");\n\ttry {\n\t\tawait operations.rename(tempPath, absPath);\n\t} catch (error) {\n\t\tif (!hasErrorCode(error, \"EEXIST\")) throw error;\n\t\tawait operations.unlink(absPath);\n\t\tawait operations.rename(tempPath, absPath);\n\t}\n}\n\nexport async function __testWriteFileAtomic(\n\tabsPath: string,\n\tcontent: string,\n\toperations: AtomicWriteOperations,\n): Promise<void> {\n\tawait writeFileAtomic(absPath, content, operations);\n}\n\nasync function applySingleHunk(\n\tcwd: string,\n\thunk: ParsedPatch,\n): Promise<{ summary: string; appliedFile: string; fuzz: number }> {\n\tconst absolutePath = resolvePatchPath(cwd, hunk.filePath);\n\tif (hunk.type === \"add\") {\n\t\tawait mkdir(path.dirname(absolutePath), { recursive: true });\n\t\tawait writeFileAtomic(absolutePath, hunk.content);\n\t\treturn { summary: `add: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0 };\n\t}\n\n\tif (hunk.type === \"delete\") {\n\t\tawait stat(absolutePath);\n\t\tawait rm(absolutePath);\n\t\treturn { summary: `delete: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: 0 };\n\t}\n\n\tconst currentContent = await readFile(absolutePath, \"utf-8\");\n\tconst chunkResult =\n\t\thunk.chunks.length === 0\n\t\t\t? { content: currentContent, fuzz: 0 }\n\t\t\t: replaceChunks(currentContent, hunk.filePath, hunk.chunks);\n\n\tif (hunk.movePath) {\n\t\tconst absoluteMovePath = resolvePatchPath(cwd, hunk.movePath);\n\t\tawait mkdir(path.dirname(absoluteMovePath), { recursive: true });\n\t\tawait writeFileAtomic(absoluteMovePath, chunkResult.content);\n\t\tif (absoluteMovePath !== absolutePath) await rm(absolutePath);\n\t\treturn {\n\t\t\tsummary: `move: ${hunk.filePath} -> ${hunk.movePath}`,\n\t\t\tappliedFile: hunk.movePath,\n\t\t\tfuzz: chunkResult.fuzz,\n\t\t};\n\t}\n\n\tawait writeFileAtomic(absolutePath, chunkResult.content);\n\treturn { summary: `update: ${hunk.filePath}`, appliedFile: hunk.filePath, fuzz: chunkResult.fuzz };\n}\n\nfunction createRecoveryInstructions(\n\tresult: Pick<ApplyPatchResult, \"appliedFiles\" | \"failures\">,\n): ApplyPatchRecoveryInstructions {\n\tconst mustReadFiles = [...new Set(result.failures.map((failure) => failure.filePath))];\n\tconst mustNotReadFiles = [...new Set(result.appliedFiles.filter((filePath) => !mustReadFiles.includes(filePath)))];\n\treturn { mustReadFiles, mustNotReadFiles };\n}\n\nexport function buildPartialFailureText(result: ApplyPatchResult): string {\n\tconst failed = result.recoveryInstructions.mustReadFiles.join(\", \");\n\tconst mustReadText = failed.includes(\",\") ? failed.split(\", \").join(\" and \") : failed;\n\treturn [\n\t\t\"apply_patch partially failed.\",\n\t\t`Failed: ${failed}`,\n\t\t`Recovery: MUST read ${mustReadText} before retrying.`,\n\t\tresult.appliedFiles.length > 0\n\t\t\t? \"Earlier file actions in this patch were already applied.\"\n\t\t\t: \"No file actions were applied.\",\n\t\tresult.recoveryInstructions.mustNotReadFiles.length > 0\n\t\t\t? \"Recovery: MUST NOT reread other files from this patch unless a specific dependency requires it.\"\n\t\t\t: \"\",\n\t]\n\t\t.filter((line) => line.length > 0)\n\t\t.join(\"\\n\");\n}\n\nfunction parseNonEmptyPatch(patchText: string): ParsedPatch[] {\n\tconst hunks = parsePatch(patchText);\n\tif (hunks.length === 0) {\n\t\tconst normalized = normalizePatchText(patchText).trim();\n\t\tif (normalized === \"*** Begin Patch\\n*** End Patch\") throw new Error(\"patch rejected: empty patch\");\n\t\tthrow new Error(\"apply_patch verification failed: no hunks found\");\n\t}\n\treturn hunks;\n}\n\nexport async function applyPatchDetailed(\n\tcwd: string,\n\tpatchText: string,\n\tonProgress?: ApplyPatchProgressCallback,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tconst failures: ApplyPatchFailure[] = [];\n\tlet fuzz = 0;\n\n\tfor (const hunk of hunks) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t\tfuzz += applied.fuzz;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tfailures.push({ filePath: hunk.filePath, operation: hunk.type, message });\n\t\t}\n\t\tawait notifyApplyPatchProgress(onProgress, {\n\t\t\tapplied: appliedFiles.length,\n\t\t\tfailed: failures.length,\n\t\t\ttotal: hunks.length,\n\t\t});\n\t}\n\n\tconst result: ApplyPatchResult = {\n\t\tsummaries,\n\t\tappliedFiles,\n\t\tfailures,\n\t\thasPartialSuccess: appliedFiles.length > 0 && failures.length > 0,\n\t\trecoveryInstructions: { mustReadFiles: [], mustNotReadFiles: [] },\n\t\tdetails: { fuzz },\n\t};\n\tresult.recoveryInstructions = createRecoveryInstructions(result);\n\treturn result;\n}\n\nexport async function applyPatch(cwd: string, patchText: string): Promise<string[]> {\n\tconst hunks = parseNonEmptyPatch(patchText);\n\tconst summaries: string[] = [];\n\tconst appliedFiles: string[] = [];\n\tfor (const hunk of hunks) {\n\t\ttry {\n\t\t\tconst applied = await applySingleHunk(cwd, hunk);\n\t\t\tsummaries.push(applied.summary);\n\t\t\tappliedFiles.push(applied.appliedFile);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconst failures: ApplyPatchFailure[] = [{ filePath: hunk.filePath, operation: hunk.type, message }];\n\t\t\tconst result: ApplyPatchResult = {\n\t\t\t\tsummaries,\n\t\t\t\tappliedFiles,\n\t\t\t\tfailures,\n\t\t\t\thasPartialSuccess: appliedFiles.length > 0,\n\t\t\t\trecoveryInstructions: createRecoveryInstructions({ appliedFiles, failures }),\n\t\t\t\tdetails: { fuzz: 0 },\n\t\t\t};\n\t\t\tthrow new ApplyPatchError(message, result);\n\t\t}\n\t}\n\n\treturn summaries;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,eAAO,MAAM,kBAAkB;;EAI7B,CAAC;AAEH,eAAO,MAAM,gCAAgC,yGAC0D,CAAC;AACxG,eAAO,MAAM,wBAAwB,onBAmBpC,CAAC;AACF,eAAO,MAAM,6BAA6B,k9FACu2F,CAAC","sourcesContent":["import { Type } from \"typebox\";\n\nexport const APPLY_PATCH_PARAMS = Type.Object({\n\tinput: Type.String({\n\t\tdescription: \"The entire contents of the apply_patch command\",\n\t}),\n});\n\nexport const APPLY_PATCH_FREEFORM_DESCRIPTION =\n\t\"Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.\";\nexport const APPLY_PATCH_LARK_GRAMMAR = `start: begin_patch hunk+ end_patch\nbegin_patch: \"*** Begin Patch\" LF\nend_patch: \"*** End Patch\" LF?\n\nhunk: add_hunk | delete_hunk | update_hunk\nadd_hunk: \"*** Add File: \" filename LF add_line+\ndelete_hunk: \"*** Delete File: \" filename LF\nupdate_hunk: \"*** Update File: \" filename LF change_move? change?\n\nfilename: /(.+)/\nadd_line: \"+\" /(.*)/ LF -> line\n\nchange_move: \"*** Move to: \" filename LF\nchange: (change_context | change_line)+ eof_line?\nchange_context: (\"@@\" | \"@@ \" /(.+)/) LF\nchange_line: (\"+\" | \"-\" | \" \") /(.*)/ LF\neof_line: \"*** End of File\" LF\n\n%import common.LF\n`;\nexport const CODEX_APPLY_PATCH_DESCRIPTION =\n\t'Use the `apply_patch` tool to edit files.\\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\\n\\n*** Begin Patch\\n[ one or more file sections ]\\n*** End Patch\\n\\nWithin that envelope, you get a sequence of file operations.\\nYou MUST include a header to specify the action you are taking.\\nEach operation starts with one of three headers:\\n\\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\\n*** Delete File: <path> - remove an existing file. Nothing follows.\\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\\n\\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\\nWithin a hunk each line starts with:\\n\\nFor instructions on [context_before] and [context_after]:\\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\\n@@ class BaseClass\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\\n\\n@@ class BaseClass\\n@@ \\t def method():\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\nThe full grammar definition is below:\\nPatch := Begin { FileOp } End\\nBegin := \"*** Begin Patch\" NEWLINE\\nEnd := \"*** End Patch\" NEWLINE\\nFileOp := AddFile | DeleteFile | UpdateFile\\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\\nDeleteFile := \"*** Delete File: \" path NEWLINE\\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\\nMoveTo := \"*** Move to: \" newPath NEWLINE\\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\\n\\nA full patch can combine several operations:\\n\\n*** Begin Patch\\n*** Add File: hello.txt\\n+Hello world\\n*** Update File: src/app.py\\n*** Move to: src/main.py\\n@@ def greet():\\n-print(\"Hi\")\\n+print(\"Hello, world!\")\\n*** Delete File: obsolete.txt\\n*** End Patch\\n\\nIt is important to remember:\\n\\n- You must include a header with your intended action (Add/Delete/Update)\\n- You must prefix new lines with `+` even when creating a new file\\n- File references can only be relative, NEVER ABSOLUTE.\\n';\n"]}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,eAAO,MAAM,kBAAkB;;EAI7B,CAAC;AAEH,eAAO,MAAM,gCAAgC,yGAC0D,CAAC;AACxG,eAAO,MAAM,wBAAwB,onBAmBpC,CAAC;AACF,eAAO,MAAM,6BAA6B,k9FACu2F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,gDAAgD;KAC7D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAC5C,sGAAsG,CAAC;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AACF,MAAM,CAAC,MAAM,6BAA6B,GACzC,85FAAg5F,CAAC","sourcesContent":["import { Type } from \"typebox\";\n\nexport const APPLY_PATCH_PARAMS = Type.Object({\n\tinput: Type.String({\n\t\tdescription: \"The entire contents of the apply_patch command\",\n\t}),\n});\n\nexport const APPLY_PATCH_FREEFORM_DESCRIPTION =\n\t\"Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.\";\nexport const APPLY_PATCH_LARK_GRAMMAR = `start: begin_patch hunk+ end_patch\nbegin_patch: \"*** Begin Patch\" LF\nend_patch: \"*** End Patch\" LF?\n\nhunk: add_hunk | delete_hunk | update_hunk\nadd_hunk: \"*** Add File: \" filename LF add_line+\ndelete_hunk: \"*** Delete File: \" filename LF\nupdate_hunk: \"*** Update File: \" filename LF change_move? change?\n\nfilename: /(.+)/\nadd_line: \"+\" /(.*)/ LF -> line\n\nchange_move: \"*** Move to: \" filename LF\nchange: (change_context | change_line)+ eof_line?\nchange_context: (\"@@\" | \"@@ \" /(.+)/) LF\nchange_line: (\"+\" | \"-\" | \" \") /(.*)/ LF\neof_line: \"*** End of File\" LF\n\n%import common.LF\n`;\nexport const CODEX_APPLY_PATCH_DESCRIPTION =\n\t'Use the `apply_patch` tool to edit files.\\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\\n\\n*** Begin Patch\\n[ one or more file sections ]\\n*** End Patch\\n\\nWithin that envelope, you get a sequence of file operations.\\nYou MUST include a header to specify the action you are taking.\\nEach operation starts with one of three headers:\\n\\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\\n*** Delete File: <path> - remove an existing file. Nothing follows.\\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\\n\\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\\nWithin a hunk each line starts with:\\n\\nFor instructions on [context_before] and [context_after]:\\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\\n@@ class BaseClass\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\\n\\n@@ class BaseClass\\n@@ \\t def method():\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\nThe full grammar definition is below:\\nPatch := Begin { FileOp } End\\nBegin := \"*** Begin Patch\" NEWLINE\\nEnd := \"*** End Patch\" NEWLINE\\nFileOp := AddFile | DeleteFile | UpdateFile\\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\\nDeleteFile := \"*** Delete File: \" path NEWLINE\\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\\nMoveTo := \"*** Move to: \" newPath NEWLINE\\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\\n\\nA full patch can combine several operations:\\n\\n*** Begin Patch\\n*** Add File: hello.txt\\n+Hello world\\n*** Update File: src/app.py\\n*** Move to: src/main.py\\n@@ def greet():\\n-print(\"Hi\")\\n+print(\"Hello, world!\")\\n*** Delete File: obsolete.txt\\n*** End Patch\\n\\nIt is important to remember:\\n\\n- You must include a header with your intended action (Add/Delete/Update)\\n- You must prefix new lines with `+` even when creating a new file\\n- File references can only be relative, NEVER ABSOLUTE.\\n';\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,gDAAgD;KAC7D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAC5C,sGAAsG,CAAC;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AACF,MAAM,CAAC,MAAM,6BAA6B,GACzC,g5FAAg5F,CAAC","sourcesContent":["import { Type } from \"typebox\";\n\nexport const APPLY_PATCH_PARAMS = Type.Object({\n\tinput: Type.String({\n\t\tdescription: \"The entire contents of the apply_patch command\",\n\t}),\n});\n\nexport const APPLY_PATCH_FREEFORM_DESCRIPTION =\n\t\"Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.\";\nexport const APPLY_PATCH_LARK_GRAMMAR = `start: begin_patch hunk+ end_patch\nbegin_patch: \"*** Begin Patch\" LF\nend_patch: \"*** End Patch\" LF?\n\nhunk: add_hunk | delete_hunk | update_hunk\nadd_hunk: \"*** Add File: \" filename LF add_line+\ndelete_hunk: \"*** Delete File: \" filename LF\nupdate_hunk: \"*** Update File: \" filename LF change_move? change?\n\nfilename: /(.+)/\nadd_line: \"+\" /(.*)/ LF -> line\n\nchange_move: \"*** Move to: \" filename LF\nchange: (change_context | change_line)+ eof_line?\nchange_context: (\"@@\" | \"@@ \" /(.+)/) LF\nchange_line: (\"+\" | \"-\" | \" \") /(.*)/ LF\neof_line: \"*** End of File\" LF\n\n%import common.LF\n`;\nexport const CODEX_APPLY_PATCH_DESCRIPTION =\n\t'Use the `apply_patch` tool to edit files.\\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\\n\\n*** Begin Patch\\n[ one or more file sections ]\\n*** End Patch\\n\\nWithin that envelope, you get a sequence of file operations.\\nYou MUST include a header to specify the action you are taking.\\nEach operation starts with one of three headers:\\n\\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\\n*** Delete File: <path> - remove an existing file. Nothing follows.\\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\\n\\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\\nWithin a hunk each line starts with:\\n\\nFor instructions on [context_before] and [context_after]:\\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\\n@@ class BaseClass\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\\n\\n@@ class BaseClass\\n@@ \\t def method():\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\nThe full grammar definition is below:\\nPatch := Begin { FileOp } End\\nBegin := \"*** Begin Patch\" NEWLINE\\nEnd := \"*** End Patch\" NEWLINE\\nFileOp := AddFile | DeleteFile | UpdateFile\\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\\nDeleteFile := \"*** Delete File: \" path NEWLINE\\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\\nMoveTo := \"*** Move to: \" newPath NEWLINE\\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\\n\\nA full patch can combine several operations:\\n\\n*** Begin Patch\\n*** Add File: hello.txt\\n+Hello world\\n*** Update File: src/app.py\\n*** Move to: src/main.py\\n@@ def greet():\\n-print(\"Hi\")\\n+print(\"Hello, world!\")\\n*** Delete File: obsolete.txt\\n*** End Patch\\n\\nIt is important to remember:\\n\\n- You must include a header with your intended action (Add/Delete/Update)\\n- You must prefix new lines with `+` even when creating a new file\\n- File references can only be relative, NEVER ABSOLUTE.\\n';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE,qBAAa,eAAgB,SAAQ,KAAK;IACzC,SAAgB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9C,SAAgB,MAAM,EAAE,gBAAgB,CAAC;IAEzC,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAKpD;IAED,iBAAiB,IAAI,OAAO,CAE3B;CACD","sourcesContent":["import type { ApplyPatchFailure, ApplyPatchResult } from \"./types.ts\";\n\nexport class ApplyPatchError extends Error {\n\tpublic readonly failures: ApplyPatchFailure[];\n\tpublic readonly result: ApplyPatchResult;\n\n\tconstructor(message: string, result: ApplyPatchResult) {\n\t\tsuper(message);\n\t\tthis.name = \"ApplyPatchError\";\n\t\tthis.failures = result.failures;\n\t\tthis.result = result;\n\t}\n\n\thasPartialSuccess(): boolean {\n\t\treturn this.result.hasPartialSuccess;\n\t}\n}\n"]}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE,qBAAa,eAAgB,SAAQ,KAAK;IACzC,SAAgB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9C,SAAgB,MAAM,EAAE,gBAAgB,CAAC;IAEzC,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAKpD;IAED,iBAAiB,IAAI,OAAO,CAE3B;CACD"}
@@ -1,6 +1,4 @@
1
1
  export class ApplyPatchError extends Error {
2
- failures;
3
- result;
4
2
  constructor(message, result) {
5
3
  super(message);
6
4
  this.name = "ApplyPatchError";
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzB,QAAQ,CAAsB;IAC9B,MAAM,CAAmB;IAEzC,YAAY,OAAe,EAAE,MAAwB,EAAE;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAAA,CACrB;IAED,iBAAiB,GAAY;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAAA,CACrC;CACD","sourcesContent":["import type { ApplyPatchFailure, ApplyPatchResult } from \"./types.ts\";\n\nexport class ApplyPatchError extends Error {\n\tpublic readonly failures: ApplyPatchFailure[];\n\tpublic readonly result: ApplyPatchResult;\n\n\tconstructor(message: string, result: ApplyPatchResult) {\n\t\tsuper(message);\n\t\tthis.name = \"ApplyPatchError\";\n\t\tthis.failures = result.failures;\n\t\tthis.result = result;\n\t}\n\n\thasPartialSuccess(): boolean {\n\t\treturn this.result.hasPartialSuccess;\n\t}\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAIzC,YAAY,OAAe,EAAE,MAAwB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,iBAAiB;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;IACtC,CAAC;CACD","sourcesContent":["import type { ApplyPatchFailure, ApplyPatchResult } from \"./types.ts\";\n\nexport class ApplyPatchError extends Error {\n\tpublic readonly failures: ApplyPatchFailure[];\n\tpublic readonly result: ApplyPatchResult;\n\n\tconstructor(message: string, result: ApplyPatchResult) {\n\t\tsuper(message);\n\t\tthis.name = \"ApplyPatchError\";\n\t\tthis.failures = result.failures;\n\t\tthis.result = result;\n\t}\n\n\thasPartialSuccess(): boolean {\n\t\treturn this.result.hasPartialSuccess;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,sBAAsB,EAAiB,MAAM,YAAY,CAAC;AAKxE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAEnG;AA+CD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAS5E;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type { ApplyPatchExtensionAPI, BaselineState } from \"./types.ts\";\n\nconst GPT_APPLY_PATCH_PROVIDERS = new Set([\"openai\", \"azure-openai-responses\", \"github-copilot\"]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"provider\" | \"id\"> | undefined): boolean {\n\treturn model !== undefined && GPT_APPLY_PATCH_PROVIDERS.has(model.provider) && model.id.startsWith(\"gpt-\");\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== \"apply_patch\");\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames)) return filteredToolNames;\n\treturn [...filteredToolNames, \"apply_patch\"];\n}\n\nfunction restoreEditToolsFromBaseline(currentToolNames: string[], baselineToolNames: string[]): string[] {\n\tconst restoredToolNames = [\n\t\t...withoutApplyPatch(currentToolNames),\n\t\t...baselineToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName)),\n\t];\n\treturn [...new Set(restoredToolNames)];\n}\n\nfunction syncToolset(\n\tpi: Pick<ApplyPatchExtensionAPI, \"getActiveTools\" | \"setActiveTools\">,\n\tmodel: Model<string> | undefined,\n\tstate: BaselineState,\n): void {\n\tconst currentToolNames = pi.getActiveTools();\n\tif (isOpenAIGptModel(model)) {\n\t\tif (hasEditTools(currentToolNames)) state.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\n\tif (state.nonGptToolNames.length > 0) {\n\t\tconst restoredToolNames = restoreEditToolsFromBaseline(currentToolNames, state.nonGptToolNames);\n\t\tstate.nonGptToolNames = restoredToolNames;\n\t\tpi.setActiveTools(restoredToolNames);\n\t\treturn;\n\t}\n\n\tstate.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\tpi.setActiveTools(state.nonGptToolNames);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: BaselineState = { nonGptToolNames: [] };\n\tpi.registerTool(createApplyPatchTool());\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
1
+ {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,sBAAsB,EAAiB,MAAM,YAAY,CAAC;AAKxE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAEnG;AA+CD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAS5E;eAEc,2BAA2B"}
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,wBAAwB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAClG,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAAC,KAAyD,EAAW;IACpG,OAAO,KAAK,KAAK,SAAS,IAAI,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,M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eAAe,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;QAChG,EAAE,CAAC,cAAc,CAAC,8BAA8B,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACpE,OAAO;IACR,CAAC;IAED,IAAI,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC,gBAAgB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QAChG,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC;QAC1C,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACrC,OAAO;IACR,CAAC;IAED,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC5D,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAAA,CACzC;AAED,MAAM,UAAU,2BAA2B,CAAC,EAA0B,EAAQ;IAC7E,MAAM,KAAK,GAAkB,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IACrD,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACxC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC7C,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAAA,CAClC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QACtC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAAA,CACpC,CAAC,CAAC;AAAA,CACH;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type { ApplyPatchExtensionAPI, BaselineState } from \"./types.ts\";\n\nconst GPT_APPLY_PATCH_PROVIDERS = new Set([\"openai\", \"azure-openai-responses\", \"github-copilot\"]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"provider\" | \"id\"> | undefined): boolean {\n\treturn model !== undefined && GPT_APPLY_PATCH_PROVIDERS.has(model.provider) && model.id.startsWith(\"gpt-\");\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== \"apply_patch\");\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames)) return filteredToolNames;\n\treturn [...filteredToolNames, \"apply_patch\"];\n}\n\nfunction restoreEditToolsFromBaseline(currentToolNames: string[], baselineToolNames: string[]): string[] {\n\tconst restoredToolNames = [\n\t\t...withoutApplyPatch(currentToolNames),\n\t\t...baselineToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName)),\n\t];\n\treturn [...new Set(restoredToolNames)];\n}\n\nfunction syncToolset(\n\tpi: Pick<ApplyPatchExtensionAPI, \"getActiveTools\" | \"setActiveTools\">,\n\tmodel: Model<string> | undefined,\n\tstate: BaselineState,\n): void {\n\tconst currentToolNames = pi.getActiveTools();\n\tif (isOpenAIGptModel(model)) {\n\t\tif (hasEditTools(currentToolNames)) state.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\n\tif (state.nonGptToolNames.length > 0) {\n\t\tconst restoredToolNames = restoreEditToolsFromBaseline(currentToolNames, state.nonGptToolNames);\n\t\tstate.nonGptToolNames = restoredToolNames;\n\t\tpi.setActiveTools(restoredToolNames);\n\t\treturn;\n\t}\n\n\tstate.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\tpi.setActiveTools(state.nonGptToolNames);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: BaselineState = { nonGptToolNames: [] };\n\tpi.registerTool(createApplyPatchTool());\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,wBAAwB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAClG,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAAC,KAAyD;IACzF,OAAO,KAAK,KAAK,SAAS,IAAI,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5G,CAAC;AAED,SAAS,YAAY,CAAC,SAAmB;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAmB;IAC7C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,8BAA8B,CAAC,SAAmB;IAC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,OAAO;IACR,CAAC;IAED,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC5D,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,EAA0B;IACrE,MAAM,KAAK,GAAkB,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IACrD,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACxC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type { ApplyPatchExtensionAPI, BaselineState } from \"./types.ts\";\n\nconst GPT_APPLY_PATCH_PROVIDERS = new Set([\"openai\", \"azure-openai-responses\", \"github-copilot\"]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"provider\" | \"id\"> | undefined): boolean {\n\treturn model !== undefined && GPT_APPLY_PATCH_PROVIDERS.has(model.provider) && model.id.startsWith(\"gpt-\");\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== \"apply_patch\");\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames)) return filteredToolNames;\n\treturn [...filteredToolNames, \"apply_patch\"];\n}\n\nfunction restoreEditToolsFromBaseline(currentToolNames: string[], baselineToolNames: string[]): string[] {\n\tconst restoredToolNames = [\n\t\t...withoutApplyPatch(currentToolNames),\n\t\t...baselineToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName)),\n\t];\n\treturn [...new Set(restoredToolNames)];\n}\n\nfunction syncToolset(\n\tpi: Pick<ApplyPatchExtensionAPI, \"getActiveTools\" | \"setActiveTools\">,\n\tmodel: Model<string> | undefined,\n\tstate: BaselineState,\n): void {\n\tconst currentToolNames = pi.getActiveTools();\n\tif (isOpenAIGptModel(model)) {\n\t\tif (hasEditTools(currentToolNames)) state.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\n\tif (state.nonGptToolNames.length > 0) {\n\t\tconst restoredToolNames = restoreEditToolsFromBaseline(currentToolNames, state.nonGptToolNames);\n\t\tstate.nonGptToolNames = restoredToolNames;\n\t\tpi.setActiveTools(restoredToolNames);\n\t\treturn;\n\t}\n\n\tstate.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\tpi.setActiveTools(state.nonGptToolNames);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: BaselineState = { nonGptToolNames: [] };\n\tpi.registerTool(createApplyPatchTool());\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACV,MAAM,YAAY,CAAC","sourcesContent":["export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nexport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n\tCODEX_APPLY_PATCH_DESCRIPTION,\n} from \"./constants.ts\";\nexport { ApplyPatchError } from \"./errors.ts\";\nexport { default, isOpenAIGptModel, registerApplyPatchExtension } from \"./extension.ts\";\nexport { parsePatch } from \"./parser.ts\";\nexport {\n\tclearApplyPatchRenderState,\n\tdisplayPath,\n\tformatInFlightCallText,\n\tformatPatchPreview,\n\tgetApplyPatchRenderState,\n\tPATCH_PREVIEW_MAX_CHARS,\n\tPATCH_PREVIEW_MAX_LINES,\n\trenderPatchPreview,\n\ttruncatePreview,\n} from \"./preview-format.ts\";\nexport { seekSequence } from \"./seek-sequence.ts\";\nexport { StreamingPatchParser } from \"./streaming-parser.ts\";\nexport { extractPatchedPaths, normalizePatchText, stripHeredoc } from \"./text.ts\";\nexport { createApplyPatchTool } from \"./tool.ts\";\nexport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchFailure,\n\tApplyPatchParams,\n\tApplyPatchPreview,\n\tApplyPatchProgress,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tAtomicWriteOperations,\n\tFreeformToolFormat,\n\tParsedPatch,\n\tPatchChunk,\n} from \"./types.ts\";\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACV,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAa5E","sourcesContent":["import type { ApplyPatchParams } from \"./types.ts\";\n\nexport function normalizeApplyPatchArguments(args: unknown): ApplyPatchParams {\n\tif (typeof args === \"string\") {\n\t\treturn { input: args };\n\t}\n\n\tif (args && typeof args === \"object\" && \"input\" in args) {\n\t\tconst input = args.input;\n\t\tif (typeof input === \"string\") {\n\t\t\treturn { input };\n\t\t}\n\t}\n\n\treturn { input: \"\" };\n}\n"]}
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAa5E"}