@openeryc/pi-coding-agent 0.75.12 → 0.75.14

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 (591) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  3. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  4. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  5. package/examples/extensions/sandbox/package-lock.json +2 -2
  6. package/examples/extensions/sandbox/package.json +1 -1
  7. package/examples/extensions/with-deps/package-lock.json +2 -2
  8. package/examples/extensions/with-deps/package.json +1 -1
  9. package/npm-shrinkwrap.json +12 -12
  10. package/package.json +4 -4
  11. package/dist/bun/cli.d.ts +0 -3
  12. package/dist/bun/cli.d.ts.map +0 -1
  13. package/dist/bun/cli.js +0 -9
  14. package/dist/bun/cli.js.map +0 -1
  15. package/dist/bun/register-bedrock.d.ts +0 -2
  16. package/dist/bun/register-bedrock.d.ts.map +0 -1
  17. package/dist/bun/register-bedrock.js +0 -4
  18. package/dist/bun/register-bedrock.js.map +0 -1
  19. package/dist/bun/restore-sandbox-env.d.ts +0 -13
  20. package/dist/bun/restore-sandbox-env.d.ts.map +0 -1
  21. package/dist/bun/restore-sandbox-env.js +0 -32
  22. package/dist/bun/restore-sandbox-env.js.map +0 -1
  23. package/dist/cli/args.d.ts +0 -53
  24. package/dist/cli/args.d.ts.map +0 -1
  25. package/dist/cli/args.js +0 -341
  26. package/dist/cli/args.js.map +0 -1
  27. package/dist/cli/config-selector.d.ts +0 -14
  28. package/dist/cli/config-selector.d.ts.map +0 -1
  29. package/dist/cli/config-selector.js +0 -31
  30. package/dist/cli/config-selector.js.map +0 -1
  31. package/dist/cli/file-processor.d.ts +0 -15
  32. package/dist/cli/file-processor.d.ts.map +0 -1
  33. package/dist/cli/file-processor.js +0 -83
  34. package/dist/cli/file-processor.js.map +0 -1
  35. package/dist/cli/initial-message.d.ts +0 -18
  36. package/dist/cli/initial-message.d.ts.map +0 -1
  37. package/dist/cli/initial-message.js +0 -22
  38. package/dist/cli/initial-message.js.map +0 -1
  39. package/dist/cli/list-models.d.ts +0 -9
  40. package/dist/cli/list-models.d.ts.map +0 -1
  41. package/dist/cli/list-models.js +0 -98
  42. package/dist/cli/list-models.js.map +0 -1
  43. package/dist/cli/session-picker.d.ts +0 -9
  44. package/dist/cli/session-picker.d.ts.map +0 -1
  45. package/dist/cli/session-picker.js +0 -35
  46. package/dist/cli/session-picker.js.map +0 -1
  47. package/dist/cli.d.ts +0 -3
  48. package/dist/cli.d.ts.map +0 -1
  49. package/dist/cli.js +0 -18
  50. package/dist/cli.js.map +0 -1
  51. package/dist/config.d.ts +0 -92
  52. package/dist/config.d.ts.map +0 -1
  53. package/dist/config.js +0 -422
  54. package/dist/config.js.map +0 -1
  55. package/dist/core/agent-session-runtime.d.ts +0 -117
  56. package/dist/core/agent-session-runtime.d.ts.map +0 -1
  57. package/dist/core/agent-session-runtime.js +0 -299
  58. package/dist/core/agent-session-runtime.js.map +0 -1
  59. package/dist/core/agent-session-services.d.ts +0 -86
  60. package/dist/core/agent-session-services.d.ts.map +0 -1
  61. package/dist/core/agent-session-services.js +0 -117
  62. package/dist/core/agent-session-services.js.map +0 -1
  63. package/dist/core/agent-session.d.ts +0 -605
  64. package/dist/core/agent-session.d.ts.map +0 -1
  65. package/dist/core/agent-session.js +0 -2519
  66. package/dist/core/agent-session.js.map +0 -1
  67. package/dist/core/auth-guidance.d.ts +0 -5
  68. package/dist/core/auth-guidance.d.ts.map +0 -1
  69. package/dist/core/auth-guidance.js +0 -21
  70. package/dist/core/auth-guidance.js.map +0 -1
  71. package/dist/core/auth-storage.d.ts +0 -141
  72. package/dist/core/auth-storage.d.ts.map +0 -1
  73. package/dist/core/auth-storage.js +0 -441
  74. package/dist/core/auth-storage.js.map +0 -1
  75. package/dist/core/bash-executor.d.ts +0 -32
  76. package/dist/core/bash-executor.d.ts.map +0 -1
  77. package/dist/core/bash-executor.js +0 -111
  78. package/dist/core/bash-executor.js.map +0 -1
  79. package/dist/core/compaction/branch-summarization.d.ts +0 -88
  80. package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
  81. package/dist/core/compaction/branch-summarization.js +0 -243
  82. package/dist/core/compaction/branch-summarization.js.map +0 -1
  83. package/dist/core/compaction/compaction.d.ts +0 -121
  84. package/dist/core/compaction/compaction.d.ts.map +0 -1
  85. package/dist/core/compaction/compaction.js +0 -638
  86. package/dist/core/compaction/compaction.js.map +0 -1
  87. package/dist/core/compaction/index.d.ts +0 -7
  88. package/dist/core/compaction/index.d.ts.map +0 -1
  89. package/dist/core/compaction/index.js +0 -7
  90. package/dist/core/compaction/index.js.map +0 -1
  91. package/dist/core/compaction/utils.d.ts +0 -38
  92. package/dist/core/compaction/utils.d.ts.map +0 -1
  93. package/dist/core/compaction/utils.js +0 -153
  94. package/dist/core/compaction/utils.js.map +0 -1
  95. package/dist/core/defaults.d.ts +0 -3
  96. package/dist/core/defaults.d.ts.map +0 -1
  97. package/dist/core/defaults.js +0 -2
  98. package/dist/core/defaults.js.map +0 -1
  99. package/dist/core/diagnostics.d.ts +0 -15
  100. package/dist/core/diagnostics.d.ts.map +0 -1
  101. package/dist/core/diagnostics.js +0 -2
  102. package/dist/core/diagnostics.js.map +0 -1
  103. package/dist/core/event-bus.d.ts +0 -9
  104. package/dist/core/event-bus.d.ts.map +0 -1
  105. package/dist/core/event-bus.js +0 -25
  106. package/dist/core/event-bus.js.map +0 -1
  107. package/dist/core/exec.d.ts +0 -29
  108. package/dist/core/exec.d.ts.map +0 -1
  109. package/dist/core/exec.js +0 -75
  110. package/dist/core/exec.js.map +0 -1
  111. package/dist/core/export-html/ansi-to-html.d.ts +0 -22
  112. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  113. package/dist/core/export-html/ansi-to-html.js +0 -249
  114. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  115. package/dist/core/export-html/index.d.ts +0 -37
  116. package/dist/core/export-html/index.d.ts.map +0 -1
  117. package/dist/core/export-html/index.js +0 -224
  118. package/dist/core/export-html/index.js.map +0 -1
  119. package/dist/core/export-html/template.css +0 -1066
  120. package/dist/core/export-html/template.html +0 -55
  121. package/dist/core/export-html/template.js +0 -1848
  122. package/dist/core/export-html/tool-renderer.d.ts +0 -34
  123. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  124. package/dist/core/export-html/tool-renderer.js +0 -108
  125. package/dist/core/export-html/tool-renderer.js.map +0 -1
  126. package/dist/core/export-html/vendor/highlight.min.js +0 -1213
  127. package/dist/core/export-html/vendor/marked.min.js +0 -6
  128. package/dist/core/extensions/index.d.ts +0 -12
  129. package/dist/core/extensions/index.d.ts.map +0 -1
  130. package/dist/core/extensions/index.js +0 -9
  131. package/dist/core/extensions/index.js.map +0 -1
  132. package/dist/core/extensions/loader.d.ts +0 -24
  133. package/dist/core/extensions/loader.d.ts.map +0 -1
  134. package/dist/core/extensions/loader.js +0 -508
  135. package/dist/core/extensions/loader.js.map +0 -1
  136. package/dist/core/extensions/runner.d.ts +0 -159
  137. package/dist/core/extensions/runner.d.ts.map +0 -1
  138. package/dist/core/extensions/runner.js +0 -826
  139. package/dist/core/extensions/runner.js.map +0 -1
  140. package/dist/core/extensions/types.d.ts +0 -1181
  141. package/dist/core/extensions/types.d.ts.map +0 -1
  142. package/dist/core/extensions/types.js +0 -45
  143. package/dist/core/extensions/types.js.map +0 -1
  144. package/dist/core/extensions/wrapper.d.ts +0 -20
  145. package/dist/core/extensions/wrapper.d.ts.map +0 -1
  146. package/dist/core/extensions/wrapper.js +0 -22
  147. package/dist/core/extensions/wrapper.js.map +0 -1
  148. package/dist/core/footer-data-provider.d.ts +0 -52
  149. package/dist/core/footer-data-provider.d.ts.map +0 -1
  150. package/dist/core/footer-data-provider.js +0 -310
  151. package/dist/core/footer-data-provider.js.map +0 -1
  152. package/dist/core/http-dispatcher.d.ts +0 -21
  153. package/dist/core/http-dispatcher.d.ts.map +0 -1
  154. package/dist/core/http-dispatcher.js +0 -48
  155. package/dist/core/http-dispatcher.js.map +0 -1
  156. package/dist/core/index.d.ts +0 -12
  157. package/dist/core/index.d.ts.map +0 -1
  158. package/dist/core/index.js +0 -12
  159. package/dist/core/index.js.map +0 -1
  160. package/dist/core/keybindings.d.ts +0 -353
  161. package/dist/core/keybindings.d.ts.map +0 -1
  162. package/dist/core/keybindings.js +0 -295
  163. package/dist/core/keybindings.js.map +0 -1
  164. package/dist/core/messages.d.ts +0 -77
  165. package/dist/core/messages.d.ts.map +0 -1
  166. package/dist/core/messages.js +0 -123
  167. package/dist/core/messages.js.map +0 -1
  168. package/dist/core/model-registry.d.ts +0 -150
  169. package/dist/core/model-registry.d.ts.map +0 -1
  170. package/dist/core/model-registry.js +0 -728
  171. package/dist/core/model-registry.js.map +0 -1
  172. package/dist/core/model-resolver.d.ts +0 -110
  173. package/dist/core/model-resolver.d.ts.map +0 -1
  174. package/dist/core/model-resolver.js +0 -495
  175. package/dist/core/model-resolver.js.map +0 -1
  176. package/dist/core/output-guard.d.ts +0 -6
  177. package/dist/core/output-guard.d.ts.map +0 -1
  178. package/dist/core/output-guard.js +0 -59
  179. package/dist/core/output-guard.js.map +0 -1
  180. package/dist/core/package-manager.d.ts +0 -203
  181. package/dist/core/package-manager.d.ts.map +0 -1
  182. package/dist/core/package-manager.js +0 -2013
  183. package/dist/core/package-manager.js.map +0 -1
  184. package/dist/core/prompt-templates.d.ts +0 -52
  185. package/dist/core/prompt-templates.d.ts.map +0 -1
  186. package/dist/core/prompt-templates.js +0 -252
  187. package/dist/core/prompt-templates.js.map +0 -1
  188. package/dist/core/provider-display-names.d.ts +0 -2
  189. package/dist/core/provider-display-names.d.ts.map +0 -1
  190. package/dist/core/provider-display-names.js +0 -33
  191. package/dist/core/provider-display-names.js.map +0 -1
  192. package/dist/core/resolve-config-value.d.ts +0 -23
  193. package/dist/core/resolve-config-value.d.ts.map +0 -1
  194. package/dist/core/resolve-config-value.js +0 -126
  195. package/dist/core/resolve-config-value.js.map +0 -1
  196. package/dist/core/resource-loader.d.ts +0 -197
  197. package/dist/core/resource-loader.d.ts.map +0 -1
  198. package/dist/core/resource-loader.js +0 -757
  199. package/dist/core/resource-loader.js.map +0 -1
  200. package/dist/core/sdk.d.ts +0 -107
  201. package/dist/core/sdk.d.ts.map +0 -1
  202. package/dist/core/sdk.js +0 -282
  203. package/dist/core/sdk.js.map +0 -1
  204. package/dist/core/session-cwd.d.ts +0 -19
  205. package/dist/core/session-cwd.d.ts.map +0 -1
  206. package/dist/core/session-cwd.js +0 -38
  207. package/dist/core/session-cwd.js.map +0 -1
  208. package/dist/core/session-manager.d.ts +0 -363
  209. package/dist/core/session-manager.d.ts.map +0 -1
  210. package/dist/core/session-manager.js +0 -1318
  211. package/dist/core/session-manager.js.map +0 -1
  212. package/dist/core/settings-manager.d.ts +0 -264
  213. package/dist/core/settings-manager.d.ts.map +0 -1
  214. package/dist/core/settings-manager.js +0 -802
  215. package/dist/core/settings-manager.js.map +0 -1
  216. package/dist/core/skills.d.ts +0 -60
  217. package/dist/core/skills.d.ts.map +0 -1
  218. package/dist/core/skills.js +0 -401
  219. package/dist/core/skills.js.map +0 -1
  220. package/dist/core/slash-commands.d.ts +0 -14
  221. package/dist/core/slash-commands.d.ts.map +0 -1
  222. package/dist/core/slash-commands.js +0 -28
  223. package/dist/core/slash-commands.js.map +0 -1
  224. package/dist/core/source-info.d.ts +0 -18
  225. package/dist/core/source-info.d.ts.map +0 -1
  226. package/dist/core/source-info.js +0 -19
  227. package/dist/core/source-info.js.map +0 -1
  228. package/dist/core/system-prompt.d.ts +0 -30
  229. package/dist/core/system-prompt.d.ts.map +0 -1
  230. package/dist/core/system-prompt.js +0 -132
  231. package/dist/core/system-prompt.js.map +0 -1
  232. package/dist/core/telemetry.d.ts +0 -3
  233. package/dist/core/telemetry.d.ts.map +0 -1
  234. package/dist/core/telemetry.js +0 -9
  235. package/dist/core/telemetry.js.map +0 -1
  236. package/dist/core/timings.d.ts +0 -8
  237. package/dist/core/timings.d.ts.map +0 -1
  238. package/dist/core/timings.js +0 -31
  239. package/dist/core/timings.js.map +0 -1
  240. package/dist/core/tools/bash.d.ts +0 -68
  241. package/dist/core/tools/bash.d.ts.map +0 -1
  242. package/dist/core/tools/bash.js +0 -336
  243. package/dist/core/tools/bash.js.map +0 -1
  244. package/dist/core/tools/edit-diff.d.ts +0 -85
  245. package/dist/core/tools/edit-diff.d.ts.map +0 -1
  246. package/dist/core/tools/edit-diff.js +0 -338
  247. package/dist/core/tools/edit-diff.js.map +0 -1
  248. package/dist/core/tools/edit.d.ts +0 -49
  249. package/dist/core/tools/edit.d.ts.map +0 -1
  250. package/dist/core/tools/edit.js +0 -324
  251. package/dist/core/tools/edit.js.map +0 -1
  252. package/dist/core/tools/file-mutation-queue.d.ts +0 -6
  253. package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
  254. package/dist/core/tools/file-mutation-queue.js +0 -37
  255. package/dist/core/tools/file-mutation-queue.js.map +0 -1
  256. package/dist/core/tools/find.d.ts +0 -35
  257. package/dist/core/tools/find.d.ts.map +0 -1
  258. package/dist/core/tools/find.js +0 -298
  259. package/dist/core/tools/find.js.map +0 -1
  260. package/dist/core/tools/grep.d.ts +0 -37
  261. package/dist/core/tools/grep.d.ts.map +0 -1
  262. package/dist/core/tools/grep.js +0 -304
  263. package/dist/core/tools/grep.js.map +0 -1
  264. package/dist/core/tools/index.d.ts +0 -40
  265. package/dist/core/tools/index.d.ts.map +0 -1
  266. package/dist/core/tools/index.js +0 -112
  267. package/dist/core/tools/index.js.map +0 -1
  268. package/dist/core/tools/ls.d.ts +0 -37
  269. package/dist/core/tools/ls.d.ts.map +0 -1
  270. package/dist/core/tools/ls.js +0 -169
  271. package/dist/core/tools/ls.js.map +0 -1
  272. package/dist/core/tools/output-accumulator.d.ts +0 -50
  273. package/dist/core/tools/output-accumulator.d.ts.map +0 -1
  274. package/dist/core/tools/output-accumulator.js +0 -178
  275. package/dist/core/tools/output-accumulator.js.map +0 -1
  276. package/dist/core/tools/path-utils.d.ts +0 -8
  277. package/dist/core/tools/path-utils.d.ts.map +0 -1
  278. package/dist/core/tools/path-utils.js +0 -81
  279. package/dist/core/tools/path-utils.js.map +0 -1
  280. package/dist/core/tools/read.d.ts +0 -35
  281. package/dist/core/tools/read.d.ts.map +0 -1
  282. package/dist/core/tools/read.js +0 -291
  283. package/dist/core/tools/read.js.map +0 -1
  284. package/dist/core/tools/render-utils.d.ts +0 -21
  285. package/dist/core/tools/render-utils.d.ts.map +0 -1
  286. package/dist/core/tools/render-utils.js +0 -49
  287. package/dist/core/tools/render-utils.js.map +0 -1
  288. package/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
  289. package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
  290. package/dist/core/tools/tool-definition-wrapper.js +0 -34
  291. package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
  292. package/dist/core/tools/truncate.d.ts +0 -70
  293. package/dist/core/tools/truncate.d.ts.map +0 -1
  294. package/dist/core/tools/truncate.js +0 -205
  295. package/dist/core/tools/truncate.js.map +0 -1
  296. package/dist/core/tools/write.d.ts +0 -26
  297. package/dist/core/tools/write.d.ts.map +0 -1
  298. package/dist/core/tools/write.js +0 -213
  299. package/dist/core/tools/write.js.map +0 -1
  300. package/dist/index.d.ts +0 -29
  301. package/dist/index.d.ts.map +0 -1
  302. package/dist/index.js +0 -42
  303. package/dist/index.js.map +0 -1
  304. package/dist/main.d.ts +0 -12
  305. package/dist/main.d.ts.map +0 -1
  306. package/dist/main.js +0 -587
  307. package/dist/main.js.map +0 -1
  308. package/dist/migrations.d.ts +0 -33
  309. package/dist/migrations.d.ts.map +0 -1
  310. package/dist/migrations.js +0 -281
  311. package/dist/migrations.js.map +0 -1
  312. package/dist/modes/index.d.ts +0 -10
  313. package/dist/modes/index.d.ts.map +0 -1
  314. package/dist/modes/index.js +0 -9
  315. package/dist/modes/index.js.map +0 -1
  316. package/dist/modes/interactive/assets/clankolas.png +0 -0
  317. package/dist/modes/interactive/components/armin.d.ts +0 -34
  318. package/dist/modes/interactive/components/armin.d.ts.map +0 -1
  319. package/dist/modes/interactive/components/armin.js +0 -333
  320. package/dist/modes/interactive/components/armin.js.map +0 -1
  321. package/dist/modes/interactive/components/assistant-message.d.ts +0 -20
  322. package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
  323. package/dist/modes/interactive/components/assistant-message.js +0 -121
  324. package/dist/modes/interactive/components/assistant-message.js.map +0 -1
  325. package/dist/modes/interactive/components/bash-execution.d.ts +0 -34
  326. package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
  327. package/dist/modes/interactive/components/bash-execution.js +0 -175
  328. package/dist/modes/interactive/components/bash-execution.js.map +0 -1
  329. package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
  330. package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
  331. package/dist/modes/interactive/components/bordered-loader.js +0 -54
  332. package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
  333. package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
  334. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
  335. package/dist/modes/interactive/components/branch-summary-message.js +0 -44
  336. package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
  337. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
  338. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  339. package/dist/modes/interactive/components/compaction-summary-message.js +0 -45
  340. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
  341. package/dist/modes/interactive/components/config-selector.d.ts +0 -71
  342. package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
  343. package/dist/modes/interactive/components/config-selector.js +0 -506
  344. package/dist/modes/interactive/components/config-selector.js.map +0 -1
  345. package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
  346. package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
  347. package/dist/modes/interactive/components/countdown-timer.js +0 -33
  348. package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
  349. package/dist/modes/interactive/components/custom-editor.d.ts +0 -21
  350. package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
  351. package/dist/modes/interactive/components/custom-editor.js +0 -70
  352. package/dist/modes/interactive/components/custom-editor.js.map +0 -1
  353. package/dist/modes/interactive/components/custom-message.d.ts +0 -20
  354. package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
  355. package/dist/modes/interactive/components/custom-message.js +0 -79
  356. package/dist/modes/interactive/components/custom-message.js.map +0 -1
  357. package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
  358. package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
  359. package/dist/modes/interactive/components/daxnuts.js +0 -140
  360. package/dist/modes/interactive/components/daxnuts.js.map +0 -1
  361. package/dist/modes/interactive/components/diff.d.ts +0 -12
  362. package/dist/modes/interactive/components/diff.d.ts.map +0 -1
  363. package/dist/modes/interactive/components/diff.js +0 -133
  364. package/dist/modes/interactive/components/diff.js.map +0 -1
  365. package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
  366. package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
  367. package/dist/modes/interactive/components/dynamic-border.js +0 -21
  368. package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
  369. package/dist/modes/interactive/components/earendil-announcement.d.ts +0 -5
  370. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +0 -1
  371. package/dist/modes/interactive/components/earendil-announcement.js +0 -40
  372. package/dist/modes/interactive/components/earendil-announcement.js.map +0 -1
  373. package/dist/modes/interactive/components/extension-editor.d.ts +0 -20
  374. package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
  375. package/dist/modes/interactive/components/extension-editor.js +0 -119
  376. package/dist/modes/interactive/components/extension-editor.js.map +0 -1
  377. package/dist/modes/interactive/components/extension-input.d.ts +0 -23
  378. package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
  379. package/dist/modes/interactive/components/extension-input.js +0 -61
  380. package/dist/modes/interactive/components/extension-input.js.map +0 -1
  381. package/dist/modes/interactive/components/extension-selector.d.ts +0 -26
  382. package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
  383. package/dist/modes/interactive/components/extension-selector.js +0 -83
  384. package/dist/modes/interactive/components/extension-selector.js.map +0 -1
  385. package/dist/modes/interactive/components/footer.d.ts +0 -27
  386. package/dist/modes/interactive/components/footer.d.ts.map +0 -1
  387. package/dist/modes/interactive/components/footer.js +0 -201
  388. package/dist/modes/interactive/components/footer.js.map +0 -1
  389. package/dist/modes/interactive/components/index.d.ts +0 -32
  390. package/dist/modes/interactive/components/index.d.ts.map +0 -1
  391. package/dist/modes/interactive/components/index.js +0 -33
  392. package/dist/modes/interactive/components/index.js.map +0 -1
  393. package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -13
  394. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
  395. package/dist/modes/interactive/components/keybinding-hints.js +0 -36
  396. package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
  397. package/dist/modes/interactive/components/login-dialog.d.ts +0 -46
  398. package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
  399. package/dist/modes/interactive/components/login-dialog.js +0 -160
  400. package/dist/modes/interactive/components/login-dialog.js.map +0 -1
  401. package/dist/modes/interactive/components/model-selector.d.ts +0 -47
  402. package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
  403. package/dist/modes/interactive/components/model-selector.js +0 -278
  404. package/dist/modes/interactive/components/model-selector.js.map +0 -1
  405. package/dist/modes/interactive/components/oauth-selector.d.ts +0 -31
  406. package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
  407. package/dist/modes/interactive/components/oauth-selector.js +0 -165
  408. package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
  409. package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -42
  410. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
  411. package/dist/modes/interactive/components/scoped-models-selector.js +0 -290
  412. package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
  413. package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
  414. package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
  415. package/dist/modes/interactive/components/session-selector-search.js +0 -155
  416. package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
  417. package/dist/modes/interactive/components/session-selector.d.ts +0 -96
  418. package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
  419. package/dist/modes/interactive/components/session-selector.js +0 -861
  420. package/dist/modes/interactive/components/session-selector.js.map +0 -1
  421. package/dist/modes/interactive/components/settings-selector.d.ts +0 -69
  422. package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
  423. package/dist/modes/interactive/components/settings-selector.js +0 -390
  424. package/dist/modes/interactive/components/settings-selector.js.map +0 -1
  425. package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
  426. package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
  427. package/dist/modes/interactive/components/show-images-selector.js +0 -39
  428. package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
  429. package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
  430. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
  431. package/dist/modes/interactive/components/skill-invocation-message.js +0 -47
  432. package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
  433. package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
  434. package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
  435. package/dist/modes/interactive/components/theme-selector.js +0 -50
  436. package/dist/modes/interactive/components/theme-selector.js.map +0 -1
  437. package/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
  438. package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
  439. package/dist/modes/interactive/components/thinking-selector.js +0 -51
  440. package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
  441. package/dist/modes/interactive/components/tool-execution.d.ts +0 -63
  442. package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
  443. package/dist/modes/interactive/components/tool-execution.js +0 -295
  444. package/dist/modes/interactive/components/tool-execution.js.map +0 -1
  445. package/dist/modes/interactive/components/tree-selector.d.ts +0 -89
  446. package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
  447. package/dist/modes/interactive/components/tree-selector.js +0 -1093
  448. package/dist/modes/interactive/components/tree-selector.js.map +0 -1
  449. package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
  450. package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
  451. package/dist/modes/interactive/components/user-message-selector.js +0 -114
  452. package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
  453. package/dist/modes/interactive/components/user-message.d.ts +0 -10
  454. package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
  455. package/dist/modes/interactive/components/user-message.js +0 -29
  456. package/dist/modes/interactive/components/user-message.js.map +0 -1
  457. package/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
  458. package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
  459. package/dist/modes/interactive/components/visual-truncate.js +0 -33
  460. package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
  461. package/dist/modes/interactive/interactive-mode.d.ts +0 -373
  462. package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
  463. package/dist/modes/interactive/interactive-mode.js +0 -4750
  464. package/dist/modes/interactive/interactive-mode.js.map +0 -1
  465. package/dist/modes/interactive/theme/dark.json +0 -86
  466. package/dist/modes/interactive/theme/light.json +0 -85
  467. package/dist/modes/interactive/theme/theme-schema.json +0 -335
  468. package/dist/modes/interactive/theme/theme.d.ts +0 -100
  469. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  470. package/dist/modes/interactive/theme/theme.js +0 -1015
  471. package/dist/modes/interactive/theme/theme.js.map +0 -1
  472. package/dist/modes/print-mode.d.ts +0 -28
  473. package/dist/modes/print-mode.d.ts.map +0 -1
  474. package/dist/modes/print-mode.js +0 -131
  475. package/dist/modes/print-mode.js.map +0 -1
  476. package/dist/modes/rpc/jsonl.d.ts +0 -17
  477. package/dist/modes/rpc/jsonl.d.ts.map +0 -1
  478. package/dist/modes/rpc/jsonl.js +0 -49
  479. package/dist/modes/rpc/jsonl.js.map +0 -1
  480. package/dist/modes/rpc/rpc-client.d.ts +0 -228
  481. package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
  482. package/dist/modes/rpc/rpc-client.js +0 -416
  483. package/dist/modes/rpc/rpc-client.js.map +0 -1
  484. package/dist/modes/rpc/rpc-mode.d.ts +0 -20
  485. package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
  486. package/dist/modes/rpc/rpc-mode.js +0 -609
  487. package/dist/modes/rpc/rpc-mode.js.map +0 -1
  488. package/dist/modes/rpc/rpc-types.d.ts +0 -428
  489. package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
  490. package/dist/modes/rpc/rpc-types.js +0 -8
  491. package/dist/modes/rpc/rpc-types.js.map +0 -1
  492. package/dist/modes/web/web-mode.d.ts +0 -3
  493. package/dist/modes/web/web-mode.d.ts.map +0 -1
  494. package/dist/modes/web/web-mode.js +0 -244
  495. package/dist/modes/web/web-mode.js.map +0 -1
  496. package/dist/package-manager-cli.d.ts +0 -4
  497. package/dist/package-manager-cli.d.ts.map +0 -1
  498. package/dist/package-manager-cli.js +0 -515
  499. package/dist/package-manager-cli.js.map +0 -1
  500. package/dist/utils/ansi.d.ts +0 -2
  501. package/dist/utils/ansi.d.ts.map +0 -1
  502. package/dist/utils/ansi.js +0 -52
  503. package/dist/utils/ansi.js.map +0 -1
  504. package/dist/utils/changelog.d.ts +0 -21
  505. package/dist/utils/changelog.d.ts.map +0 -1
  506. package/dist/utils/changelog.js +0 -87
  507. package/dist/utils/changelog.js.map +0 -1
  508. package/dist/utils/child-process.d.ts +0 -15
  509. package/dist/utils/child-process.d.ts.map +0 -1
  510. package/dist/utils/child-process.js +0 -88
  511. package/dist/utils/child-process.js.map +0 -1
  512. package/dist/utils/clipboard-image.d.ts +0 -11
  513. package/dist/utils/clipboard-image.d.ts.map +0 -1
  514. package/dist/utils/clipboard-image.js +0 -245
  515. package/dist/utils/clipboard-image.js.map +0 -1
  516. package/dist/utils/clipboard-native.d.ts +0 -8
  517. package/dist/utils/clipboard-native.d.ts.map +0 -1
  518. package/dist/utils/clipboard-native.js +0 -14
  519. package/dist/utils/clipboard-native.js.map +0 -1
  520. package/dist/utils/clipboard.d.ts +0 -2
  521. package/dist/utils/clipboard.d.ts.map +0 -1
  522. package/dist/utils/clipboard.js +0 -117
  523. package/dist/utils/clipboard.js.map +0 -1
  524. package/dist/utils/exif-orientation.d.ts +0 -5
  525. package/dist/utils/exif-orientation.d.ts.map +0 -1
  526. package/dist/utils/exif-orientation.js +0 -158
  527. package/dist/utils/exif-orientation.js.map +0 -1
  528. package/dist/utils/frontmatter.d.ts +0 -8
  529. package/dist/utils/frontmatter.d.ts.map +0 -1
  530. package/dist/utils/frontmatter.js +0 -26
  531. package/dist/utils/frontmatter.js.map +0 -1
  532. package/dist/utils/fs-watch.d.ts +0 -5
  533. package/dist/utils/fs-watch.d.ts.map +0 -1
  534. package/dist/utils/fs-watch.js +0 -25
  535. package/dist/utils/fs-watch.js.map +0 -1
  536. package/dist/utils/git.d.ts +0 -26
  537. package/dist/utils/git.d.ts.map +0 -1
  538. package/dist/utils/git.js +0 -163
  539. package/dist/utils/git.js.map +0 -1
  540. package/dist/utils/html.d.ts +0 -7
  541. package/dist/utils/html.d.ts.map +0 -1
  542. package/dist/utils/html.js +0 -40
  543. package/dist/utils/html.js.map +0 -1
  544. package/dist/utils/image-convert.d.ts +0 -9
  545. package/dist/utils/image-convert.d.ts.map +0 -1
  546. package/dist/utils/image-convert.js +0 -39
  547. package/dist/utils/image-convert.js.map +0 -1
  548. package/dist/utils/image-resize.d.ts +0 -36
  549. package/dist/utils/image-resize.d.ts.map +0 -1
  550. package/dist/utils/image-resize.js +0 -137
  551. package/dist/utils/image-resize.js.map +0 -1
  552. package/dist/utils/mime.d.ts +0 -3
  553. package/dist/utils/mime.d.ts.map +0 -1
  554. package/dist/utils/mime.js +0 -69
  555. package/dist/utils/mime.js.map +0 -1
  556. package/dist/utils/paths.d.ts +0 -17
  557. package/dist/utils/paths.d.ts.map +0 -1
  558. package/dist/utils/paths.js +0 -66
  559. package/dist/utils/paths.js.map +0 -1
  560. package/dist/utils/photon.d.ts +0 -21
  561. package/dist/utils/photon.d.ts.map +0 -1
  562. package/dist/utils/photon.js +0 -121
  563. package/dist/utils/photon.js.map +0 -1
  564. package/dist/utils/pi-user-agent.d.ts +0 -2
  565. package/dist/utils/pi-user-agent.d.ts.map +0 -1
  566. package/dist/utils/pi-user-agent.js +0 -5
  567. package/dist/utils/pi-user-agent.js.map +0 -1
  568. package/dist/utils/shell.d.ts +0 -30
  569. package/dist/utils/shell.d.ts.map +0 -1
  570. package/dist/utils/shell.js +0 -195
  571. package/dist/utils/shell.js.map +0 -1
  572. package/dist/utils/sleep.d.ts +0 -5
  573. package/dist/utils/sleep.d.ts.map +0 -1
  574. package/dist/utils/sleep.js +0 -17
  575. package/dist/utils/sleep.js.map +0 -1
  576. package/dist/utils/syntax-highlight.d.ts +0 -12
  577. package/dist/utils/syntax-highlight.d.ts.map +0 -1
  578. package/dist/utils/syntax-highlight.js +0 -118
  579. package/dist/utils/syntax-highlight.js.map +0 -1
  580. package/dist/utils/tools-manager.d.ts +0 -3
  581. package/dist/utils/tools-manager.d.ts.map +0 -1
  582. package/dist/utils/tools-manager.js +0 -328
  583. package/dist/utils/tools-manager.js.map +0 -1
  584. package/dist/utils/version-check.d.ts +0 -15
  585. package/dist/utils/version-check.d.ts.map +0 -1
  586. package/dist/utils/version-check.js +0 -82
  587. package/dist/utils/version-check.js.map +0 -1
  588. package/dist/utils/windows-self-update.d.ts +0 -3
  589. package/dist/utils/windows-self-update.d.ts.map +0 -1
  590. package/dist/utils/windows-self-update.js +0 -77
  591. package/dist/utils/windows-self-update.js.map +0 -1
@@ -1,17 +0,0 @@
1
- /**
2
- * Resolve a path to its canonical (real) form, following symlinks.
3
- * Falls back to the raw path if resolution fails (e.g. the target does
4
- * not exist yet), so that callers never crash on missing filesystem
5
- * entries.
6
- */
7
- export declare function canonicalizePath(path: string): string;
8
- /**
9
- * Returns true if the value is NOT a package source (npm:, git:, etc.)
10
- * or a URL protocol. Bare names and relative paths without ./ prefix
11
- * are considered local.
12
- */
13
- export declare function isLocalPath(value: string): boolean;
14
- export declare function getCwdRelativePath(filePath: string, cwd: string): string | undefined;
15
- export declare function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string;
16
- export declare function markPathIgnoredByCloudSync(path: string): void;
17
- //# sourceMappingURL=paths.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAclD;AAMD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASpF;AAED,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAe7D","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport { spawnProcessSync } from \"./child-process.ts\";\n\n/**\n * Resolve a path to its canonical (real) form, following symlinks.\n * Falls back to the raw path if resolution fails (e.g. the target does\n * not exist yet), so that callers never crash on missing filesystem\n * entries.\n */\nexport function canonicalizePath(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\n/**\n * Returns true if the value is NOT a package source (npm:, git:, etc.)\n * or a URL protocol. Bare names and relative paths without ./ prefix\n * are considered local.\n */\nexport function isLocalPath(value: string): boolean {\n\tconst trimmed = value.trim();\n\t// Known non-local prefixes\n\tif (\n\t\ttrimmed.startsWith(\"npm:\") ||\n\t\ttrimmed.startsWith(\"git:\") ||\n\t\ttrimmed.startsWith(\"github:\") ||\n\t\ttrimmed.startsWith(\"http:\") ||\n\t\ttrimmed.startsWith(\"https:\") ||\n\t\ttrimmed.startsWith(\"ssh:\")\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nfunction resolveAgainstCwd(filePath: string, cwd: string): string {\n\treturn isAbsolute(filePath) ? resolvePath(filePath) : resolvePath(cwd, filePath);\n}\n\nexport function getCwdRelativePath(filePath: string, cwd: string): string | undefined {\n\tconst resolvedCwd = resolvePath(cwd);\n\tconst resolvedPath = resolveAgainstCwd(filePath, resolvedCwd);\n\tconst relativePath = relative(resolvedCwd, resolvedPath);\n\tconst isInsideCwd =\n\t\trelativePath === \"\" ||\n\t\t(relativePath !== \"..\" && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath));\n\n\treturn isInsideCwd ? relativePath || \".\" : undefined;\n}\n\nexport function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string {\n\tconst absolutePath = resolveAgainstCwd(filePath, cwd);\n\treturn (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join(\"/\");\n}\n\nexport function markPathIgnoredByCloudSync(path: string): void {\n\tconst attrs =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"com.dropbox.ignored\", \"com.apple.fileprovider.ignore#P\"]\n\t\t\t: process.platform === \"linux\"\n\t\t\t\t? [\"user.com.dropbox.ignored\"]\n\t\t\t\t: [];\n\n\tfor (const attr of attrs) {\n\t\tif (process.platform === \"darwin\") {\n\t\t\tspawnProcessSync(\"xattr\", [\"-w\", attr, \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t} else {\n\t\t\tspawnProcessSync(\"setfattr\", [\"-n\", attr, \"-v\", \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t}\n\t}\n}\n"]}
@@ -1,66 +0,0 @@
1
- import { realpathSync } from "node:fs";
2
- import { isAbsolute, relative, resolve as resolvePath, sep } from "node:path";
3
- import { spawnProcessSync } from "./child-process.js";
4
- /**
5
- * Resolve a path to its canonical (real) form, following symlinks.
6
- * Falls back to the raw path if resolution fails (e.g. the target does
7
- * not exist yet), so that callers never crash on missing filesystem
8
- * entries.
9
- */
10
- export function canonicalizePath(path) {
11
- try {
12
- return realpathSync(path);
13
- }
14
- catch {
15
- return path;
16
- }
17
- }
18
- /**
19
- * Returns true if the value is NOT a package source (npm:, git:, etc.)
20
- * or a URL protocol. Bare names and relative paths without ./ prefix
21
- * are considered local.
22
- */
23
- export function isLocalPath(value) {
24
- const trimmed = value.trim();
25
- // Known non-local prefixes
26
- if (trimmed.startsWith("npm:") ||
27
- trimmed.startsWith("git:") ||
28
- trimmed.startsWith("github:") ||
29
- trimmed.startsWith("http:") ||
30
- trimmed.startsWith("https:") ||
31
- trimmed.startsWith("ssh:")) {
32
- return false;
33
- }
34
- return true;
35
- }
36
- function resolveAgainstCwd(filePath, cwd) {
37
- return isAbsolute(filePath) ? resolvePath(filePath) : resolvePath(cwd, filePath);
38
- }
39
- export function getCwdRelativePath(filePath, cwd) {
40
- const resolvedCwd = resolvePath(cwd);
41
- const resolvedPath = resolveAgainstCwd(filePath, resolvedCwd);
42
- const relativePath = relative(resolvedCwd, resolvedPath);
43
- const isInsideCwd = relativePath === "" ||
44
- (relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath));
45
- return isInsideCwd ? relativePath || "." : undefined;
46
- }
47
- export function formatPathRelativeToCwdOrAbsolute(filePath, cwd) {
48
- const absolutePath = resolveAgainstCwd(filePath, cwd);
49
- return (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join("/");
50
- }
51
- export function markPathIgnoredByCloudSync(path) {
52
- const attrs = process.platform === "darwin"
53
- ? ["com.dropbox.ignored", "com.apple.fileprovider.ignore#P"]
54
- : process.platform === "linux"
55
- ? ["user.com.dropbox.ignored"]
56
- : [];
57
- for (const attr of attrs) {
58
- if (process.platform === "darwin") {
59
- spawnProcessSync("xattr", ["-w", attr, "1", path], { encoding: "utf-8", stdio: "ignore" });
60
- }
61
- else {
62
- spawnProcessSync("setfattr", ["-n", attr, "-v", "1", path], { encoding: "utf-8", stdio: "ignore" });
63
- }
64
- }
65
- }
66
- //# sourceMappingURL=paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAU;IACtD,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AAAA,CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAW;IACnD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,2BAA2B;IAC3B,IACC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1B,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;QAC1B,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;QAC7B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;QAC3B,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC5B,OAAO,CAAC,UAAU,CAAC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qBAAqB,EAAE,iCAAiC,CAAC;QAC5D,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO;YAC7B,CAAC,CAAC,CAAC,0BAA0B,CAAC;YAC9B,CAAC,CAAC,EAAE,CAAC;IAER,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACnC,gBAAgB,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACP,gBAAgB,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrG,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport { isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport { spawnProcessSync } from \"./child-process.ts\";\n\n/**\n * Resolve a path to its canonical (real) form, following symlinks.\n * Falls back to the raw path if resolution fails (e.g. the target does\n * not exist yet), so that callers never crash on missing filesystem\n * entries.\n */\nexport function canonicalizePath(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\n/**\n * Returns true if the value is NOT a package source (npm:, git:, etc.)\n * or a URL protocol. Bare names and relative paths without ./ prefix\n * are considered local.\n */\nexport function isLocalPath(value: string): boolean {\n\tconst trimmed = value.trim();\n\t// Known non-local prefixes\n\tif (\n\t\ttrimmed.startsWith(\"npm:\") ||\n\t\ttrimmed.startsWith(\"git:\") ||\n\t\ttrimmed.startsWith(\"github:\") ||\n\t\ttrimmed.startsWith(\"http:\") ||\n\t\ttrimmed.startsWith(\"https:\") ||\n\t\ttrimmed.startsWith(\"ssh:\")\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nfunction resolveAgainstCwd(filePath: string, cwd: string): string {\n\treturn isAbsolute(filePath) ? resolvePath(filePath) : resolvePath(cwd, filePath);\n}\n\nexport function getCwdRelativePath(filePath: string, cwd: string): string | undefined {\n\tconst resolvedCwd = resolvePath(cwd);\n\tconst resolvedPath = resolveAgainstCwd(filePath, resolvedCwd);\n\tconst relativePath = relative(resolvedCwd, resolvedPath);\n\tconst isInsideCwd =\n\t\trelativePath === \"\" ||\n\t\t(relativePath !== \"..\" && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath));\n\n\treturn isInsideCwd ? relativePath || \".\" : undefined;\n}\n\nexport function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string {\n\tconst absolutePath = resolveAgainstCwd(filePath, cwd);\n\treturn (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join(\"/\");\n}\n\nexport function markPathIgnoredByCloudSync(path: string): void {\n\tconst attrs =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"com.dropbox.ignored\", \"com.apple.fileprovider.ignore#P\"]\n\t\t\t: process.platform === \"linux\"\n\t\t\t\t? [\"user.com.dropbox.ignored\"]\n\t\t\t\t: [];\n\n\tfor (const attr of attrs) {\n\t\tif (process.platform === \"darwin\") {\n\t\t\tspawnProcessSync(\"xattr\", [\"-w\", attr, \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t} else {\n\t\t\tspawnProcessSync(\"setfattr\", [\"-n\", attr, \"-v\", \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t}\n\t}\n}\n"]}
@@ -1,21 +0,0 @@
1
- /**
2
- * Photon image processing wrapper.
3
- *
4
- * This module provides a unified interface to @silvia-odwyer/photon-node that works in:
5
- * 1. Node.js (development, npm run build)
6
- * 2. Bun compiled binaries (standalone distribution)
7
- *
8
- * The challenge: photon-node's CJS entry uses fs.readFileSync(__dirname + '/photon_rs_bg.wasm')
9
- * which bakes the build machine's absolute path into Bun compiled binaries.
10
- *
11
- * Solution:
12
- * 1. Patch fs.readFileSync to redirect missing photon_rs_bg.wasm reads
13
- * 2. Copy photon_rs_bg.wasm next to the executable in build:binary
14
- */
15
- export type { PhotonImage as PhotonImageType } from "@silvia-odwyer/photon-node";
16
- /**
17
- * Load the photon module asynchronously.
18
- * Returns cached module on subsequent calls.
19
- */
20
- export declare function loadPhoton(): Promise<typeof import("@silvia-odwyer/photon-node") | null>;
21
- //# sourceMappingURL=photon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"photon.d.ts","sourceRoot":"","sources":["../../src/utils/photon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH,YAAY,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAuFjF;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,cAAc,4BAA4B,CAAC,GAAG,IAAI,CAAC,CAuB9F","sourcesContent":["/**\n * Photon image processing wrapper.\n *\n * This module provides a unified interface to @silvia-odwyer/photon-node that works in:\n * 1. Node.js (development, npm run build)\n * 2. Bun compiled binaries (standalone distribution)\n *\n * The challenge: photon-node's CJS entry uses fs.readFileSync(__dirname + '/photon_rs_bg.wasm')\n * which bakes the build machine's absolute path into Bun compiled binaries.\n *\n * Solution:\n * 1. Patch fs.readFileSync to redirect missing photon_rs_bg.wasm reads\n * 2. Copy photon_rs_bg.wasm next to the executable in build:binary\n */\n\nimport type { PathOrFileDescriptor } from \"fs\";\nimport { createRequire } from \"module\";\nimport * as path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst require = createRequire(import.meta.url);\nconst fs = require(\"fs\") as typeof import(\"fs\");\n\n// Re-export types from the main package\nexport type { PhotonImage as PhotonImageType } from \"@silvia-odwyer/photon-node\";\n\ntype ReadFileSync = typeof fs.readFileSync;\n\nconst WASM_FILENAME = \"photon_rs_bg.wasm\";\n\n// Lazy-loaded photon module\nlet photonModule: typeof import(\"@silvia-odwyer/photon-node\") | null = null;\nlet loadPromise: Promise<typeof import(\"@silvia-odwyer/photon-node\") | null> | null = null;\n\nfunction pathOrNull(file: PathOrFileDescriptor): string | null {\n\tif (typeof file === \"string\") {\n\t\treturn file;\n\t}\n\tif (file instanceof URL) {\n\t\treturn fileURLToPath(file);\n\t}\n\treturn null;\n}\n\nfunction getFallbackWasmPaths(): string[] {\n\tconst execDir = path.dirname(process.execPath);\n\treturn [\n\t\tpath.join(execDir, WASM_FILENAME),\n\t\tpath.join(execDir, \"photon\", WASM_FILENAME),\n\t\tpath.join(process.cwd(), WASM_FILENAME),\n\t];\n}\n\nfunction patchPhotonWasmRead(): () => void {\n\tconst originalReadFileSync: ReadFileSync = fs.readFileSync.bind(fs);\n\tconst fallbackPaths = getFallbackWasmPaths();\n\tconst mutableFs = fs as { readFileSync: ReadFileSync };\n\n\tconst patchedReadFileSync: ReadFileSync = ((...args: Parameters<ReadFileSync>) => {\n\t\tconst [file, options] = args;\n\t\tconst resolvedPath = pathOrNull(file);\n\n\t\tif (resolvedPath?.endsWith(WASM_FILENAME)) {\n\t\t\ttry {\n\t\t\t\treturn originalReadFileSync(...args);\n\t\t\t} catch (error) {\n\t\t\t\tconst err = error as NodeJS.ErrnoException;\n\t\t\t\tif (err?.code && err.code !== \"ENOENT\") {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\tfor (const fallbackPath of fallbackPaths) {\n\t\t\t\t\tif (!fs.existsSync(fallbackPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (options === undefined) {\n\t\t\t\t\t\treturn originalReadFileSync(fallbackPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn originalReadFileSync(fallbackPath, options);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn originalReadFileSync(...args);\n\t}) as ReadFileSync;\n\n\ttry {\n\t\tmutableFs.readFileSync = patchedReadFileSync;\n\t} catch {\n\t\tObject.defineProperty(fs, \"readFileSync\", {\n\t\t\tvalue: patchedReadFileSync,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\n\treturn () => {\n\t\ttry {\n\t\t\tmutableFs.readFileSync = originalReadFileSync;\n\t\t} catch {\n\t\t\tObject.defineProperty(fs, \"readFileSync\", {\n\t\t\t\tvalue: originalReadFileSync,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t};\n}\n\n/**\n * Load the photon module asynchronously.\n * Returns cached module on subsequent calls.\n */\nexport async function loadPhoton(): Promise<typeof import(\"@silvia-odwyer/photon-node\") | null> {\n\tif (photonModule) {\n\t\treturn photonModule;\n\t}\n\n\tif (loadPromise) {\n\t\treturn loadPromise;\n\t}\n\n\tloadPromise = (async () => {\n\t\tconst restoreReadFileSync = patchPhotonWasmRead();\n\t\ttry {\n\t\t\tphotonModule = await import(\"@silvia-odwyer/photon-node\");\n\t\t\treturn photonModule;\n\t\t} catch {\n\t\t\tphotonModule = null;\n\t\t\treturn photonModule;\n\t\t} finally {\n\t\t\trestoreReadFileSync();\n\t\t}\n\t})();\n\n\treturn loadPromise;\n}\n"]}
@@ -1,121 +0,0 @@
1
- /**
2
- * Photon image processing wrapper.
3
- *
4
- * This module provides a unified interface to @silvia-odwyer/photon-node that works in:
5
- * 1. Node.js (development, npm run build)
6
- * 2. Bun compiled binaries (standalone distribution)
7
- *
8
- * The challenge: photon-node's CJS entry uses fs.readFileSync(__dirname + '/photon_rs_bg.wasm')
9
- * which bakes the build machine's absolute path into Bun compiled binaries.
10
- *
11
- * Solution:
12
- * 1. Patch fs.readFileSync to redirect missing photon_rs_bg.wasm reads
13
- * 2. Copy photon_rs_bg.wasm next to the executable in build:binary
14
- */
15
- import { createRequire } from "module";
16
- import * as path from "path";
17
- import { fileURLToPath } from "url";
18
- const require = createRequire(import.meta.url);
19
- const fs = require("fs");
20
- const WASM_FILENAME = "photon_rs_bg.wasm";
21
- // Lazy-loaded photon module
22
- let photonModule = null;
23
- let loadPromise = null;
24
- function pathOrNull(file) {
25
- if (typeof file === "string") {
26
- return file;
27
- }
28
- if (file instanceof URL) {
29
- return fileURLToPath(file);
30
- }
31
- return null;
32
- }
33
- function getFallbackWasmPaths() {
34
- const execDir = path.dirname(process.execPath);
35
- return [
36
- path.join(execDir, WASM_FILENAME),
37
- path.join(execDir, "photon", WASM_FILENAME),
38
- path.join(process.cwd(), WASM_FILENAME),
39
- ];
40
- }
41
- function patchPhotonWasmRead() {
42
- const originalReadFileSync = fs.readFileSync.bind(fs);
43
- const fallbackPaths = getFallbackWasmPaths();
44
- const mutableFs = fs;
45
- const patchedReadFileSync = ((...args) => {
46
- const [file, options] = args;
47
- const resolvedPath = pathOrNull(file);
48
- if (resolvedPath?.endsWith(WASM_FILENAME)) {
49
- try {
50
- return originalReadFileSync(...args);
51
- }
52
- catch (error) {
53
- const err = error;
54
- if (err?.code && err.code !== "ENOENT") {
55
- throw error;
56
- }
57
- for (const fallbackPath of fallbackPaths) {
58
- if (!fs.existsSync(fallbackPath)) {
59
- continue;
60
- }
61
- if (options === undefined) {
62
- return originalReadFileSync(fallbackPath);
63
- }
64
- return originalReadFileSync(fallbackPath, options);
65
- }
66
- throw error;
67
- }
68
- }
69
- return originalReadFileSync(...args);
70
- });
71
- try {
72
- mutableFs.readFileSync = patchedReadFileSync;
73
- }
74
- catch {
75
- Object.defineProperty(fs, "readFileSync", {
76
- value: patchedReadFileSync,
77
- writable: true,
78
- configurable: true,
79
- });
80
- }
81
- return () => {
82
- try {
83
- mutableFs.readFileSync = originalReadFileSync;
84
- }
85
- catch {
86
- Object.defineProperty(fs, "readFileSync", {
87
- value: originalReadFileSync,
88
- writable: true,
89
- configurable: true,
90
- });
91
- }
92
- };
93
- }
94
- /**
95
- * Load the photon module asynchronously.
96
- * Returns cached module on subsequent calls.
97
- */
98
- export async function loadPhoton() {
99
- if (photonModule) {
100
- return photonModule;
101
- }
102
- if (loadPromise) {
103
- return loadPromise;
104
- }
105
- loadPromise = (async () => {
106
- const restoreReadFileSync = patchPhotonWasmRead();
107
- try {
108
- photonModule = await import("@silvia-odwyer/photon-node");
109
- return photonModule;
110
- }
111
- catch {
112
- photonModule = null;
113
- return photonModule;
114
- }
115
- finally {
116
- restoreReadFileSync();
117
- }
118
- })();
119
- return loadPromise;
120
- }
121
- //# sourceMappingURL=photon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"photon.js","sourceRoot":"","sources":["../../src/utils/photon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAwB,CAAC;AAOhD,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C,4BAA4B;AAC5B,IAAI,YAAY,GAAuD,IAAI,CAAC;AAC5E,IAAI,WAAW,GAAuE,IAAI,CAAC;AAE3F,SAAS,UAAU,CAAC,IAA0B,EAAiB;IAC9D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,IAAI,YAAY,GAAG,EAAE,CAAC;QACzB,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ;AAED,SAAS,oBAAoB,GAAa;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO;QACN,IAAI,CAAC,IAAI,CAAC,OAAO,EA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AAW,CAAC;AAAA,CACnB","sourcesContent":["/**\n * Photon image processing wrapper.\n *\n * This module provides a unified interface to @silvia-odwyer/photon-node that works in:\n * 1. Node.js (development, npm run build)\n * 2. Bun compiled binaries (standalone distribution)\n *\n * The challenge: photon-node's CJS entry uses fs.readFileSync(__dirname + '/photon_rs_bg.wasm')\n * which bakes the build machine's absolute path into Bun compiled binaries.\n *\n * Solution:\n * 1. Patch fs.readFileSync to redirect missing photon_rs_bg.wasm reads\n * 2. Copy photon_rs_bg.wasm next to the executable in build:binary\n */\n\nimport type { PathOrFileDescriptor } from \"fs\";\nimport { createRequire } from \"module\";\nimport * as path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst require = createRequire(import.meta.url);\nconst fs = require(\"fs\") as typeof import(\"fs\");\n\n// Re-export types from the main package\nexport type { PhotonImage as PhotonImageType } from \"@silvia-odwyer/photon-node\";\n\ntype ReadFileSync = typeof fs.readFileSync;\n\nconst WASM_FILENAME = \"photon_rs_bg.wasm\";\n\n// Lazy-loaded photon module\nlet photonModule: typeof import(\"@silvia-odwyer/photon-node\") | null = null;\nlet loadPromise: Promise<typeof import(\"@silvia-odwyer/photon-node\") | null> | null = null;\n\nfunction pathOrNull(file: PathOrFileDescriptor): string | null {\n\tif (typeof file === \"string\") {\n\t\treturn file;\n\t}\n\tif (file instanceof URL) {\n\t\treturn fileURLToPath(file);\n\t}\n\treturn null;\n}\n\nfunction getFallbackWasmPaths(): string[] {\n\tconst execDir = path.dirname(process.execPath);\n\treturn [\n\t\tpath.join(execDir, WASM_FILENAME),\n\t\tpath.join(execDir, \"photon\", WASM_FILENAME),\n\t\tpath.join(process.cwd(), WASM_FILENAME),\n\t];\n}\n\nfunction patchPhotonWasmRead(): () => void {\n\tconst originalReadFileSync: ReadFileSync = fs.readFileSync.bind(fs);\n\tconst fallbackPaths = getFallbackWasmPaths();\n\tconst mutableFs = fs as { readFileSync: ReadFileSync };\n\n\tconst patchedReadFileSync: ReadFileSync = ((...args: Parameters<ReadFileSync>) => {\n\t\tconst [file, options] = args;\n\t\tconst resolvedPath = pathOrNull(file);\n\n\t\tif (resolvedPath?.endsWith(WASM_FILENAME)) {\n\t\t\ttry {\n\t\t\t\treturn originalReadFileSync(...args);\n\t\t\t} catch (error) {\n\t\t\t\tconst err = error as NodeJS.ErrnoException;\n\t\t\t\tif (err?.code && err.code !== \"ENOENT\") {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\n\t\t\t\tfor (const fallbackPath of fallbackPaths) {\n\t\t\t\t\tif (!fs.existsSync(fallbackPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (options === undefined) {\n\t\t\t\t\t\treturn originalReadFileSync(fallbackPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn originalReadFileSync(fallbackPath, options);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn originalReadFileSync(...args);\n\t}) as ReadFileSync;\n\n\ttry {\n\t\tmutableFs.readFileSync = patchedReadFileSync;\n\t} catch {\n\t\tObject.defineProperty(fs, \"readFileSync\", {\n\t\t\tvalue: patchedReadFileSync,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\n\treturn () => {\n\t\ttry {\n\t\t\tmutableFs.readFileSync = originalReadFileSync;\n\t\t} catch {\n\t\t\tObject.defineProperty(fs, \"readFileSync\", {\n\t\t\t\tvalue: originalReadFileSync,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t};\n}\n\n/**\n * Load the photon module asynchronously.\n * Returns cached module on subsequent calls.\n */\nexport async function loadPhoton(): Promise<typeof import(\"@silvia-odwyer/photon-node\") | null> {\n\tif (photonModule) {\n\t\treturn photonModule;\n\t}\n\n\tif (loadPromise) {\n\t\treturn loadPromise;\n\t}\n\n\tloadPromise = (async () => {\n\t\tconst restoreReadFileSync = patchPhotonWasmRead();\n\t\ttry {\n\t\t\tphotonModule = await import(\"@silvia-odwyer/photon-node\");\n\t\t\treturn photonModule;\n\t\t} catch {\n\t\t\tphotonModule = null;\n\t\t\treturn photonModule;\n\t\t} finally {\n\t\t\trestoreReadFileSync();\n\t\t}\n\t})();\n\n\treturn loadPromise;\n}\n"]}
@@ -1,2 +0,0 @@
1
- export declare function getPiUserAgent(version: string): string;
2
- //# sourceMappingURL=pi-user-agent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pi-user-agent.d.ts","sourceRoot":"","sources":["../../src/utils/pi-user-agent.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGtD","sourcesContent":["export function getPiUserAgent(version: string): string {\n\tconst runtime = process.versions.bun ? `bun/${process.versions.bun}` : `node/${process.version}`;\n\treturn `pi/${version} (${process.platform}; ${runtime}; ${process.arch})`;\n}\n"]}
@@ -1,5 +0,0 @@
1
- export function getPiUserAgent(version) {
2
- const runtime = process.versions.bun ? `bun/${process.versions.bun}` : `node/${process.version}`;
3
- return `pi/${version} (${process.platform}; ${runtime}; ${process.arch})`;
4
- }
5
- //# sourceMappingURL=pi-user-agent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pi-user-agent.js","sourceRoot":"","sources":["../../src/utils/pi-user-agent.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,OAAe,EAAU;IACvD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,OAAO,CAAC,OAAO,EAAE,CAAC;IACjG,OAAO,MAAM,OAAO,KAAK,OAAO,CAAC,QAAQ,KAAK,OAAO,KAAK,OAAO,CAAC,IAAI,GAAG,CAAC;AAAA,CAC1E","sourcesContent":["export function getPiUserAgent(version: string): string {\n\tconst runtime = process.versions.bun ? `bun/${process.versions.bun}` : `node/${process.version}`;\n\treturn `pi/${version} (${process.platform}; ${runtime}; ${process.arch})`;\n}\n"]}
@@ -1,30 +0,0 @@
1
- export interface ShellConfig {
2
- shell: string;
3
- args: string[];
4
- }
5
- /**
6
- * Resolve shell configuration based on platform and an optional explicit shell path.
7
- * Resolution order:
8
- * 1. User-specified shellPath
9
- * 2. On Windows: Git Bash in known locations, then bash on PATH
10
- * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh
11
- */
12
- export declare function getShellConfig(customShellPath?: string): ShellConfig;
13
- export declare function getShellEnv(): NodeJS.ProcessEnv;
14
- /**
15
- * Sanitize binary output for display/storage.
16
- * Removes characters that crash string-width or cause display issues:
17
- * - Control characters (except tab, newline, carriage return)
18
- * - Lone surrogates
19
- * - Unicode Format characters (crash string-width due to a bug)
20
- * - Characters with undefined code points
21
- */
22
- export declare function sanitizeBinaryOutput(str: string): string;
23
- export declare function trackDetachedChildPid(pid: number): void;
24
- export declare function untrackDetachedChildPid(pid: number): void;
25
- export declare function killTrackedDetachedChildren(): void;
26
- /**
27
- * Kill a process and all its children (cross-platform)
28
- */
29
- export declare function killProcessTree(pid: number): void;
30
- //# sourceMappingURL=shell.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AAyCD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAqDpE;AAED,wBAAgB,WAAW,IAAI,MAAM,CAAC,UAAU,CAY/C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8BxD;AAQD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEzD;AAED,wBAAgB,2BAA2B,IAAI,IAAI,CAKlD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAyBjD","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { delimiter } from \"node:path\";\nimport { spawn, spawnSync } from \"child_process\";\nimport { getBinDir } from \"../config.ts\";\n\nexport interface ShellConfig {\n\tshell: string;\n\targs: string[];\n}\n\n/**\n * Find bash executable on PATH (cross-platform)\n */\nfunction findBashOnPath(): string | null {\n\tif (process.platform === \"win32\") {\n\t\t// Windows: Use 'where' and verify file exists (where can return non-existent paths)\n\t\ttry {\n\t\t\tconst result = spawnSync(\"where\", [\"bash.exe\"], {\n\t\t\t\tencoding: \"utf-8\",\n\t\t\t\ttimeout: 5000,\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (result.status === 0 && result.stdout) {\n\t\t\t\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\t\t\t\tif (firstMatch && existsSync(firstMatch)) {\n\t\t\t\t\treturn firstMatch;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore errors\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Unix: Use 'which' and trust its output (handles Termux and special filesystems)\n\ttry {\n\t\tconst result = spawnSync(\"which\", [\"bash\"], { encoding: \"utf-8\", timeout: 5000 });\n\t\tif (result.status === 0 && result.stdout) {\n\t\t\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\t\t\tif (firstMatch) {\n\t\t\t\treturn firstMatch;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\treturn null;\n}\n\n/**\n * Resolve shell configuration based on platform and an optional explicit shell path.\n * Resolution order:\n * 1. User-specified shellPath\n * 2. On Windows: Git Bash in known locations, then bash on PATH\n * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh\n */\nexport function getShellConfig(customShellPath?: string): ShellConfig {\n\t// 1. Check user-specified shell path\n\tif (customShellPath) {\n\t\tif (existsSync(customShellPath)) {\n\t\t\treturn { shell: customShellPath, args: [\"-c\"] };\n\t\t}\n\t\tthrow new Error(`Custom shell path not found: ${customShellPath}`);\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\t// 2. Try Git Bash in known locations\n\t\tconst paths: string[] = [];\n\t\tconst programFiles = process.env.ProgramFiles;\n\t\tif (programFiles) {\n\t\t\tpaths.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\t\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\t\tif (programFilesX86) {\n\t\t\tpaths.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\n\t\tfor (const path of paths) {\n\t\t\tif (existsSync(path)) {\n\t\t\t\treturn { shell: path, args: [\"-c\"] };\n\t\t\t}\n\t\t}\n\n\t\t// 3. Fallback: search bash.exe on PATH (Cygwin, MSYS2, WSL, etc.)\n\t\tconst bashOnPath = findBashOnPath();\n\t\tif (bashOnPath) {\n\t\t\treturn { shell: bashOnPath, args: [\"-c\"] };\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No bash shell found. Options:\\n` +\n\t\t\t\t` 1. Install Git for Windows: https://git-scm.com/download/win\\n` +\n\t\t\t\t` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\\n` +\n\t\t\t\t\" 3. Set shellPath in settings.json\\n\\n\" +\n\t\t\t\t`Searched Git Bash in:\\n${paths.map((p) => ` ${p}`).join(\"\\n\")}`,\n\t\t);\n\t}\n\n\t// Unix: try /bin/bash, then bash on PATH, then fallback to sh\n\tif (existsSync(\"/bin/bash\")) {\n\t\treturn { shell: \"/bin/bash\", args: [\"-c\"] };\n\t}\n\n\tconst bashOnPath = findBashOnPath();\n\tif (bashOnPath) {\n\t\treturn { shell: bashOnPath, args: [\"-c\"] };\n\t}\n\n\treturn { shell: \"sh\", args: [\"-c\"] };\n}\n\nexport function getShellEnv(): NodeJS.ProcessEnv {\n\tconst binDir = getBinDir();\n\tconst pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === \"path\") ?? \"PATH\";\n\tconst currentPath = process.env[pathKey] ?? \"\";\n\tconst pathEntries = currentPath.split(delimiter).filter(Boolean);\n\tconst hasBinDir = pathEntries.includes(binDir);\n\tconst updatedPath = hasBinDir ? currentPath : [binDir, currentPath].filter(Boolean).join(delimiter);\n\n\treturn {\n\t\t...process.env,\n\t\t[pathKey]: updatedPath,\n\t};\n}\n\n/**\n * Sanitize binary output for display/storage.\n * Removes characters that crash string-width or cause display issues:\n * - Control characters (except tab, newline, carriage return)\n * - Lone surrogates\n * - Unicode Format characters (crash string-width due to a bug)\n * - Characters with undefined code points\n */\nexport function sanitizeBinaryOutput(str: string): string {\n\t// Use Array.from to properly iterate over code points (not code units)\n\t// This handles surrogate pairs correctly and catches edge cases where\n\t// codePointAt() might return undefined\n\treturn Array.from(str)\n\t\t.filter((char) => {\n\t\t\t// Filter out characters that cause string-width to crash\n\t\t\t// This includes:\n\t\t\t// - Unicode format characters\n\t\t\t// - Lone surrogates (already filtered by Array.from)\n\t\t\t// - Control chars except \\t \\n \\r\n\t\t\t// - Characters with undefined code points\n\n\t\t\tconst code = char.codePointAt(0);\n\n\t\t\t// Skip if code point is undefined (edge case with invalid strings)\n\t\t\tif (code === undefined) return false;\n\n\t\t\t// Allow tab, newline, carriage return\n\t\t\tif (code === 0x09 || code === 0x0a || code === 0x0d) return true;\n\n\t\t\t// Filter out control characters (0x00-0x1F, except 0x09, 0x0a, 0x0x0d)\n\t\t\tif (code <= 0x1f) return false;\n\n\t\t\t// Filter out Unicode format characters\n\t\t\tif (code >= 0xfff9 && code <= 0xfffb) return false;\n\n\t\t\treturn true;\n\t\t})\n\t\t.join(\"\");\n}\n\n/**\n * Detached child processes must be tracked so they can be killed on parent\n * shutdown signals (SIGHUP/SIGTERM).\n */\nconst trackedDetachedChildPids = new Set<number>();\n\nexport function trackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.add(pid);\n}\n\nexport function untrackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.delete(pid);\n}\n\nexport function killTrackedDetachedChildren(): void {\n\tfor (const pid of trackedDetachedChildPids) {\n\t\tkillProcessTree(pid);\n\t}\n\ttrackedDetachedChildPids.clear();\n}\n\n/**\n * Kill a process and all its children (cross-platform)\n */\nexport function killProcessTree(pid: number): void {\n\tif (process.platform === \"win32\") {\n\t\t// Use taskkill on Windows to kill process tree\n\t\ttry {\n\t\t\tspawn(\"taskkill\", [\"/F\", \"/T\", \"/PID\", String(pid)], {\n\t\t\t\tstdio: \"ignore\",\n\t\t\t\tdetached: true,\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t} catch {\n\t\t\t// Ignore errors if taskkill fails\n\t\t}\n\t} else {\n\t\t// Use SIGKILL on Unix/Linux/Mac\n\t\ttry {\n\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// Fallback to killing just the child if process group kill fails\n\t\t\ttry {\n\t\t\t\tprocess.kill(pid, \"SIGKILL\");\n\t\t\t} catch {\n\t\t\t\t// Process already dead\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1,195 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { delimiter } from "node:path";
3
- import { spawn, spawnSync } from "child_process";
4
- import { getBinDir } from "../config.js";
5
- /**
6
- * Find bash executable on PATH (cross-platform)
7
- */
8
- function findBashOnPath() {
9
- if (process.platform === "win32") {
10
- // Windows: Use 'where' and verify file exists (where can return non-existent paths)
11
- try {
12
- const result = spawnSync("where", ["bash.exe"], {
13
- encoding: "utf-8",
14
- timeout: 5000,
15
- windowsHide: true,
16
- });
17
- if (result.status === 0 && result.stdout) {
18
- const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
19
- if (firstMatch && existsSync(firstMatch)) {
20
- return firstMatch;
21
- }
22
- }
23
- }
24
- catch {
25
- // Ignore errors
26
- }
27
- return null;
28
- }
29
- // Unix: Use 'which' and trust its output (handles Termux and special filesystems)
30
- try {
31
- const result = spawnSync("which", ["bash"], { encoding: "utf-8", timeout: 5000 });
32
- if (result.status === 0 && result.stdout) {
33
- const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
34
- if (firstMatch) {
35
- return firstMatch;
36
- }
37
- }
38
- }
39
- catch {
40
- // Ignore errors
41
- }
42
- return null;
43
- }
44
- /**
45
- * Resolve shell configuration based on platform and an optional explicit shell path.
46
- * Resolution order:
47
- * 1. User-specified shellPath
48
- * 2. On Windows: Git Bash in known locations, then bash on PATH
49
- * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh
50
- */
51
- export function getShellConfig(customShellPath) {
52
- // 1. Check user-specified shell path
53
- if (customShellPath) {
54
- if (existsSync(customShellPath)) {
55
- return { shell: customShellPath, args: ["-c"] };
56
- }
57
- throw new Error(`Custom shell path not found: ${customShellPath}`);
58
- }
59
- if (process.platform === "win32") {
60
- // 2. Try Git Bash in known locations
61
- const paths = [];
62
- const programFiles = process.env.ProgramFiles;
63
- if (programFiles) {
64
- paths.push(`${programFiles}\\Git\\bin\\bash.exe`);
65
- }
66
- const programFilesX86 = process.env["ProgramFiles(x86)"];
67
- if (programFilesX86) {
68
- paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
69
- }
70
- for (const path of paths) {
71
- if (existsSync(path)) {
72
- return { shell: path, args: ["-c"] };
73
- }
74
- }
75
- // 3. Fallback: search bash.exe on PATH (Cygwin, MSYS2, WSL, etc.)
76
- const bashOnPath = findBashOnPath();
77
- if (bashOnPath) {
78
- return { shell: bashOnPath, args: ["-c"] };
79
- }
80
- throw new Error(`No bash shell found. Options:\n` +
81
- ` 1. Install Git for Windows: https://git-scm.com/download/win\n` +
82
- ` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\n` +
83
- " 3. Set shellPath in settings.json\n\n" +
84
- `Searched Git Bash in:\n${paths.map((p) => ` ${p}`).join("\n")}`);
85
- }
86
- // Unix: try /bin/bash, then bash on PATH, then fallback to sh
87
- if (existsSync("/bin/bash")) {
88
- return { shell: "/bin/bash", args: ["-c"] };
89
- }
90
- const bashOnPath = findBashOnPath();
91
- if (bashOnPath) {
92
- return { shell: bashOnPath, args: ["-c"] };
93
- }
94
- return { shell: "sh", args: ["-c"] };
95
- }
96
- export function getShellEnv() {
97
- const binDir = getBinDir();
98
- const pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === "path") ?? "PATH";
99
- const currentPath = process.env[pathKey] ?? "";
100
- const pathEntries = currentPath.split(delimiter).filter(Boolean);
101
- const hasBinDir = pathEntries.includes(binDir);
102
- const updatedPath = hasBinDir ? currentPath : [binDir, currentPath].filter(Boolean).join(delimiter);
103
- return {
104
- ...process.env,
105
- [pathKey]: updatedPath,
106
- };
107
- }
108
- /**
109
- * Sanitize binary output for display/storage.
110
- * Removes characters that crash string-width or cause display issues:
111
- * - Control characters (except tab, newline, carriage return)
112
- * - Lone surrogates
113
- * - Unicode Format characters (crash string-width due to a bug)
114
- * - Characters with undefined code points
115
- */
116
- export function sanitizeBinaryOutput(str) {
117
- // Use Array.from to properly iterate over code points (not code units)
118
- // This handles surrogate pairs correctly and catches edge cases where
119
- // codePointAt() might return undefined
120
- return Array.from(str)
121
- .filter((char) => {
122
- // Filter out characters that cause string-width to crash
123
- // This includes:
124
- // - Unicode format characters
125
- // - Lone surrogates (already filtered by Array.from)
126
- // - Control chars except \t \n \r
127
- // - Characters with undefined code points
128
- const code = char.codePointAt(0);
129
- // Skip if code point is undefined (edge case with invalid strings)
130
- if (code === undefined)
131
- return false;
132
- // Allow tab, newline, carriage return
133
- if (code === 0x09 || code === 0x0a || code === 0x0d)
134
- return true;
135
- // Filter out control characters (0x00-0x1F, except 0x09, 0x0a, 0x0x0d)
136
- if (code <= 0x1f)
137
- return false;
138
- // Filter out Unicode format characters
139
- if (code >= 0xfff9 && code <= 0xfffb)
140
- return false;
141
- return true;
142
- })
143
- .join("");
144
- }
145
- /**
146
- * Detached child processes must be tracked so they can be killed on parent
147
- * shutdown signals (SIGHUP/SIGTERM).
148
- */
149
- const trackedDetachedChildPids = new Set();
150
- export function trackDetachedChildPid(pid) {
151
- trackedDetachedChildPids.add(pid);
152
- }
153
- export function untrackDetachedChildPid(pid) {
154
- trackedDetachedChildPids.delete(pid);
155
- }
156
- export function killTrackedDetachedChildren() {
157
- for (const pid of trackedDetachedChildPids) {
158
- killProcessTree(pid);
159
- }
160
- trackedDetachedChildPids.clear();
161
- }
162
- /**
163
- * Kill a process and all its children (cross-platform)
164
- */
165
- export function killProcessTree(pid) {
166
- if (process.platform === "win32") {
167
- // Use taskkill on Windows to kill process tree
168
- try {
169
- spawn("taskkill", ["/F", "/T", "/PID", String(pid)], {
170
- stdio: "ignore",
171
- detached: true,
172
- windowsHide: true,
173
- });
174
- }
175
- catch {
176
- // Ignore errors if taskkill fails
177
- }
178
- }
179
- else {
180
- // Use SIGKILL on Unix/Linux/Mac
181
- try {
182
- process.kill(-pid, "SIGKILL");
183
- }
184
- catch {
185
- // Fallback to killing just the child if process group kill fails
186
- try {
187
- process.kill(pid, "SIGKILL");
188
- }
189
- catch {
190
- // Process already dead
191
- }
192
- }
193
- }
194
- }
195
- //# sourceMappingURL=shell.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOzC;;GAEG;AACH,SAAS,cAAc,GAAkB;IACxC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAClC,oFAAoF;QACpF,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EA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,EAAQ;IAClD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAClC,+CAA+C;QAC/C,IAAI,CAAC;YACJ,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACpD,KAAK,EAAE,QAAQ;gBACf,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,IAAI;aACjB,CAAC,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACR,kCAAkC;QACnC,CAAC;IACF,CAAC;SAAM,CAAC;QACP,gCAAgC;QAChC,IAAI,CAAC;YACJ,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACR,iEAAiE;YACjE,IAAI,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACR,uBAAuB;YACxB,CAAC;QACF,CAAC;IACF,CAAC;AAAA,CACD","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { delimiter } from \"node:path\";\nimport { spawn, spawnSync } from \"child_process\";\nimport { getBinDir } from \"../config.ts\";\n\nexport interface ShellConfig {\n\tshell: string;\n\targs: string[];\n}\n\n/**\n * Find bash executable on PATH (cross-platform)\n */\nfunction findBashOnPath(): string | null {\n\tif (process.platform === \"win32\") {\n\t\t// Windows: Use 'where' and verify file exists (where can return non-existent paths)\n\t\ttry {\n\t\t\tconst result = spawnSync(\"where\", [\"bash.exe\"], {\n\t\t\t\tencoding: \"utf-8\",\n\t\t\t\ttimeout: 5000,\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t\tif (result.status === 0 && result.stdout) {\n\t\t\t\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\t\t\t\tif (firstMatch && existsSync(firstMatch)) {\n\t\t\t\t\treturn firstMatch;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore errors\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Unix: Use 'which' and trust its output (handles Termux and special filesystems)\n\ttry {\n\t\tconst result = spawnSync(\"which\", [\"bash\"], { encoding: \"utf-8\", timeout: 5000 });\n\t\tif (result.status === 0 && result.stdout) {\n\t\t\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\t\t\tif (firstMatch) {\n\t\t\t\treturn firstMatch;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\treturn null;\n}\n\n/**\n * Resolve shell configuration based on platform and an optional explicit shell path.\n * Resolution order:\n * 1. User-specified shellPath\n * 2. On Windows: Git Bash in known locations, then bash on PATH\n * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh\n */\nexport function getShellConfig(customShellPath?: string): ShellConfig {\n\t// 1. Check user-specified shell path\n\tif (customShellPath) {\n\t\tif (existsSync(customShellPath)) {\n\t\t\treturn { shell: customShellPath, args: [\"-c\"] };\n\t\t}\n\t\tthrow new Error(`Custom shell path not found: ${customShellPath}`);\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\t// 2. Try Git Bash in known locations\n\t\tconst paths: string[] = [];\n\t\tconst programFiles = process.env.ProgramFiles;\n\t\tif (programFiles) {\n\t\t\tpaths.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\t\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\t\tif (programFilesX86) {\n\t\t\tpaths.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\n\t\tfor (const path of paths) {\n\t\t\tif (existsSync(path)) {\n\t\t\t\treturn { shell: path, args: [\"-c\"] };\n\t\t\t}\n\t\t}\n\n\t\t// 3. Fallback: search bash.exe on PATH (Cygwin, MSYS2, WSL, etc.)\n\t\tconst bashOnPath = findBashOnPath();\n\t\tif (bashOnPath) {\n\t\t\treturn { shell: bashOnPath, args: [\"-c\"] };\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No bash shell found. Options:\\n` +\n\t\t\t\t` 1. Install Git for Windows: https://git-scm.com/download/win\\n` +\n\t\t\t\t` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\\n` +\n\t\t\t\t\" 3. Set shellPath in settings.json\\n\\n\" +\n\t\t\t\t`Searched Git Bash in:\\n${paths.map((p) => ` ${p}`).join(\"\\n\")}`,\n\t\t);\n\t}\n\n\t// Unix: try /bin/bash, then bash on PATH, then fallback to sh\n\tif (existsSync(\"/bin/bash\")) {\n\t\treturn { shell: \"/bin/bash\", args: [\"-c\"] };\n\t}\n\n\tconst bashOnPath = findBashOnPath();\n\tif (bashOnPath) {\n\t\treturn { shell: bashOnPath, args: [\"-c\"] };\n\t}\n\n\treturn { shell: \"sh\", args: [\"-c\"] };\n}\n\nexport function getShellEnv(): NodeJS.ProcessEnv {\n\tconst binDir = getBinDir();\n\tconst pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === \"path\") ?? \"PATH\";\n\tconst currentPath = process.env[pathKey] ?? \"\";\n\tconst pathEntries = currentPath.split(delimiter).filter(Boolean);\n\tconst hasBinDir = pathEntries.includes(binDir);\n\tconst updatedPath = hasBinDir ? currentPath : [binDir, currentPath].filter(Boolean).join(delimiter);\n\n\treturn {\n\t\t...process.env,\n\t\t[pathKey]: updatedPath,\n\t};\n}\n\n/**\n * Sanitize binary output for display/storage.\n * Removes characters that crash string-width or cause display issues:\n * - Control characters (except tab, newline, carriage return)\n * - Lone surrogates\n * - Unicode Format characters (crash string-width due to a bug)\n * - Characters with undefined code points\n */\nexport function sanitizeBinaryOutput(str: string): string {\n\t// Use Array.from to properly iterate over code points (not code units)\n\t// This handles surrogate pairs correctly and catches edge cases where\n\t// codePointAt() might return undefined\n\treturn Array.from(str)\n\t\t.filter((char) => {\n\t\t\t// Filter out characters that cause string-width to crash\n\t\t\t// This includes:\n\t\t\t// - Unicode format characters\n\t\t\t// - Lone surrogates (already filtered by Array.from)\n\t\t\t// - Control chars except \\t \\n \\r\n\t\t\t// - Characters with undefined code points\n\n\t\t\tconst code = char.codePointAt(0);\n\n\t\t\t// Skip if code point is undefined (edge case with invalid strings)\n\t\t\tif (code === undefined) return false;\n\n\t\t\t// Allow tab, newline, carriage return\n\t\t\tif (code === 0x09 || code === 0x0a || code === 0x0d) return true;\n\n\t\t\t// Filter out control characters (0x00-0x1F, except 0x09, 0x0a, 0x0x0d)\n\t\t\tif (code <= 0x1f) return false;\n\n\t\t\t// Filter out Unicode format characters\n\t\t\tif (code >= 0xfff9 && code <= 0xfffb) return false;\n\n\t\t\treturn true;\n\t\t})\n\t\t.join(\"\");\n}\n\n/**\n * Detached child processes must be tracked so they can be killed on parent\n * shutdown signals (SIGHUP/SIGTERM).\n */\nconst trackedDetachedChildPids = new Set<number>();\n\nexport function trackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.add(pid);\n}\n\nexport function untrackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.delete(pid);\n}\n\nexport function killTrackedDetachedChildren(): void {\n\tfor (const pid of trackedDetachedChildPids) {\n\t\tkillProcessTree(pid);\n\t}\n\ttrackedDetachedChildPids.clear();\n}\n\n/**\n * Kill a process and all its children (cross-platform)\n */\nexport function killProcessTree(pid: number): void {\n\tif (process.platform === \"win32\") {\n\t\t// Use taskkill on Windows to kill process tree\n\t\ttry {\n\t\t\tspawn(\"taskkill\", [\"/F\", \"/T\", \"/PID\", String(pid)], {\n\t\t\t\tstdio: \"ignore\",\n\t\t\t\tdetached: true,\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t} catch {\n\t\t\t// Ignore errors if taskkill fails\n\t\t}\n\t} else {\n\t\t// Use SIGKILL on Unix/Linux/Mac\n\t\ttry {\n\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// Fallback to killing just the child if process group kill fails\n\t\t\ttry {\n\t\t\t\tprocess.kill(pid, \"SIGKILL\");\n\t\t\t} catch {\n\t\t\t\t// Process already dead\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Sleep helper that respects abort signal.
3
- */
4
- export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
5
- //# sourceMappingURL=sleep.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE","sourcesContent":["/**\n * Sleep helper that respects abort signal.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout(resolve, ms);\n\n\t\tsignal?.addEventListener(\"abort\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t});\n\t});\n}\n"]}
@@ -1,17 +0,0 @@
1
- /**
2
- * Sleep helper that respects abort signal.
3
- */
4
- export function sleep(ms, signal) {
5
- return new Promise((resolve, reject) => {
6
- if (signal?.aborted) {
7
- reject(new Error("Aborted"));
8
- return;
9
- }
10
- const timeout = setTimeout(resolve, ms);
11
- signal?.addEventListener("abort", () => {
12
- clearTimeout(timeout);
13
- reject(new Error("Aborted"));
14
- });
15
- });
16
- }
17
- //# sourceMappingURL=sleep.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,MAAoB,EAAiB;IACtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;QACvC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7B,OAAO;QACR,CAAC;QAED,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAExC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAAA,CAC7B,CAAC,CAAC;IAAA,CACH,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Sleep helper that respects abort signal.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout(resolve, ms);\n\n\t\tsignal?.addEventListener(\"abort\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t});\n\t});\n}\n"]}
@@ -1,12 +0,0 @@
1
- export type HighlightFormatter = (text: string) => string;
2
- export type HighlightTheme = Partial<Record<string, HighlightFormatter>>;
3
- export interface HighlightOptions {
4
- language?: string;
5
- ignoreIllegals?: boolean;
6
- languageSubset?: string[];
7
- theme?: HighlightTheme;
8
- }
9
- export declare function renderHighlightedHtml(html: string, theme?: HighlightTheme): string;
10
- export declare function highlight(code: string, options?: HighlightOptions): string;
11
- export declare function supportsLanguage(name: string): boolean;
12
- //# sourceMappingURL=syntax-highlight.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syntax-highlight.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;CACvB;AAoED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,MAAM,CAoDtF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAQ9E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD","sourcesContent":["import hljs from \"highlight.js/lib/index.js\";\nimport { decodeHtmlEntityAt } from \"./html.ts\";\n\nexport type HighlightFormatter = (text: string) => string;\nexport type HighlightTheme = Partial<Record<string, HighlightFormatter>>;\n\nexport interface HighlightOptions {\n\tlanguage?: string;\n\tignoreIllegals?: boolean;\n\tlanguageSubset?: string[];\n\ttheme?: HighlightTheme;\n}\n\nconst SPAN_CLOSE = \"</span>\";\nconst HIGHLIGHT_CLASS_PREFIX = \"hljs-\";\n\nfunction getScopeFromSpanTag(tag: string): string | undefined {\n\tconst match = /\\sclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/.exec(tag);\n\tconst classValue = match?.[1] ?? match?.[2];\n\tif (!classValue) {\n\t\treturn undefined;\n\t}\n\n\tfor (const className of classValue.split(/\\s+/)) {\n\t\tif (className.startsWith(HIGHLIGHT_CLASS_PREFIX)) {\n\t\t\treturn className.slice(HIGHLIGHT_CLASS_PREFIX.length);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getScopeFormatter(scope: string, theme: HighlightTheme): HighlightFormatter | undefined {\n\tconst exact = theme[scope];\n\tif (exact) {\n\t\treturn exact;\n\t}\n\n\tconst dotIndex = scope.indexOf(\".\");\n\tif (dotIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dotIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\tconst dashIndex = scope.indexOf(\"-\");\n\tif (dashIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dashIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getActiveFormatter(scopes: Array<string | undefined>, theme: HighlightTheme): HighlightFormatter | undefined {\n\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\tconst scope = scopes[i];\n\t\tif (!scope) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst formatter = getScopeFormatter(scope, theme);\n\t\tif (formatter) {\n\t\t\treturn formatter;\n\t\t}\n\t}\n\treturn theme.default;\n}\n\nfunction isSpanOpenTagStart(html: string, index: number): boolean {\n\tif (!html.startsWith(\"<span\", index)) {\n\t\treturn false;\n\t}\n\tconst nextChar = html[index + \"<span\".length];\n\treturn nextChar === \">\" || nextChar === \" \" || nextChar === \"\\t\" || nextChar === \"\\n\" || nextChar === \"\\r\";\n}\n\nexport function renderHighlightedHtml(html: string, theme: HighlightTheme = {}): string {\n\tlet output = \"\";\n\tlet textBuffer = \"\";\n\tconst scopes: Array<string | undefined> = [];\n\n\tconst flushText = () => {\n\t\tif (!textBuffer) {\n\t\t\treturn;\n\t\t}\n\t\tconst formatter = getActiveFormatter(scopes, theme);\n\t\toutput += formatter ? formatter(textBuffer) : textBuffer;\n\t\ttextBuffer = \"\";\n\t};\n\n\tlet index = 0;\n\twhile (index < html.length) {\n\t\tif (isSpanOpenTagStart(html, index)) {\n\t\t\tconst tagEndIndex = html.indexOf(\">\", index + 5);\n\t\t\tif (tagEndIndex !== -1) {\n\t\t\t\tflushText();\n\t\t\t\tconst tag = html.slice(index, tagEndIndex + 1);\n\t\t\t\tconst scope = getScopeFromSpanTag(tag);\n\t\t\t\tscopes.push(scope);\n\t\t\t\tindex = tagEndIndex + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (html.startsWith(SPAN_CLOSE, index)) {\n\t\t\tflushText();\n\t\t\tif (scopes.length > 0) {\n\t\t\t\tscopes.pop();\n\t\t\t}\n\t\t\tindex += SPAN_CLOSE.length;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (html[index] === \"&\") {\n\t\t\tconst decoded = decodeHtmlEntityAt(html, index);\n\t\t\tif (decoded) {\n\t\t\t\ttextBuffer += decoded.text;\n\t\t\t\tindex += decoded.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttextBuffer += html[index];\n\t\tindex++;\n\t}\n\n\tflushText();\n\treturn output;\n}\n\nexport function highlight(code: string, options: HighlightOptions = {}): string {\n\tconst html = options.language\n\t\t? hljs.highlight(code, {\n\t\t\t\tlanguage: options.language,\n\t\t\t\tignoreIllegals: options.ignoreIllegals,\n\t\t\t}).value\n\t\t: hljs.highlightAuto(code, options.languageSubset).value;\n\treturn renderHighlightedHtml(html, options.theme);\n}\n\nexport function supportsLanguage(name: string): boolean {\n\treturn hljs.getLanguage(name) !== undefined;\n}\n"]}