shortcutxl 0.3.76 → 0.3.78

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 (480) hide show
  1. package/BINARY-INVENTORY.json +813 -813
  2. package/CHANGELOG.md +14 -0
  3. package/dist/ai/models.d.ts +10 -6
  4. package/dist/ai/models.generated.d.ts +72 -0
  5. package/dist/ai/models.generated.js +33 -0
  6. package/dist/ai/models.js +36 -13
  7. package/dist/ai/providers/anthropic.d.ts +4 -2
  8. package/dist/ai/providers/anthropic.js +59 -29
  9. package/dist/ai/providers/azure-openai-responses.d.ts +2 -1
  10. package/dist/ai/providers/azure-openai-responses.js +4 -20
  11. package/dist/ai/providers/google-vertex.d.ts +8 -2
  12. package/dist/ai/providers/google-vertex.js +66 -54
  13. package/dist/ai/providers/google.js +15 -48
  14. package/dist/ai/providers/openai-completions.d.ts +4 -1
  15. package/dist/ai/providers/openai-completions.js +26 -10
  16. package/dist/ai/providers/openai-reasoning.d.ts +5 -0
  17. package/dist/ai/providers/openai-reasoning.js +13 -0
  18. package/dist/ai/providers/openai-responses-shared.js +1 -1
  19. package/dist/ai/providers/openai-responses.d.ts +6 -2
  20. package/dist/ai/providers/openai-responses.js +28 -23
  21. package/dist/ai/providers/simple-options.d.ts +2 -3
  22. package/dist/ai/providers/simple-options.js +4 -6
  23. package/dist/ai/types.d.ts +19 -2
  24. package/dist/app/agent-session-runtime-adapter.js +7 -6
  25. package/dist/app/agent-session.d.ts +0 -15
  26. package/dist/app/agent-session.js +0 -37
  27. package/dist/app/approvals/approval-errors.d.ts +15 -0
  28. package/dist/app/approvals/approval-errors.js +14 -0
  29. package/dist/app/approvals/runtime-approval-gates.d.ts +1 -2
  30. package/dist/app/approvals/tool-approval.d.ts +1 -0
  31. package/dist/app/approvals/tool-approval.js +11 -23
  32. package/dist/app/approvals/types.d.ts +0 -14
  33. package/dist/app/approvals/types.js +0 -2
  34. package/dist/app/background/tool-summaries.js +0 -2
  35. package/dist/app/extensions/slash-commands.js +1 -3
  36. package/dist/app/local/tools/execute-code/executor.d.ts +1 -1
  37. package/dist/app/local/tools/execute-code/executor.js +20 -10
  38. package/dist/app/local/tools/execute-code/tool.js +21 -2
  39. package/dist/app/modes/action/agent.js +4 -5
  40. package/dist/app/modes/ask/agent.js +4 -6
  41. package/dist/app/modes/index.js +20 -10
  42. package/dist/app/modes/installation/agent.js +4 -5
  43. package/dist/app/modes/manage/agent.js +3 -4
  44. package/dist/app/modes/manage/prompt.js +1 -2
  45. package/dist/app/modes/metadata.d.ts +31 -0
  46. package/dist/app/modes/metadata.js +35 -0
  47. package/dist/app/modes/plan/agent.js +5 -8
  48. package/dist/app/modes/plan/prompt.js +3 -3
  49. package/dist/app/permissions/runtime-approval-flow.d.ts +1 -5
  50. package/dist/app/permissions/runtime-approval-flow.js +0 -28
  51. package/dist/app/permissions/tool-gates.d.ts +2 -3
  52. package/dist/app/permissions/tool-gates.js +3 -81
  53. package/dist/app/prompts/com-api.js +1 -1
  54. package/dist/app/prompts/shared-guidelines.js +7 -3
  55. package/dist/app/providers/google-vertex-gateway.js +4 -51
  56. package/dist/app/providers/model-registry.d.ts +1 -0
  57. package/dist/app/providers/model-registry.js +39 -0
  58. package/dist/app/providers/model-resolver.js +10 -7
  59. package/dist/app/providers/register-shortcut-provider.js +6 -6
  60. package/dist/app/providers/shortcut-api-v2-transport.js +4 -0
  61. package/dist/app/providers/shortcut-llm-proxy-client.d.ts +2 -2
  62. package/dist/app/providers/shortcut-llm-proxy-client.js +1 -0
  63. package/dist/app/resources/package-manager.js +2 -123
  64. package/dist/app/resources/resource-patterns.d.ts +9 -0
  65. package/dist/app/resources/resource-patterns.js +120 -0
  66. package/dist/app/session/forked-agent.d.ts +2 -2
  67. package/dist/app/session/model-manager.js +3 -2
  68. package/dist/app/session/session-lifecycle.js +3 -2
  69. package/dist/app/session/session-models.d.ts +2 -0
  70. package/dist/app/session/session-models.js +14 -6
  71. package/dist/app/settings-manager.d.ts +3 -3
  72. package/dist/app/shared/tools/execute-code/mog.d.ts +3 -1
  73. package/dist/app/shared/tools/execute-code/mog.js +18 -2
  74. package/dist/app/tools/bash.js +3 -3
  75. package/dist/app/tools/execute-code/index.d.ts +1 -0
  76. package/dist/app/tools/execute-code/index.js +3 -1
  77. package/dist/app/tools/find-ignore-files.d.ts +3 -0
  78. package/dist/app/tools/find-ignore-files.js +33 -0
  79. package/dist/app/tools/find.js +2 -21
  80. package/dist/app/tools/llm-analysis.js +0 -2
  81. package/dist/app/tools/refresh-context.d.ts +1 -1
  82. package/dist/app/tools/session-settings/update-session-settings.js +2 -2
  83. package/dist/app/tools/switch-mode.js +2 -2
  84. package/dist/app/tools/take-screenshot.js +0 -2
  85. package/dist/app/tools/task/runner.js +1 -2
  86. package/dist/app/tools/task/task.d.ts +1 -3
  87. package/dist/app/tools/task/task.js +20 -40
  88. package/dist/app/tools/web-search.js +12 -2
  89. package/dist/autocomplete/core.d.ts +33 -0
  90. package/dist/autocomplete/core.js +113 -0
  91. package/dist/{tui → autocomplete}/fuzzy.d.ts +0 -1
  92. package/dist/{tui → autocomplete}/fuzzy.js +0 -1
  93. package/dist/{tui/autocomplete.d.ts → autocomplete/index.d.ts} +0 -1
  94. package/dist/{tui/autocomplete.js → autocomplete/index.js} +62 -158
  95. package/dist/cli/args.js +1 -1
  96. package/dist/cli/list-models.js +1 -1
  97. package/dist/cli.js +26227 -30480
  98. package/dist/constants.d.ts +0 -2
  99. package/dist/constants.js +0 -3
  100. package/dist/contracts/agent-session-store.d.ts +1 -1
  101. package/dist/contracts/agent-settings.d.ts +1 -0
  102. package/dist/contracts/agent-settings.js +2 -1
  103. package/dist/contracts/model-call.d.ts +1 -2
  104. package/dist/contracts/model-call.js +1 -2
  105. package/dist/contracts/model-stream.d.ts +1 -0
  106. package/dist/contracts/model-stream.js +1 -0
  107. package/dist/contracts/wire.d.ts +10 -7
  108. package/dist/contracts/wire.js +8 -0
  109. package/dist/core/agent-engine.js +1 -1
  110. package/dist/core/core-types.d.ts +1 -21
  111. package/dist/core/defaults.d.ts +1 -1
  112. package/dist/core/defaults.js +9 -1
  113. package/dist/core/prompts/agent-guidelines.d.ts +4 -5
  114. package/dist/core/prompts/agent-guidelines.js +28 -42
  115. package/dist/core/session-schema.d.ts +1 -1
  116. package/dist/embedded-agent/ai-invoke.d.ts +1 -2
  117. package/dist/embedded-agent/ai-invoke.js +2 -70
  118. package/dist/embedded-agent/anthropic-messages-transport.d.ts +4 -20
  119. package/dist/embedded-agent/anthropic-messages-transport.js +23 -786
  120. package/dist/embedded-agent/bootstrap.js +2 -2
  121. package/dist/embedded-agent/compose.js +8 -7
  122. package/dist/embedded-agent/gateway-base-url.d.ts +3 -0
  123. package/dist/embedded-agent/gateway-base-url.js +35 -0
  124. package/dist/embedded-agent/google-vertex-transport.d.ts +2 -11
  125. package/dist/embedded-agent/google-vertex-transport.js +20 -117
  126. package/dist/embedded-agent/host-runtime-options.d.ts +0 -8
  127. package/dist/embedded-agent/host-runtime-options.js +10 -2
  128. package/dist/embedded-agent/host-tools/invoke-llm/contract.d.ts +2 -2
  129. package/dist/embedded-agent/host-tools/invoke-llm/contract.js +4 -2
  130. package/dist/embedded-agent/host-tools/sandbox-llm/contract.d.ts +8 -3
  131. package/dist/embedded-agent/host-tools/sandbox-llm/contract.js +12 -8
  132. package/dist/embedded-agent/host-tools/sandbox-llm/index.d.ts +1 -1
  133. package/dist/embedded-agent/host-tools/sandbox-llm/index.js +1 -1
  134. package/dist/embedded-agent/host-tools/shared/index.d.ts +1 -1
  135. package/dist/embedded-agent/host-tools/shared/index.js +1 -1
  136. package/dist/embedded-agent/host-tools/shared/llm-stream-error.d.ts +7 -0
  137. package/dist/embedded-agent/host-tools/shared/llm-stream-error.js +10 -0
  138. package/dist/embedded-agent/host-tools/take-screenshot/contract.d.ts +0 -2
  139. package/dist/embedded-agent/host-tools/take-screenshot/contract.js +1 -3
  140. package/dist/embedded-agent/host-tools/take-screenshot/index.d.ts +1 -1
  141. package/dist/embedded-agent/host-tools/take-screenshot/index.js +1 -1
  142. package/dist/embedded-agent/host-tools/task/agents/clone.js +1 -2
  143. package/dist/embedded-agent/host-tools/task/contract.js +1 -1
  144. package/dist/embedded-agent/index.d.ts +3 -4
  145. package/dist/embedded-agent/index.js +2 -3
  146. package/dist/embedded-agent/model-selection.d.ts +0 -6
  147. package/dist/embedded-agent/model-selection.js +15 -8
  148. package/dist/embedded-agent/openai-completions-transport.d.ts +2 -11
  149. package/dist/embedded-agent/openai-completions-transport.js +20 -120
  150. package/dist/embedded-agent/openai-responses-transport.d.ts +2 -11
  151. package/dist/embedded-agent/openai-responses-transport.js +15 -170
  152. package/dist/embedded-agent/prompt/build.js +1 -2
  153. package/dist/embedded-agent/prompt/sections.d.ts +1 -1
  154. package/dist/embedded-agent/prompt/sections.js +2 -0
  155. package/dist/embedded-agent/provider-native-request.d.ts +29 -0
  156. package/dist/embedded-agent/provider-native-request.js +65 -0
  157. package/dist/embedded-agent/run-stats.d.ts +1 -1
  158. package/dist/embedded-agent/stream.d.ts +10 -96
  159. package/dist/embedded-agent/stream.js +31 -556
  160. package/dist/embedded-agent/suggestions.d.ts +1 -1
  161. package/dist/embedded-agent/suggestions.js +1 -1
  162. package/dist/embedded-agent/worker-bridge/host-client.d.ts +7 -0
  163. package/dist/embedded-agent/worker-bridge/host-client.js +15 -0
  164. package/dist/embedded-agent/worker-bridge/worker-port.js +17 -1
  165. package/dist/main.js +18 -14
  166. package/dist/rpc/index.d.ts +1 -1
  167. package/dist/rpc/rpc-approval-gates.js +1 -2
  168. package/dist/rpc/rpc-host.d.ts +4 -0
  169. package/dist/rpc/rpc-host.js +13 -24
  170. package/dist/rpc/rpc-types.d.ts +6 -17
  171. package/dist/shared/platform/open.d.ts +4 -1
  172. package/dist/shared/platform/open.js +14 -2
  173. package/dist/shell/approvals/runtime-approval-gates.js +1 -3
  174. package/dist/shell/components/selectors/model-selector.js +2 -1
  175. package/dist/shell/components/selectors/session-selector-search.js +1 -1
  176. package/dist/shell/components/selectors/thinking-selector.js +7 -6
  177. package/dist/shell/index.d.ts +0 -1
  178. package/dist/shell/index.js +0 -1
  179. package/dist/shell/interactive/interactive-mode-options.d.ts +10 -0
  180. package/dist/shell/interactive/interactive-mode.d.ts +6 -12
  181. package/dist/shell/interactive/interactive-mode.js +39 -158
  182. package/dist/shell/interactive/slash-commands.d.ts +0 -34
  183. package/dist/shell/interactive/slash-commands.js +0 -2
  184. package/dist/shell/links/local-file-link-input.d.ts +15 -0
  185. package/dist/shell/links/local-file-link-input.js +38 -0
  186. package/dist/shell/links/local-file-link.d.ts +7 -0
  187. package/dist/shell/links/local-file-link.js +35 -0
  188. package/dist/shell/links/local-file-opener.d.ts +16 -0
  189. package/dist/shell/links/local-file-opener.js +90 -0
  190. package/dist/shell/session-client.d.ts +0 -1
  191. package/dist/shell/session-client.js +0 -6
  192. package/dist/shell/status/update-check-scheduler.d.ts +30 -0
  193. package/dist/shell/status/update-check-scheduler.js +71 -0
  194. package/dist/shell/status/update-reminder-controller.d.ts +22 -0
  195. package/dist/shell/status/update-reminder-controller.js +40 -0
  196. package/dist/shell/status/update-reminder.d.ts +6 -0
  197. package/dist/shell/status/update-reminder.js +4 -0
  198. package/dist/shell/theme/dark.json +1 -2
  199. package/dist/shell/theme/light.json +1 -2
  200. package/dist/shell/theme/runtime.d.ts +2 -3
  201. package/dist/shell/theme/runtime.js +2 -6
  202. package/dist/shell/theme/theme-schema.json +1 -6
  203. package/dist/shortcut-model-catalog.d.ts +7 -2
  204. package/dist/shortcut-model-catalog.js +134 -10
  205. package/dist/startup/update-manager.d.ts +6 -6
  206. package/dist/startup/update-manager.js +23 -38
  207. package/dist/startup/update-prompt.d.ts +1 -0
  208. package/dist/startup/update-prompt.js +2 -2
  209. package/dist/tui/components/editor.d.ts +1 -1
  210. package/dist/tui/components/editor.js +1 -1
  211. package/dist/tui/components/markdown.js +15 -6
  212. package/dist/tui/components/settings-list.js +1 -1
  213. package/dist/tui/editor-component.d.ts +1 -1
  214. package/dist/tui/index.d.ts +7 -8
  215. package/dist/tui/index.js +7 -6
  216. package/dist/tui/tui.d.ts +2 -0
  217. package/dist/tui/tui.js +16 -1
  218. package/dist/tui/utils.d.ts +7 -0
  219. package/dist/tui/utils.js +58 -8
  220. package/native-app/main/index.js +3200 -48
  221. package/native-app/main/{photon_rs-SoVDgheu.js → photon_rs-XkYyYTVA.js} +2 -2
  222. package/native-app/package.json +1 -1
  223. package/native-app/preload/index.cjs +2 -0
  224. package/native-app/renderer/assets/{index-CFc-oZuS.js → index-B4jz6epR.js} +825 -155
  225. package/native-app/renderer/assets/{index-OhGE0UY4.css → index-C__g36ft.css} +412 -162
  226. package/native-app/renderer/assets/shortcutagent-DxFsGSkw.png +0 -0
  227. package/native-app/renderer/index.html +2 -2
  228. package/package.json +17 -3
  229. package/skills/add-custom-model/SKILL.md +52 -0
  230. package/user-docs/dist/index.html +1 -1
  231. package/user-docs/dist/shortcutxl-docs.pdf +0 -0
  232. package/xll/ShortcutXL.xll +0 -0
  233. package/xll/modules/shortcut_xl/_managed.py +26 -7
  234. package/xll/modules/shortcut_xl/_tracking.py +141 -251
  235. package/xll/modules/shortcut_xl/api/__init__.py +60 -0
  236. package/xll/modules/shortcut_xl/api/workbook.py +9 -1
  237. package/xll/modules/shortcut_xl/api/worksheet.py +4 -1
  238. package/xll/python/Lib/site-packages/httpx-0.28.1.dist-info/RECORD +1 -1
  239. package/xll/python/Lib/site-packages/idna-3.18.dist-info/RECORD +1 -1
  240. package/xll/python/Lib/site-packages/pip/__init__.py +1 -1
  241. package/xll/python/Lib/site-packages/pip/_internal/build_env/__init__.py +25 -0
  242. package/xll/python/Lib/site-packages/pip/_internal/build_env/base.py +103 -0
  243. package/xll/python/Lib/site-packages/pip/_internal/build_env/installer.py +333 -0
  244. package/xll/python/Lib/site-packages/pip/_internal/build_env/noop.py +42 -0
  245. package/xll/python/Lib/site-packages/pip/_internal/build_env/venv.py +145 -0
  246. package/xll/python/Lib/site-packages/pip/_internal/build_env/virtual.py +139 -0
  247. package/xll/python/Lib/site-packages/pip/_internal/cache.py +4 -1
  248. package/xll/python/Lib/site-packages/pip/_internal/cli/autocompletion.py +4 -1
  249. package/xll/python/Lib/site-packages/pip/_internal/cli/base_command.py +11 -14
  250. package/xll/python/Lib/site-packages/pip/_internal/cli/cmdoptions.py +133 -22
  251. package/xll/python/Lib/site-packages/pip/_internal/cli/index_command.py +11 -6
  252. package/xll/python/Lib/site-packages/pip/_internal/cli/main.py +2 -1
  253. package/xll/python/Lib/site-packages/pip/_internal/cli/main_parser.py +1 -2
  254. package/xll/python/Lib/site-packages/pip/_internal/cli/parser.py +10 -2
  255. package/xll/python/Lib/site-packages/pip/_internal/cli/progress_bars.py +2 -2
  256. package/xll/python/Lib/site-packages/pip/_internal/cli/req_command.py +57 -25
  257. package/xll/python/Lib/site-packages/pip/_internal/cli/status_codes.py +1 -0
  258. package/xll/python/Lib/site-packages/pip/_internal/commands/cache.py +7 -6
  259. package/xll/python/Lib/site-packages/pip/_internal/commands/configuration.py +2 -1
  260. package/xll/python/Lib/site-packages/pip/_internal/commands/debug.py +4 -5
  261. package/xll/python/Lib/site-packages/pip/_internal/commands/download.py +4 -0
  262. package/xll/python/Lib/site-packages/pip/_internal/commands/freeze.py +1 -1
  263. package/xll/python/Lib/site-packages/pip/_internal/commands/index.py +10 -3
  264. package/xll/python/Lib/site-packages/pip/_internal/commands/inspect.py +1 -1
  265. package/xll/python/Lib/site-packages/pip/_internal/commands/install.py +6 -6
  266. package/xll/python/Lib/site-packages/pip/_internal/commands/list.py +11 -6
  267. package/xll/python/Lib/site-packages/pip/_internal/commands/lock.py +4 -6
  268. package/xll/python/Lib/site-packages/pip/_internal/commands/show.py +14 -8
  269. package/xll/python/Lib/site-packages/pip/_internal/commands/wheel.py +7 -1
  270. package/xll/python/Lib/site-packages/pip/_internal/configuration.py +2 -3
  271. package/xll/python/Lib/site-packages/pip/_internal/distributions/base.py +5 -3
  272. package/xll/python/Lib/site-packages/pip/_internal/distributions/installed.py +3 -2
  273. package/xll/python/Lib/site-packages/pip/_internal/distributions/sdist.py +45 -20
  274. package/xll/python/Lib/site-packages/pip/_internal/distributions/wheel.py +3 -2
  275. package/xll/python/Lib/site-packages/pip/_internal/exceptions.py +174 -0
  276. package/xll/python/Lib/site-packages/pip/_internal/index/collector.py +70 -48
  277. package/xll/python/Lib/site-packages/pip/_internal/index/package_finder.py +46 -7
  278. package/xll/python/Lib/site-packages/pip/_internal/index/sources.py +1 -2
  279. package/xll/python/Lib/site-packages/pip/_internal/locations/_sysconfig.py +1 -1
  280. package/xll/python/Lib/site-packages/pip/_internal/locations/base.py +1 -1
  281. package/xll/python/Lib/site-packages/pip/_internal/metadata/base.py +10 -5
  282. package/xll/python/Lib/site-packages/pip/_internal/metadata/importlib/_dists.py +1 -1
  283. package/xll/python/Lib/site-packages/pip/_internal/metadata/importlib/_envs.py +8 -3
  284. package/xll/python/Lib/site-packages/pip/_internal/models/candidate.py +5 -1
  285. package/xll/python/Lib/site-packages/pip/_internal/models/link.py +53 -13
  286. package/xll/python/Lib/site-packages/pip/_internal/network/auth.py +38 -21
  287. package/xll/python/Lib/site-packages/pip/_internal/network/cache.py +2 -2
  288. package/xll/python/Lib/site-packages/pip/_internal/network/download.py +58 -11
  289. package/xll/python/Lib/site-packages/pip/_internal/network/session.py +35 -40
  290. package/xll/python/Lib/site-packages/pip/_internal/network/utils.py +109 -1
  291. package/xll/python/Lib/site-packages/pip/_internal/operations/check.py +2 -3
  292. package/xll/python/Lib/site-packages/pip/_internal/operations/install/wheel.py +23 -18
  293. package/xll/python/Lib/site-packages/pip/_internal/operations/prepare.py +152 -7
  294. package/xll/python/Lib/site-packages/pip/_internal/req/__init__.py +2 -0
  295. package/xll/python/Lib/site-packages/pip/_internal/req/constructors.py +54 -69
  296. package/xll/python/Lib/site-packages/pip/_internal/req/req_file.py +6 -6
  297. package/xll/python/Lib/site-packages/pip/_internal/req/req_install.py +25 -21
  298. package/xll/python/Lib/site-packages/pip/_internal/req/req_uninstall.py +13 -8
  299. package/xll/python/Lib/site-packages/pip/_internal/resolution/base.py +2 -2
  300. package/xll/python/Lib/site-packages/pip/_internal/resolution/legacy/resolver.py +2 -2
  301. package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/base.py +1 -1
  302. package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py +0 -1
  303. package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py +39 -52
  304. package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +3 -3
  305. package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py +3 -0
  306. package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/resolver.py +9 -0
  307. package/xll/python/Lib/site-packages/pip/_internal/utils/compat.py +15 -9
  308. package/xll/python/Lib/site-packages/pip/_internal/utils/deprecation.py +6 -1
  309. package/xll/python/Lib/site-packages/pip/_internal/utils/filesystem.py +2 -2
  310. package/xll/python/Lib/site-packages/pip/_internal/utils/logging.py +11 -3
  311. package/xll/python/Lib/site-packages/pip/_internal/utils/misc.py +48 -4
  312. package/xll/python/Lib/site-packages/pip/_internal/utils/pylock.py +18 -2
  313. package/xll/python/Lib/site-packages/pip/_internal/utils/retry.py +2 -1
  314. package/xll/python/Lib/site-packages/pip/_internal/utils/subprocess.py +4 -3
  315. package/xll/python/Lib/site-packages/pip/_internal/utils/temp_dir.py +1 -2
  316. package/xll/python/Lib/site-packages/pip/_internal/utils/unpacking.py +30 -4
  317. package/xll/python/Lib/site-packages/pip/_internal/utils/urls.py +5 -2
  318. package/xll/python/Lib/site-packages/pip/_internal/utils/virtualenv.py +2 -36
  319. package/xll/python/Lib/site-packages/pip/_internal/vcs/git.py +8 -5
  320. package/xll/python/Lib/site-packages/pip/_internal/vcs/versioncontrol.py +1 -2
  321. package/xll/python/Lib/site-packages/pip/_internal/wheel_builder.py +5 -1
  322. package/xll/python/Lib/site-packages/pip/_vendor/bom.cdx.json +231 -0
  323. package/xll/python/Lib/site-packages/pip/_vendor/certifi/__init__.py +1 -1
  324. package/xll/python/Lib/site-packages/pip/_vendor/certifi/cacert.pem +0 -631
  325. package/xll/python/Lib/site-packages/pip/_vendor/distlib/__init__.py +1 -1
  326. package/xll/python/Lib/site-packages/pip/_vendor/distlib/compat.py +34 -64
  327. package/xll/python/Lib/site-packages/pip/_vendor/distlib/resources.py +28 -14
  328. package/xll/python/Lib/site-packages/pip/_vendor/distlib/scripts.py +7 -3
  329. package/xll/python/Lib/site-packages/pip/_vendor/distlib/util.py +48 -11
  330. package/xll/python/Lib/site-packages/pip/_vendor/idna/LICENSE.md +1 -1
  331. package/xll/python/Lib/site-packages/pip/_vendor/idna/__main__.py +6 -0
  332. package/xll/python/Lib/site-packages/pip/_vendor/idna/cli.py +128 -0
  333. package/xll/python/Lib/site-packages/pip/_vendor/idna/codec.py +50 -13
  334. package/xll/python/Lib/site-packages/pip/_vendor/idna/compat.py +26 -0
  335. package/xll/python/Lib/site-packages/pip/_vendor/idna/core.py +352 -141
  336. package/xll/python/Lib/site-packages/pip/_vendor/idna/idnadata.py +571 -2983
  337. package/xll/python/Lib/site-packages/pip/_vendor/idna/intranges.py +5 -7
  338. package/xll/python/Lib/site-packages/pip/_vendor/idna/package_data.py +1 -1
  339. package/xll/python/Lib/site-packages/pip/_vendor/idna/uts46data.py +16887 -8832
  340. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/__init__.py +352 -66
  341. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/__main__.py +11 -0
  342. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/_xdg.py +171 -0
  343. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/android.py +92 -41
  344. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/api.py +213 -49
  345. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/macos.py +128 -51
  346. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/unix.py +176 -127
  347. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/version.py +8 -18
  348. package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/windows.py +185 -68
  349. package/xll/python/Lib/site-packages/pip/_vendor/pygments/__init__.py +2 -2
  350. package/xll/python/Lib/site-packages/pip/_vendor/pygments/__main__.py +1 -1
  351. package/xll/python/Lib/site-packages/pip/_vendor/pygments/console.py +1 -1
  352. package/xll/python/Lib/site-packages/pip/_vendor/pygments/filter.py +1 -1
  353. package/xll/python/Lib/site-packages/pip/_vendor/pygments/filters/__init__.py +10 -8
  354. package/xll/python/Lib/site-packages/pip/_vendor/pygments/formatter.py +1 -1
  355. package/xll/python/Lib/site-packages/pip/_vendor/pygments/formatters/__init__.py +1 -1
  356. package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexer.py +7 -5
  357. package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexers/__init__.py +1 -1
  358. package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexers/_mapping.py +9 -8
  359. package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexers/python.py +35 -32
  360. package/xll/python/Lib/site-packages/pip/_vendor/pygments/modeline.py +1 -1
  361. package/xll/python/Lib/site-packages/pip/_vendor/pygments/plugin.py +3 -1
  362. package/xll/python/Lib/site-packages/pip/_vendor/pygments/regexopt.py +13 -2
  363. package/xll/python/Lib/site-packages/pip/_vendor/pygments/scanner.py +1 -1
  364. package/xll/python/Lib/site-packages/pip/_vendor/pygments/sphinxext.py +1 -1
  365. package/xll/python/Lib/site-packages/pip/_vendor/pygments/style.py +1 -1
  366. package/xll/python/Lib/site-packages/pip/_vendor/pygments/styles/__init__.py +1 -1
  367. package/xll/python/Lib/site-packages/pip/_vendor/pygments/token.py +1 -1
  368. package/xll/python/Lib/site-packages/pip/_vendor/pygments/unistring.py +1 -1
  369. package/xll/python/Lib/site-packages/pip/_vendor/pygments/util.py +2 -2
  370. package/xll/python/Lib/site-packages/pip/_vendor/requests/__init__.py +52 -16
  371. package/xll/python/Lib/site-packages/pip/_vendor/requests/__version__.py +2 -2
  372. package/xll/python/Lib/site-packages/pip/_vendor/requests/_internal_utils.py +2 -2
  373. package/xll/python/Lib/site-packages/pip/_vendor/requests/_types.py +183 -0
  374. package/xll/python/Lib/site-packages/pip/_vendor/requests/adapters.py +101 -50
  375. package/xll/python/Lib/site-packages/pip/_vendor/requests/api.py +31 -8
  376. package/xll/python/Lib/site-packages/pip/_vendor/requests/auth.py +80 -40
  377. package/xll/python/Lib/site-packages/pip/_vendor/requests/compat.py +9 -3
  378. package/xll/python/Lib/site-packages/pip/_vendor/requests/cookies.py +143 -79
  379. package/xll/python/Lib/site-packages/pip/_vendor/requests/exceptions.py +15 -5
  380. package/xll/python/Lib/site-packages/pip/_vendor/requests/help.py +13 -10
  381. package/xll/python/Lib/site-packages/pip/_vendor/requests/hooks.py +23 -9
  382. package/xll/python/Lib/site-packages/pip/_vendor/requests/models.py +265 -126
  383. package/xll/python/Lib/site-packages/pip/_vendor/requests/py.typed +0 -0
  384. package/xll/python/Lib/site-packages/pip/_vendor/requests/sessions.py +164 -78
  385. package/xll/python/Lib/site-packages/pip/_vendor/requests/status_codes.py +2 -2
  386. package/xll/python/Lib/site-packages/pip/_vendor/requests/structures.py +51 -20
  387. package/xll/python/Lib/site-packages/pip/_vendor/requests/utils.py +161 -89
  388. package/xll/python/Lib/site-packages/pip/_vendor/tomli/__init__.py +1 -1
  389. package/xll/python/Lib/site-packages/pip/_vendor/tomli/_parser.py +9 -4
  390. package/xll/python/Lib/site-packages/pip/_vendor/tomli/_re.py +13 -9
  391. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/_base_connection.py +3 -1
  392. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/_collections.py +0 -1
  393. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/_version.py +8 -18
  394. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/connection.py +4 -4
  395. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +23 -10
  396. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/contrib/emscripten/response.py +5 -1
  397. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +7 -8
  398. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py +1 -1
  399. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/exceptions.py +2 -2
  400. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/fields.py +14 -14
  401. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/poolmanager.py +8 -6
  402. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/response.py +35 -22
  403. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/util/retry.py +8 -0
  404. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/util/ssl_.py +11 -61
  405. package/xll/python/Lib/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +5 -11
  406. package/xll/python/Lib/site-packages/pip/_vendor/vendor.txt +8 -8
  407. package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/METADATA +3 -2
  408. package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/RECORD +208 -188
  409. package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/AUTHORS.txt +20 -0
  410. package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/idna/LICENSE.md +1 -1
  411. package/xll/python/Lib/site-packages/pywin32-311.dist-info/RECORD +2 -2
  412. package/xll/python/Scripts/httpx.exe +0 -0
  413. package/xll/python/Scripts/idna.exe +0 -0
  414. package/xll/python/Scripts/pip.exe +0 -0
  415. package/xll/python/Scripts/pip3.13.exe +0 -0
  416. package/xll/python/Scripts/pip3.exe +0 -0
  417. package/xll/python/Scripts/pywin32_postinstall.exe +0 -0
  418. package/xll/python/Scripts/pywin32_testall.exe +0 -0
  419. package/dist/app/collab/awareness.d.ts +0 -32
  420. package/dist/app/collab/awareness.js +0 -52
  421. package/dist/app/collab/collab-client.d.ts +0 -37
  422. package/dist/app/collab/collab-client.js +0 -208
  423. package/dist/app/collab/collab-manager.d.ts +0 -91
  424. package/dist/app/collab/collab-manager.js +0 -218
  425. package/dist/app/collab/collab-sync.d.ts +0 -62
  426. package/dist/app/collab/collab-sync.js +0 -215
  427. package/dist/app/collab/index.d.ts +0 -9
  428. package/dist/app/collab/index.js +0 -6
  429. package/dist/app/collab/super-fight.d.ts +0 -90
  430. package/dist/app/collab/super-fight.js +0 -310
  431. package/dist/app/collab/sync-bridge.d.ts +0 -35
  432. package/dist/app/collab/sync-bridge.js +0 -109
  433. package/dist/app/collab/types.d.ts +0 -75
  434. package/dist/app/collab/types.js +0 -5
  435. package/dist/embedded-agent/ai-content.d.ts +0 -52
  436. package/dist/embedded-agent/ai-content.js +0 -101
  437. package/dist/embedded-agent/host-tools/shared/llm-stream.d.ts +0 -31
  438. package/dist/embedded-agent/host-tools/shared/llm-stream.js +0 -136
  439. package/dist/embedded-agent/model-call-orchestrator.d.ts +0 -22
  440. package/dist/embedded-agent/model-call-orchestrator.js +0 -22
  441. package/dist/embedded-agent/stream-errors.d.ts +0 -10
  442. package/dist/embedded-agent/stream-errors.js +0 -73
  443. package/dist/embedded-agent/stream-message-state.d.ts +0 -14
  444. package/dist/embedded-agent/stream-message-state.js +0 -271
  445. package/dist/embedded-agent/stream-sse.d.ts +0 -78
  446. package/dist/embedded-agent/stream-sse.js +0 -73
  447. package/dist/shell/approvals/task-spawn-approval.d.ts +0 -20
  448. package/dist/shell/approvals/task-spawn-approval.js +0 -93
  449. package/dist/shell/interactive/collab-command.d.ts +0 -9
  450. package/dist/shell/interactive/collab-command.js +0 -115
  451. package/dist/shell/interactive/super-fight-ui.d.ts +0 -80
  452. package/dist/shell/interactive/super-fight-ui.js +0 -484
  453. package/dist/shell/status/collab-status.d.ts +0 -18
  454. package/dist/shell/status/collab-status.js +0 -46
  455. package/xll/python/Lib/site-packages/pip/_internal/build_env.py +0 -606
  456. /package/dist/{tui → autocomplete}/skill-autocomplete.js +0 -0
  457. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/INSTALLER +0 -0
  458. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/REQUESTED +0 -0
  459. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/WHEEL +0 -0
  460. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/entry_points.txt +0 -0
  461. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/LICENSE.txt +0 -0
  462. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +0 -0
  463. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/certifi/LICENSE +0 -0
  464. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/distlib/LICENSE.txt +0 -0
  465. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/distro/LICENSE +0 -0
  466. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/msgpack/COPYING +0 -0
  467. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/packaging/LICENSE +0 -0
  468. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +0 -0
  469. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/packaging/LICENSE.BSD +0 -0
  470. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/pkg_resources/LICENSE +0 -0
  471. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/platformdirs/LICENSE +0 -0
  472. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/pygments/LICENSE +0 -0
  473. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +0 -0
  474. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/requests/LICENSE +0 -0
  475. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/resolvelib/LICENSE +0 -0
  476. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/rich/LICENSE +0 -0
  477. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/tomli/LICENSE +0 -0
  478. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/tomli_w/LICENSE +0 -0
  479. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/truststore/LICENSE +0 -0
  480. /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/urllib3/LICENSE.txt +0 -0
@@ -1,16 +1,30 @@
1
1
  import { app, BrowserWindow, ipcMain, dialog, shell } from "electron";
2
2
  import { resolve, extname, basename, join, dirname, isAbsolute } from "node:path";
3
- import { open, stat, readFile } from "node:fs/promises";
3
+ import { open, stat, readFile, unlink } from "node:fs/promises";
4
4
  import require$$1 from "tty";
5
5
  import require$$1$1 from "util";
6
- import require$$0 from "os";
6
+ import require$$0, { homedir, platform, arch } from "os";
7
7
  import { createRequire } from "module";
8
8
  import * as path from "path";
9
+ import path__default, { dirname as dirname$1, join as join$1, basename as basename$1 } from "path";
9
10
  import { fileURLToPath } from "url";
10
11
  import { spawn } from "node:child_process";
11
12
  import * as readline from "node:readline";
12
13
  import { randomUUID } from "node:crypto";
13
14
  import { createRequire as createRequire$1 } from "node:module";
15
+ import process$1 from "node:process";
16
+ import os from "node:os";
17
+ import tty from "node:tty";
18
+ import { spawnSync } from "child_process";
19
+ import require$$0$2, { readFileSync, existsSync, mkdirSync, renameSync, chmodSync, rmSync, readdirSync, statSync } from "fs";
20
+ import require$$0$1 from "buffer";
21
+ import require$$6 from "stream";
22
+ import require$$1$2 from "zlib";
23
+ import require$$4 from "events";
24
+ import "crypto";
25
+ import { createWriteStream } from "node:fs";
26
+ import { Readable } from "node:stream";
27
+ import { pipeline } from "node:stream/promises";
14
28
  import __cjs_mod__ from "node:module";
15
29
  const __filename = import.meta.filename;
16
30
  const __dirname = import.meta.dirname;
@@ -1052,7 +1066,7 @@ var hasRequiredCommon;
1052
1066
  function requireCommon() {
1053
1067
  if (hasRequiredCommon) return common;
1054
1068
  hasRequiredCommon = 1;
1055
- function setup(env) {
1069
+ function setup(env2) {
1056
1070
  createDebug.debug = createDebug;
1057
1071
  createDebug.default = createDebug;
1058
1072
  createDebug.coerce = coerce;
@@ -1061,8 +1075,8 @@ function requireCommon() {
1061
1075
  createDebug.enabled = enabled;
1062
1076
  createDebug.humanize = requireMs();
1063
1077
  createDebug.destroy = destroy;
1064
- Object.keys(env).forEach((key) => {
1065
- createDebug[key] = env[key];
1078
+ Object.keys(env2).forEach((key) => {
1079
+ createDebug[key] = env2[key];
1066
1080
  });
1067
1081
  createDebug.names = [];
1068
1082
  createDebug.skips = [];
@@ -1398,46 +1412,46 @@ function requireBrowser() {
1398
1412
  return browser.exports;
1399
1413
  }
1400
1414
  var node = { exports: {} };
1401
- var hasFlag;
1415
+ var hasFlag$1;
1402
1416
  var hasRequiredHasFlag;
1403
1417
  function requireHasFlag() {
1404
- if (hasRequiredHasFlag) return hasFlag;
1418
+ if (hasRequiredHasFlag) return hasFlag$1;
1405
1419
  hasRequiredHasFlag = 1;
1406
- hasFlag = (flag, argv = process.argv) => {
1420
+ hasFlag$1 = (flag, argv = process.argv) => {
1407
1421
  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1408
1422
  const position = argv.indexOf(prefix + flag);
1409
1423
  const terminatorPosition = argv.indexOf("--");
1410
1424
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1411
1425
  };
1412
- return hasFlag;
1426
+ return hasFlag$1;
1413
1427
  }
1414
1428
  var supportsColor_1;
1415
1429
  var hasRequiredSupportsColor;
1416
1430
  function requireSupportsColor() {
1417
1431
  if (hasRequiredSupportsColor) return supportsColor_1;
1418
1432
  hasRequiredSupportsColor = 1;
1419
- const os = require$$0;
1420
- const tty = require$$1;
1433
+ const os2 = require$$0;
1434
+ const tty2 = require$$1;
1421
1435
  const hasFlag2 = requireHasFlag();
1422
- const { env } = process;
1423
- let flagForceColor;
1436
+ const { env: env2 } = process;
1437
+ let flagForceColor2;
1424
1438
  if (hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false") || hasFlag2("color=never")) {
1425
- flagForceColor = 0;
1439
+ flagForceColor2 = 0;
1426
1440
  } else if (hasFlag2("color") || hasFlag2("colors") || hasFlag2("color=true") || hasFlag2("color=always")) {
1427
- flagForceColor = 1;
1441
+ flagForceColor2 = 1;
1428
1442
  }
1429
- function envForceColor() {
1430
- if ("FORCE_COLOR" in env) {
1431
- if (env.FORCE_COLOR === "true") {
1443
+ function envForceColor2() {
1444
+ if ("FORCE_COLOR" in env2) {
1445
+ if (env2.FORCE_COLOR === "true") {
1432
1446
  return 1;
1433
1447
  }
1434
- if (env.FORCE_COLOR === "false") {
1448
+ if (env2.FORCE_COLOR === "false") {
1435
1449
  return 0;
1436
1450
  }
1437
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
1451
+ return env2.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
1438
1452
  }
1439
1453
  }
1440
- function translateLevel(level) {
1454
+ function translateLevel2(level) {
1441
1455
  if (level === 0) {
1442
1456
  return false;
1443
1457
  }
@@ -1448,12 +1462,12 @@ function requireSupportsColor() {
1448
1462
  has16m: level >= 3
1449
1463
  };
1450
1464
  }
1451
- function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1452
- const noFlagForceColor = envForceColor();
1465
+ function supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1466
+ const noFlagForceColor = envForceColor2();
1453
1467
  if (noFlagForceColor !== void 0) {
1454
- flagForceColor = noFlagForceColor;
1468
+ flagForceColor2 = noFlagForceColor;
1455
1469
  }
1456
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
1470
+ const forceColor = sniffFlags ? flagForceColor2 : noFlagForceColor;
1457
1471
  if (forceColor === 0) {
1458
1472
  return 0;
1459
1473
  }
@@ -1469,59 +1483,59 @@ function requireSupportsColor() {
1469
1483
  return 0;
1470
1484
  }
1471
1485
  const min = forceColor || 0;
1472
- if (env.TERM === "dumb") {
1486
+ if (env2.TERM === "dumb") {
1473
1487
  return min;
1474
1488
  }
1475
1489
  if (process.platform === "win32") {
1476
- const osRelease = os.release().split(".");
1490
+ const osRelease = os2.release().split(".");
1477
1491
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1478
1492
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
1479
1493
  }
1480
1494
  return 1;
1481
1495
  }
1482
- if ("CI" in env) {
1483
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1496
+ if ("CI" in env2) {
1497
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
1484
1498
  return 1;
1485
1499
  }
1486
1500
  return min;
1487
1501
  }
1488
- if ("TEAMCITY_VERSION" in env) {
1489
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1502
+ if ("TEAMCITY_VERSION" in env2) {
1503
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
1490
1504
  }
1491
- if (env.COLORTERM === "truecolor") {
1505
+ if (env2.COLORTERM === "truecolor") {
1492
1506
  return 3;
1493
1507
  }
1494
- if ("TERM_PROGRAM" in env) {
1495
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1496
- switch (env.TERM_PROGRAM) {
1508
+ if ("TERM_PROGRAM" in env2) {
1509
+ const version = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1510
+ switch (env2.TERM_PROGRAM) {
1497
1511
  case "iTerm.app":
1498
1512
  return version >= 3 ? 3 : 2;
1499
1513
  case "Apple_Terminal":
1500
1514
  return 2;
1501
1515
  }
1502
1516
  }
1503
- if (/-256(color)?$/i.test(env.TERM)) {
1517
+ if (/-256(color)?$/i.test(env2.TERM)) {
1504
1518
  return 2;
1505
1519
  }
1506
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1520
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
1507
1521
  return 1;
1508
1522
  }
1509
- if ("COLORTERM" in env) {
1523
+ if ("COLORTERM" in env2) {
1510
1524
  return 1;
1511
1525
  }
1512
1526
  return min;
1513
1527
  }
1514
1528
  function getSupportLevel(stream, options = {}) {
1515
- const level = supportsColor(stream, {
1529
+ const level = supportsColor2(stream, {
1516
1530
  streamIsTTY: stream && stream.isTTY,
1517
1531
  ...options
1518
1532
  });
1519
- return translateLevel(level);
1533
+ return translateLevel2(level);
1520
1534
  }
1521
1535
  supportsColor_1 = {
1522
1536
  supportsColor: getSupportLevel,
1523
- stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
1524
- stderr: getSupportLevel({ isTTY: tty.isatty(2) })
1537
+ stdout: getSupportLevel({ isTTY: tty2.isatty(1) }),
1538
+ stderr: getSupportLevel({ isTTY: tty2.isatty(2) })
1525
1539
  };
1526
1540
  return supportsColor_1;
1527
1541
  }
@@ -1530,7 +1544,7 @@ function requireNode() {
1530
1544
  if (hasRequiredNode) return node.exports;
1531
1545
  hasRequiredNode = 1;
1532
1546
  (function(module, exports$1) {
1533
- const tty = require$$1;
1547
+ const tty2 = require$$1;
1534
1548
  const util = require$$1$1;
1535
1549
  exports$1.init = init;
1536
1550
  exports$1.log = log;
@@ -1545,8 +1559,8 @@ function requireNode() {
1545
1559
  );
1546
1560
  exports$1.colors = [6, 2, 3, 4, 5, 1];
1547
1561
  try {
1548
- const supportsColor = requireSupportsColor();
1549
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1562
+ const supportsColor2 = requireSupportsColor();
1563
+ if (supportsColor2 && (supportsColor2.stderr || supportsColor2).level >= 2) {
1550
1564
  exports$1.colors = [
1551
1565
  20,
1552
1566
  21,
@@ -1648,7 +1662,7 @@ function requireNode() {
1648
1662
  return obj;
1649
1663
  }, {});
1650
1664
  function useColors() {
1651
- return "colors" in exports$1.inspectOpts ? Boolean(exports$1.inspectOpts.colors) : tty.isatty(process.stderr.fd);
1665
+ return "colors" in exports$1.inspectOpts ? Boolean(exports$1.inspectOpts.colors) : tty2.isatty(process.stderr.fd);
1652
1666
  }
1653
1667
  function formatArgs(args) {
1654
1668
  const { namespace: name, useColors: useColors2 } = this;
@@ -4744,7 +4758,7 @@ async function loadPhoton() {
4744
4758
  loadPromise = (async () => {
4745
4759
  const restoreReadFileSync = patchPhotonWasmRead();
4746
4760
  try {
4747
- photonModule = await import("./photon_rs-SoVDgheu.js").then((n) => n.p);
4761
+ photonModule = await import("./photon_rs-XkYyYTVA.js").then((n) => n.p);
4748
4762
  return photonModule;
4749
4763
  } catch {
4750
4764
  photonModule = null;
@@ -5251,6 +5265,7 @@ const AgentIpcChannel = {
5251
5265
  Event: "agent:event",
5252
5266
  OpenWorkspace: "agent:open-workspace",
5253
5267
  PickAttachments: "agent:pick-attachments",
5268
+ FileMentionSuggestions: "agent:file-mention-suggestions",
5254
5269
  OpenFolder: "app:open-folder",
5255
5270
  Quit: "app:quit"
5256
5271
  };
@@ -5344,6 +5359,3137 @@ class AgentProcessManager {
5344
5359
  await Promise.all([...this.agents.keys()].map((hostId) => this.stop(hostId)));
5345
5360
  }
5346
5361
  }
5362
+ const ANSI_BACKGROUND_OFFSET = 10;
5363
+ const wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
5364
+ const wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
5365
+ const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
5366
+ const styles$1 = {
5367
+ modifier: {
5368
+ reset: [0, 0],
5369
+ // 21 isn't widely supported and 22 does the same thing
5370
+ bold: [1, 22],
5371
+ dim: [2, 22],
5372
+ italic: [3, 23],
5373
+ underline: [4, 24],
5374
+ overline: [53, 55],
5375
+ inverse: [7, 27],
5376
+ hidden: [8, 28],
5377
+ strikethrough: [9, 29]
5378
+ },
5379
+ color: {
5380
+ black: [30, 39],
5381
+ red: [31, 39],
5382
+ green: [32, 39],
5383
+ yellow: [33, 39],
5384
+ blue: [34, 39],
5385
+ magenta: [35, 39],
5386
+ cyan: [36, 39],
5387
+ white: [37, 39],
5388
+ // Bright color
5389
+ blackBright: [90, 39],
5390
+ gray: [90, 39],
5391
+ // Alias of `blackBright`
5392
+ grey: [90, 39],
5393
+ // Alias of `blackBright`
5394
+ redBright: [91, 39],
5395
+ greenBright: [92, 39],
5396
+ yellowBright: [93, 39],
5397
+ blueBright: [94, 39],
5398
+ magentaBright: [95, 39],
5399
+ cyanBright: [96, 39],
5400
+ whiteBright: [97, 39]
5401
+ },
5402
+ bgColor: {
5403
+ bgBlack: [40, 49],
5404
+ bgRed: [41, 49],
5405
+ bgGreen: [42, 49],
5406
+ bgYellow: [43, 49],
5407
+ bgBlue: [44, 49],
5408
+ bgMagenta: [45, 49],
5409
+ bgCyan: [46, 49],
5410
+ bgWhite: [47, 49],
5411
+ // Bright color
5412
+ bgBlackBright: [100, 49],
5413
+ bgGray: [100, 49],
5414
+ // Alias of `bgBlackBright`
5415
+ bgGrey: [100, 49],
5416
+ // Alias of `bgBlackBright`
5417
+ bgRedBright: [101, 49],
5418
+ bgGreenBright: [102, 49],
5419
+ bgYellowBright: [103, 49],
5420
+ bgBlueBright: [104, 49],
5421
+ bgMagentaBright: [105, 49],
5422
+ bgCyanBright: [106, 49],
5423
+ bgWhiteBright: [107, 49]
5424
+ }
5425
+ };
5426
+ Object.keys(styles$1.modifier);
5427
+ const foregroundColorNames = Object.keys(styles$1.color);
5428
+ const backgroundColorNames = Object.keys(styles$1.bgColor);
5429
+ [...foregroundColorNames, ...backgroundColorNames];
5430
+ function assembleStyles() {
5431
+ const codes = /* @__PURE__ */ new Map();
5432
+ for (const [groupName, group] of Object.entries(styles$1)) {
5433
+ for (const [styleName, style] of Object.entries(group)) {
5434
+ styles$1[styleName] = {
5435
+ open: `\x1B[${style[0]}m`,
5436
+ close: `\x1B[${style[1]}m`
5437
+ };
5438
+ group[styleName] = styles$1[styleName];
5439
+ codes.set(style[0], style[1]);
5440
+ }
5441
+ Object.defineProperty(styles$1, groupName, {
5442
+ value: group,
5443
+ enumerable: false
5444
+ });
5445
+ }
5446
+ Object.defineProperty(styles$1, "codes", {
5447
+ value: codes,
5448
+ enumerable: false
5449
+ });
5450
+ styles$1.color.close = "\x1B[39m";
5451
+ styles$1.bgColor.close = "\x1B[49m";
5452
+ styles$1.color.ansi = wrapAnsi16();
5453
+ styles$1.color.ansi256 = wrapAnsi256();
5454
+ styles$1.color.ansi16m = wrapAnsi16m();
5455
+ styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
5456
+ styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
5457
+ styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
5458
+ Object.defineProperties(styles$1, {
5459
+ rgbToAnsi256: {
5460
+ value(red, green, blue) {
5461
+ if (red === green && green === blue) {
5462
+ if (red < 8) {
5463
+ return 16;
5464
+ }
5465
+ if (red > 248) {
5466
+ return 231;
5467
+ }
5468
+ return Math.round((red - 8) / 247 * 24) + 232;
5469
+ }
5470
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
5471
+ },
5472
+ enumerable: false
5473
+ },
5474
+ hexToRgb: {
5475
+ value(hex) {
5476
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
5477
+ if (!matches) {
5478
+ return [0, 0, 0];
5479
+ }
5480
+ let [colorString] = matches;
5481
+ if (colorString.length === 3) {
5482
+ colorString = [...colorString].map((character) => character + character).join("");
5483
+ }
5484
+ const integer = Number.parseInt(colorString, 16);
5485
+ return [
5486
+ /* eslint-disable no-bitwise */
5487
+ integer >> 16 & 255,
5488
+ integer >> 8 & 255,
5489
+ integer & 255
5490
+ /* eslint-enable no-bitwise */
5491
+ ];
5492
+ },
5493
+ enumerable: false
5494
+ },
5495
+ hexToAnsi256: {
5496
+ value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
5497
+ enumerable: false
5498
+ },
5499
+ ansi256ToAnsi: {
5500
+ value(code) {
5501
+ if (code < 8) {
5502
+ return 30 + code;
5503
+ }
5504
+ if (code < 16) {
5505
+ return 90 + (code - 8);
5506
+ }
5507
+ let red;
5508
+ let green;
5509
+ let blue;
5510
+ if (code >= 232) {
5511
+ red = ((code - 232) * 10 + 8) / 255;
5512
+ green = red;
5513
+ blue = red;
5514
+ } else {
5515
+ code -= 16;
5516
+ const remainder = code % 36;
5517
+ red = Math.floor(code / 36) / 5;
5518
+ green = Math.floor(remainder / 6) / 5;
5519
+ blue = remainder % 6 / 5;
5520
+ }
5521
+ const value = Math.max(red, green, blue) * 2;
5522
+ if (value === 0) {
5523
+ return 30;
5524
+ }
5525
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
5526
+ if (value === 2) {
5527
+ result += 60;
5528
+ }
5529
+ return result;
5530
+ },
5531
+ enumerable: false
5532
+ },
5533
+ rgbToAnsi: {
5534
+ value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
5535
+ enumerable: false
5536
+ },
5537
+ hexToAnsi: {
5538
+ value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
5539
+ enumerable: false
5540
+ }
5541
+ });
5542
+ return styles$1;
5543
+ }
5544
+ const ansiStyles = assembleStyles();
5545
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
5546
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
5547
+ const position = argv.indexOf(prefix + flag);
5548
+ const terminatorPosition = argv.indexOf("--");
5549
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
5550
+ }
5551
+ const { env } = process$1;
5552
+ let flagForceColor;
5553
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
5554
+ flagForceColor = 0;
5555
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
5556
+ flagForceColor = 1;
5557
+ }
5558
+ function envForceColor() {
5559
+ if ("FORCE_COLOR" in env) {
5560
+ if (env.FORCE_COLOR === "true") {
5561
+ return 1;
5562
+ }
5563
+ if (env.FORCE_COLOR === "false") {
5564
+ return 0;
5565
+ }
5566
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
5567
+ }
5568
+ }
5569
+ function translateLevel(level) {
5570
+ if (level === 0) {
5571
+ return false;
5572
+ }
5573
+ return {
5574
+ level,
5575
+ hasBasic: true,
5576
+ has256: level >= 2,
5577
+ has16m: level >= 3
5578
+ };
5579
+ }
5580
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
5581
+ const noFlagForceColor = envForceColor();
5582
+ if (noFlagForceColor !== void 0) {
5583
+ flagForceColor = noFlagForceColor;
5584
+ }
5585
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
5586
+ if (forceColor === 0) {
5587
+ return 0;
5588
+ }
5589
+ if (sniffFlags) {
5590
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
5591
+ return 3;
5592
+ }
5593
+ if (hasFlag("color=256")) {
5594
+ return 2;
5595
+ }
5596
+ }
5597
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
5598
+ return 1;
5599
+ }
5600
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
5601
+ return 0;
5602
+ }
5603
+ const min = forceColor || 0;
5604
+ if (env.TERM === "dumb") {
5605
+ return min;
5606
+ }
5607
+ if (process$1.platform === "win32") {
5608
+ const osRelease = os.release().split(".");
5609
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
5610
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
5611
+ }
5612
+ return 1;
5613
+ }
5614
+ if ("CI" in env) {
5615
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
5616
+ return 3;
5617
+ }
5618
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
5619
+ return 1;
5620
+ }
5621
+ return min;
5622
+ }
5623
+ if ("TEAMCITY_VERSION" in env) {
5624
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
5625
+ }
5626
+ if (env.COLORTERM === "truecolor") {
5627
+ return 3;
5628
+ }
5629
+ if (env.TERM === "xterm-kitty") {
5630
+ return 3;
5631
+ }
5632
+ if (env.TERM === "xterm-ghostty") {
5633
+ return 3;
5634
+ }
5635
+ if (env.TERM === "wezterm") {
5636
+ return 3;
5637
+ }
5638
+ if ("TERM_PROGRAM" in env) {
5639
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
5640
+ switch (env.TERM_PROGRAM) {
5641
+ case "iTerm.app": {
5642
+ return version >= 3 ? 3 : 2;
5643
+ }
5644
+ case "Apple_Terminal": {
5645
+ return 2;
5646
+ }
5647
+ }
5648
+ }
5649
+ if (/-256(color)?$/i.test(env.TERM)) {
5650
+ return 2;
5651
+ }
5652
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
5653
+ return 1;
5654
+ }
5655
+ if ("COLORTERM" in env) {
5656
+ return 1;
5657
+ }
5658
+ return min;
5659
+ }
5660
+ function createSupportsColor(stream, options = {}) {
5661
+ const level = _supportsColor(stream, {
5662
+ streamIsTTY: stream && stream.isTTY,
5663
+ ...options
5664
+ });
5665
+ return translateLevel(level);
5666
+ }
5667
+ const supportsColor = {
5668
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
5669
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
5670
+ };
5671
+ function stringReplaceAll(string, substring, replacer) {
5672
+ let index = string.indexOf(substring);
5673
+ if (index === -1) {
5674
+ return string;
5675
+ }
5676
+ const substringLength = substring.length;
5677
+ let endIndex = 0;
5678
+ let returnValue = "";
5679
+ do {
5680
+ returnValue += string.slice(endIndex, index) + substring + replacer;
5681
+ endIndex = index + substringLength;
5682
+ index = string.indexOf(substring, endIndex);
5683
+ } while (index !== -1);
5684
+ returnValue += string.slice(endIndex);
5685
+ return returnValue;
5686
+ }
5687
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
5688
+ let endIndex = 0;
5689
+ let returnValue = "";
5690
+ do {
5691
+ const gotCR = string[index - 1] === "\r";
5692
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
5693
+ endIndex = index + 1;
5694
+ index = string.indexOf("\n", endIndex);
5695
+ } while (index !== -1);
5696
+ returnValue += string.slice(endIndex);
5697
+ return returnValue;
5698
+ }
5699
+ const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
5700
+ const GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
5701
+ const STYLER = /* @__PURE__ */ Symbol("STYLER");
5702
+ const IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
5703
+ const levelMapping = [
5704
+ "ansi",
5705
+ "ansi",
5706
+ "ansi256",
5707
+ "ansi16m"
5708
+ ];
5709
+ const styles = /* @__PURE__ */ Object.create(null);
5710
+ const applyOptions = (object, options = {}) => {
5711
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5712
+ throw new Error("The `level` option should be an integer from 0 to 3");
5713
+ }
5714
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
5715
+ object.level = options.level === void 0 ? colorLevel : options.level;
5716
+ };
5717
+ const chalkFactory = (options) => {
5718
+ const chalk2 = (...strings) => strings.join(" ");
5719
+ applyOptions(chalk2, options);
5720
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
5721
+ return chalk2;
5722
+ };
5723
+ function createChalk(options) {
5724
+ return chalkFactory(options);
5725
+ }
5726
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
5727
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
5728
+ styles[styleName] = {
5729
+ get() {
5730
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
5731
+ Object.defineProperty(this, styleName, { value: builder });
5732
+ return builder;
5733
+ }
5734
+ };
5735
+ }
5736
+ styles.visible = {
5737
+ get() {
5738
+ const builder = createBuilder(this, this[STYLER], true);
5739
+ Object.defineProperty(this, "visible", { value: builder });
5740
+ return builder;
5741
+ }
5742
+ };
5743
+ const getModelAnsi = (model, level, type, ...arguments_) => {
5744
+ if (model === "rgb") {
5745
+ if (level === "ansi16m") {
5746
+ return ansiStyles[type].ansi16m(...arguments_);
5747
+ }
5748
+ if (level === "ansi256") {
5749
+ return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
5750
+ }
5751
+ return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
5752
+ }
5753
+ if (model === "hex") {
5754
+ return getModelAnsi("rgb", level, type, ...ansiStyles.hexToRgb(...arguments_));
5755
+ }
5756
+ return ansiStyles[type][model](...arguments_);
5757
+ };
5758
+ const usedModels = ["rgb", "hex", "ansi256"];
5759
+ for (const model of usedModels) {
5760
+ styles[model] = {
5761
+ get() {
5762
+ const { level } = this;
5763
+ return function(...arguments_) {
5764
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles.color.close, this[STYLER]);
5765
+ return createBuilder(this, styler, this[IS_EMPTY]);
5766
+ };
5767
+ }
5768
+ };
5769
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
5770
+ styles[bgModel] = {
5771
+ get() {
5772
+ const { level } = this;
5773
+ return function(...arguments_) {
5774
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
5775
+ return createBuilder(this, styler, this[IS_EMPTY]);
5776
+ };
5777
+ }
5778
+ };
5779
+ }
5780
+ const proto = Object.defineProperties(() => {
5781
+ }, {
5782
+ ...styles,
5783
+ level: {
5784
+ enumerable: true,
5785
+ get() {
5786
+ return this[GENERATOR].level;
5787
+ },
5788
+ set(level) {
5789
+ this[GENERATOR].level = level;
5790
+ }
5791
+ }
5792
+ });
5793
+ const createStyler = (open2, close, parent) => {
5794
+ let openAll;
5795
+ let closeAll;
5796
+ if (parent === void 0) {
5797
+ openAll = open2;
5798
+ closeAll = close;
5799
+ } else {
5800
+ openAll = parent.openAll + open2;
5801
+ closeAll = close + parent.closeAll;
5802
+ }
5803
+ return {
5804
+ open: open2,
5805
+ close,
5806
+ openAll,
5807
+ closeAll,
5808
+ parent
5809
+ };
5810
+ };
5811
+ const createBuilder = (self2, _styler, _isEmpty) => {
5812
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
5813
+ Object.setPrototypeOf(builder, proto);
5814
+ builder[GENERATOR] = self2;
5815
+ builder[STYLER] = _styler;
5816
+ builder[IS_EMPTY] = _isEmpty;
5817
+ return builder;
5818
+ };
5819
+ const applyStyle = (self2, string) => {
5820
+ if (self2.level <= 0 || !string) {
5821
+ return self2[IS_EMPTY] ? "" : string;
5822
+ }
5823
+ let styler = self2[STYLER];
5824
+ if (styler === void 0) {
5825
+ return string;
5826
+ }
5827
+ const { openAll, closeAll } = styler;
5828
+ if (string.includes("\x1B")) {
5829
+ while (styler !== void 0) {
5830
+ string = stringReplaceAll(string, styler.close, styler.open);
5831
+ styler = styler.parent;
5832
+ }
5833
+ }
5834
+ const lfIndex = string.indexOf("\n");
5835
+ if (lfIndex !== -1) {
5836
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
5837
+ }
5838
+ return openAll + string + closeAll;
5839
+ };
5840
+ Object.defineProperties(createChalk.prototype, styles);
5841
+ const chalk = createChalk();
5842
+ createChalk({ level: stderrColor ? stderrColor.level : 0 });
5843
+ var getStream = { exports: {} };
5844
+ var once = { exports: {} };
5845
+ var wrappy_1;
5846
+ var hasRequiredWrappy;
5847
+ function requireWrappy() {
5848
+ if (hasRequiredWrappy) return wrappy_1;
5849
+ hasRequiredWrappy = 1;
5850
+ wrappy_1 = wrappy;
5851
+ function wrappy(fn, cb) {
5852
+ if (fn && cb) return wrappy(fn)(cb);
5853
+ if (typeof fn !== "function")
5854
+ throw new TypeError("need wrapper function");
5855
+ Object.keys(fn).forEach(function(k) {
5856
+ wrapper[k] = fn[k];
5857
+ });
5858
+ return wrapper;
5859
+ function wrapper() {
5860
+ var args = new Array(arguments.length);
5861
+ for (var i = 0; i < args.length; i++) {
5862
+ args[i] = arguments[i];
5863
+ }
5864
+ var ret = fn.apply(this, args);
5865
+ var cb2 = args[args.length - 1];
5866
+ if (typeof ret === "function" && ret !== cb2) {
5867
+ Object.keys(cb2).forEach(function(k) {
5868
+ ret[k] = cb2[k];
5869
+ });
5870
+ }
5871
+ return ret;
5872
+ }
5873
+ }
5874
+ return wrappy_1;
5875
+ }
5876
+ var hasRequiredOnce;
5877
+ function requireOnce() {
5878
+ if (hasRequiredOnce) return once.exports;
5879
+ hasRequiredOnce = 1;
5880
+ var wrappy = requireWrappy();
5881
+ once.exports = wrappy(once$1);
5882
+ once.exports.strict = wrappy(onceStrict);
5883
+ once$1.proto = once$1(function() {
5884
+ Object.defineProperty(Function.prototype, "once", {
5885
+ value: function() {
5886
+ return once$1(this);
5887
+ },
5888
+ configurable: true
5889
+ });
5890
+ Object.defineProperty(Function.prototype, "onceStrict", {
5891
+ value: function() {
5892
+ return onceStrict(this);
5893
+ },
5894
+ configurable: true
5895
+ });
5896
+ });
5897
+ function once$1(fn) {
5898
+ var f = function() {
5899
+ if (f.called) return f.value;
5900
+ f.called = true;
5901
+ return f.value = fn.apply(this, arguments);
5902
+ };
5903
+ f.called = false;
5904
+ return f;
5905
+ }
5906
+ function onceStrict(fn) {
5907
+ var f = function() {
5908
+ if (f.called)
5909
+ throw new Error(f.onceError);
5910
+ f.called = true;
5911
+ return f.value = fn.apply(this, arguments);
5912
+ };
5913
+ var name = fn.name || "Function wrapped with `once`";
5914
+ f.onceError = name + " shouldn't be called more than once";
5915
+ f.called = false;
5916
+ return f;
5917
+ }
5918
+ return once.exports;
5919
+ }
5920
+ var endOfStream;
5921
+ var hasRequiredEndOfStream;
5922
+ function requireEndOfStream() {
5923
+ if (hasRequiredEndOfStream) return endOfStream;
5924
+ hasRequiredEndOfStream = 1;
5925
+ var once2 = requireOnce();
5926
+ var noop = function() {
5927
+ };
5928
+ var qnt = commonjsGlobal.Bare ? queueMicrotask : process.nextTick.bind(process);
5929
+ var isRequest = function(stream) {
5930
+ return stream.setHeader && typeof stream.abort === "function";
5931
+ };
5932
+ var isChildProcess = function(stream) {
5933
+ return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
5934
+ };
5935
+ var eos = function(stream, opts, callback) {
5936
+ if (typeof opts === "function") return eos(stream, null, opts);
5937
+ if (!opts) opts = {};
5938
+ callback = once2(callback || noop);
5939
+ var ws = stream._writableState;
5940
+ var rs = stream._readableState;
5941
+ var readable = opts.readable || opts.readable !== false && stream.readable;
5942
+ var writable = opts.writable || opts.writable !== false && stream.writable;
5943
+ var cancelled = false;
5944
+ var onlegacyfinish = function() {
5945
+ if (!stream.writable) onfinish();
5946
+ };
5947
+ var onfinish = function() {
5948
+ writable = false;
5949
+ if (!readable) callback.call(stream);
5950
+ };
5951
+ var onend = function() {
5952
+ readable = false;
5953
+ if (!writable) callback.call(stream);
5954
+ };
5955
+ var onexit = function(exitCode) {
5956
+ callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null);
5957
+ };
5958
+ var onerror = function(err) {
5959
+ callback.call(stream, err);
5960
+ };
5961
+ var onclose = function() {
5962
+ qnt(onclosenexttick);
5963
+ };
5964
+ var onclosenexttick = function() {
5965
+ if (cancelled) return;
5966
+ if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error("premature close"));
5967
+ if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error("premature close"));
5968
+ };
5969
+ var onrequest = function() {
5970
+ stream.req.on("finish", onfinish);
5971
+ };
5972
+ if (isRequest(stream)) {
5973
+ stream.on("complete", onfinish);
5974
+ stream.on("abort", onclose);
5975
+ if (stream.req) onrequest();
5976
+ else stream.on("request", onrequest);
5977
+ } else if (writable && !ws) {
5978
+ stream.on("end", onlegacyfinish);
5979
+ stream.on("close", onlegacyfinish);
5980
+ }
5981
+ if (isChildProcess(stream)) stream.on("exit", onexit);
5982
+ stream.on("end", onend);
5983
+ stream.on("finish", onfinish);
5984
+ if (opts.error !== false) stream.on("error", onerror);
5985
+ stream.on("close", onclose);
5986
+ return function() {
5987
+ cancelled = true;
5988
+ stream.removeListener("complete", onfinish);
5989
+ stream.removeListener("abort", onclose);
5990
+ stream.removeListener("request", onrequest);
5991
+ if (stream.req) stream.req.removeListener("finish", onfinish);
5992
+ stream.removeListener("end", onlegacyfinish);
5993
+ stream.removeListener("close", onlegacyfinish);
5994
+ stream.removeListener("finish", onfinish);
5995
+ stream.removeListener("exit", onexit);
5996
+ stream.removeListener("end", onend);
5997
+ stream.removeListener("error", onerror);
5998
+ stream.removeListener("close", onclose);
5999
+ };
6000
+ };
6001
+ endOfStream = eos;
6002
+ return endOfStream;
6003
+ }
6004
+ var pump_1;
6005
+ var hasRequiredPump;
6006
+ function requirePump() {
6007
+ if (hasRequiredPump) return pump_1;
6008
+ hasRequiredPump = 1;
6009
+ var once2 = requireOnce();
6010
+ var eos = requireEndOfStream();
6011
+ var fs2;
6012
+ try {
6013
+ fs2 = require2("fs");
6014
+ } catch (e) {
6015
+ }
6016
+ var noop = function() {
6017
+ };
6018
+ var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
6019
+ var isFn = function(fn) {
6020
+ return typeof fn === "function";
6021
+ };
6022
+ var isFS = function(stream) {
6023
+ if (!ancient) return false;
6024
+ if (!fs2) return false;
6025
+ return (stream instanceof (fs2.ReadStream || noop) || stream instanceof (fs2.WriteStream || noop)) && isFn(stream.close);
6026
+ };
6027
+ var isRequest = function(stream) {
6028
+ return stream.setHeader && isFn(stream.abort);
6029
+ };
6030
+ var destroyer = function(stream, reading, writing, callback) {
6031
+ callback = once2(callback);
6032
+ var closed = false;
6033
+ stream.on("close", function() {
6034
+ closed = true;
6035
+ });
6036
+ eos(stream, { readable: reading, writable: writing }, function(err) {
6037
+ if (err) return callback(err);
6038
+ closed = true;
6039
+ callback();
6040
+ });
6041
+ var destroyed = false;
6042
+ return function(err) {
6043
+ if (closed) return;
6044
+ if (destroyed) return;
6045
+ destroyed = true;
6046
+ if (isFS(stream)) return stream.close(noop);
6047
+ if (isRequest(stream)) return stream.abort();
6048
+ if (isFn(stream.destroy)) return stream.destroy();
6049
+ callback(err || new Error("stream was destroyed"));
6050
+ };
6051
+ };
6052
+ var call = function(fn) {
6053
+ fn();
6054
+ };
6055
+ var pipe = function(from, to) {
6056
+ return from.pipe(to);
6057
+ };
6058
+ var pump = function() {
6059
+ var streams = Array.prototype.slice.call(arguments);
6060
+ var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
6061
+ if (Array.isArray(streams[0])) streams = streams[0];
6062
+ if (streams.length < 2) throw new Error("pump requires two streams per minimum");
6063
+ var error;
6064
+ var destroys = streams.map(function(stream, i) {
6065
+ var reading = i < streams.length - 1;
6066
+ var writing = i > 0;
6067
+ return destroyer(stream, reading, writing, function(err) {
6068
+ if (!error) error = err;
6069
+ if (err) destroys.forEach(call);
6070
+ if (reading) return;
6071
+ destroys.forEach(call);
6072
+ callback(error);
6073
+ });
6074
+ });
6075
+ return streams.reduce(pipe);
6076
+ };
6077
+ pump_1 = pump;
6078
+ return pump_1;
6079
+ }
6080
+ var bufferStream;
6081
+ var hasRequiredBufferStream;
6082
+ function requireBufferStream() {
6083
+ if (hasRequiredBufferStream) return bufferStream;
6084
+ hasRequiredBufferStream = 1;
6085
+ const { PassThrough: PassThroughStream } = require$$6;
6086
+ bufferStream = (options) => {
6087
+ options = { ...options };
6088
+ const { array } = options;
6089
+ let { encoding } = options;
6090
+ const isBuffer = encoding === "buffer";
6091
+ let objectMode = false;
6092
+ if (array) {
6093
+ objectMode = !(encoding || isBuffer);
6094
+ } else {
6095
+ encoding = encoding || "utf8";
6096
+ }
6097
+ if (isBuffer) {
6098
+ encoding = null;
6099
+ }
6100
+ const stream = new PassThroughStream({ objectMode });
6101
+ if (encoding) {
6102
+ stream.setEncoding(encoding);
6103
+ }
6104
+ let length = 0;
6105
+ const chunks = [];
6106
+ stream.on("data", (chunk) => {
6107
+ chunks.push(chunk);
6108
+ if (objectMode) {
6109
+ length = chunks.length;
6110
+ } else {
6111
+ length += chunk.length;
6112
+ }
6113
+ });
6114
+ stream.getBufferedValue = () => {
6115
+ if (array) {
6116
+ return chunks;
6117
+ }
6118
+ return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
6119
+ };
6120
+ stream.getBufferedLength = () => length;
6121
+ return stream;
6122
+ };
6123
+ return bufferStream;
6124
+ }
6125
+ var hasRequiredGetStream;
6126
+ function requireGetStream() {
6127
+ if (hasRequiredGetStream) return getStream.exports;
6128
+ hasRequiredGetStream = 1;
6129
+ const { constants: BufferConstants } = require$$0$1;
6130
+ const pump = requirePump();
6131
+ const bufferStream2 = requireBufferStream();
6132
+ class MaxBufferError extends Error {
6133
+ constructor() {
6134
+ super("maxBuffer exceeded");
6135
+ this.name = "MaxBufferError";
6136
+ }
6137
+ }
6138
+ async function getStream$1(inputStream, options) {
6139
+ if (!inputStream) {
6140
+ return Promise.reject(new Error("Expected a stream"));
6141
+ }
6142
+ options = {
6143
+ maxBuffer: Infinity,
6144
+ ...options
6145
+ };
6146
+ const { maxBuffer } = options;
6147
+ let stream;
6148
+ await new Promise((resolve2, reject) => {
6149
+ const rejectPromise = (error) => {
6150
+ if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
6151
+ error.bufferedData = stream.getBufferedValue();
6152
+ }
6153
+ reject(error);
6154
+ };
6155
+ stream = pump(inputStream, bufferStream2(options), (error) => {
6156
+ if (error) {
6157
+ rejectPromise(error);
6158
+ return;
6159
+ }
6160
+ resolve2();
6161
+ });
6162
+ stream.on("data", () => {
6163
+ if (stream.getBufferedLength() > maxBuffer) {
6164
+ rejectPromise(new MaxBufferError());
6165
+ }
6166
+ });
6167
+ });
6168
+ return stream.getBufferedValue();
6169
+ }
6170
+ getStream.exports = getStream$1;
6171
+ getStream.exports.default = getStream$1;
6172
+ getStream.exports.buffer = (stream, options) => getStream$1(stream, { ...options, encoding: "buffer" });
6173
+ getStream.exports.array = (stream, options) => getStream$1(stream, { ...options, array: true });
6174
+ getStream.exports.MaxBufferError = MaxBufferError;
6175
+ return getStream.exports;
6176
+ }
6177
+ var yauzl = {};
6178
+ var fdSlicer = {};
6179
+ var pend;
6180
+ var hasRequiredPend;
6181
+ function requirePend() {
6182
+ if (hasRequiredPend) return pend;
6183
+ hasRequiredPend = 1;
6184
+ pend = Pend;
6185
+ function Pend() {
6186
+ this.pending = 0;
6187
+ this.max = Infinity;
6188
+ this.listeners = [];
6189
+ this.waiting = [];
6190
+ this.error = null;
6191
+ }
6192
+ Pend.prototype.go = function(fn) {
6193
+ if (this.pending < this.max) {
6194
+ pendGo(this, fn);
6195
+ } else {
6196
+ this.waiting.push(fn);
6197
+ }
6198
+ };
6199
+ Pend.prototype.wait = function(cb) {
6200
+ if (this.pending === 0) {
6201
+ cb(this.error);
6202
+ } else {
6203
+ this.listeners.push(cb);
6204
+ }
6205
+ };
6206
+ Pend.prototype.hold = function() {
6207
+ return pendHold(this);
6208
+ };
6209
+ function pendHold(self2) {
6210
+ self2.pending += 1;
6211
+ var called = false;
6212
+ return onCb;
6213
+ function onCb(err) {
6214
+ if (called) throw new Error("callback called twice");
6215
+ called = true;
6216
+ self2.error = self2.error || err;
6217
+ self2.pending -= 1;
6218
+ if (self2.waiting.length > 0 && self2.pending < self2.max) {
6219
+ pendGo(self2, self2.waiting.shift());
6220
+ } else if (self2.pending === 0) {
6221
+ var listeners = self2.listeners;
6222
+ self2.listeners = [];
6223
+ listeners.forEach(cbListener);
6224
+ }
6225
+ }
6226
+ function cbListener(listener) {
6227
+ listener(self2.error);
6228
+ }
6229
+ }
6230
+ function pendGo(self2, fn) {
6231
+ fn(pendHold(self2));
6232
+ }
6233
+ return pend;
6234
+ }
6235
+ var hasRequiredFdSlicer;
6236
+ function requireFdSlicer() {
6237
+ if (hasRequiredFdSlicer) return fdSlicer;
6238
+ hasRequiredFdSlicer = 1;
6239
+ var fs2 = require$$0$2;
6240
+ var util = require$$1$1;
6241
+ var stream = require$$6;
6242
+ var Readable2 = stream.Readable;
6243
+ var Writable = stream.Writable;
6244
+ var PassThrough = stream.PassThrough;
6245
+ var Pend = requirePend();
6246
+ var EventEmitter = require$$4.EventEmitter;
6247
+ fdSlicer.createFromBuffer = createFromBuffer;
6248
+ fdSlicer.createFromFd = createFromFd;
6249
+ fdSlicer.BufferSlicer = BufferSlicer;
6250
+ fdSlicer.FdSlicer = FdSlicer;
6251
+ util.inherits(FdSlicer, EventEmitter);
6252
+ function FdSlicer(fd, options) {
6253
+ options = options || {};
6254
+ EventEmitter.call(this);
6255
+ this.fd = fd;
6256
+ this.pend = new Pend();
6257
+ this.pend.max = 1;
6258
+ this.refCount = 0;
6259
+ this.autoClose = !!options.autoClose;
6260
+ }
6261
+ FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
6262
+ var self2 = this;
6263
+ self2.pend.go(function(cb) {
6264
+ fs2.read(self2.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
6265
+ cb();
6266
+ callback(err, bytesRead, buffer2);
6267
+ });
6268
+ });
6269
+ };
6270
+ FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
6271
+ var self2 = this;
6272
+ self2.pend.go(function(cb) {
6273
+ fs2.write(self2.fd, buffer, offset, length, position, function(err, written, buffer2) {
6274
+ cb();
6275
+ callback(err, written, buffer2);
6276
+ });
6277
+ });
6278
+ };
6279
+ FdSlicer.prototype.createReadStream = function(options) {
6280
+ return new ReadStream(this, options);
6281
+ };
6282
+ FdSlicer.prototype.createWriteStream = function(options) {
6283
+ return new WriteStream(this, options);
6284
+ };
6285
+ FdSlicer.prototype.ref = function() {
6286
+ this.refCount += 1;
6287
+ };
6288
+ FdSlicer.prototype.unref = function() {
6289
+ var self2 = this;
6290
+ self2.refCount -= 1;
6291
+ if (self2.refCount > 0) return;
6292
+ if (self2.refCount < 0) throw new Error("invalid unref");
6293
+ if (self2.autoClose) {
6294
+ fs2.close(self2.fd, onCloseDone);
6295
+ }
6296
+ function onCloseDone(err) {
6297
+ if (err) {
6298
+ self2.emit("error", err);
6299
+ } else {
6300
+ self2.emit("close");
6301
+ }
6302
+ }
6303
+ };
6304
+ util.inherits(ReadStream, Readable2);
6305
+ function ReadStream(context, options) {
6306
+ options = options || {};
6307
+ Readable2.call(this, options);
6308
+ this.context = context;
6309
+ this.context.ref();
6310
+ this.start = options.start || 0;
6311
+ this.endOffset = options.end;
6312
+ this.pos = this.start;
6313
+ this.destroyed = false;
6314
+ }
6315
+ ReadStream.prototype._read = function(n) {
6316
+ var self2 = this;
6317
+ if (self2.destroyed) return;
6318
+ var toRead = Math.min(self2._readableState.highWaterMark, n);
6319
+ if (self2.endOffset != null) {
6320
+ toRead = Math.min(toRead, self2.endOffset - self2.pos);
6321
+ }
6322
+ if (toRead <= 0) {
6323
+ self2.destroyed = true;
6324
+ self2.push(null);
6325
+ self2.context.unref();
6326
+ return;
6327
+ }
6328
+ self2.context.pend.go(function(cb) {
6329
+ if (self2.destroyed) return cb();
6330
+ var buffer = new Buffer(toRead);
6331
+ fs2.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err, bytesRead) {
6332
+ if (err) {
6333
+ self2.destroy(err);
6334
+ } else if (bytesRead === 0) {
6335
+ self2.destroyed = true;
6336
+ self2.push(null);
6337
+ self2.context.unref();
6338
+ } else {
6339
+ self2.pos += bytesRead;
6340
+ self2.push(buffer.slice(0, bytesRead));
6341
+ }
6342
+ cb();
6343
+ });
6344
+ });
6345
+ };
6346
+ ReadStream.prototype.destroy = function(err) {
6347
+ if (this.destroyed) return;
6348
+ err = err || new Error("stream destroyed");
6349
+ this.destroyed = true;
6350
+ this.emit("error", err);
6351
+ this.context.unref();
6352
+ };
6353
+ util.inherits(WriteStream, Writable);
6354
+ function WriteStream(context, options) {
6355
+ options = options || {};
6356
+ Writable.call(this, options);
6357
+ this.context = context;
6358
+ this.context.ref();
6359
+ this.start = options.start || 0;
6360
+ this.endOffset = options.end == null ? Infinity : +options.end;
6361
+ this.bytesWritten = 0;
6362
+ this.pos = this.start;
6363
+ this.destroyed = false;
6364
+ this.on("finish", this.destroy.bind(this));
6365
+ }
6366
+ WriteStream.prototype._write = function(buffer, encoding, callback) {
6367
+ var self2 = this;
6368
+ if (self2.destroyed) return;
6369
+ if (self2.pos + buffer.length > self2.endOffset) {
6370
+ var err = new Error("maximum file length exceeded");
6371
+ err.code = "ETOOBIG";
6372
+ self2.destroy();
6373
+ callback(err);
6374
+ return;
6375
+ }
6376
+ self2.context.pend.go(function(cb) {
6377
+ if (self2.destroyed) return cb();
6378
+ fs2.write(self2.context.fd, buffer, 0, buffer.length, self2.pos, function(err2, bytes) {
6379
+ if (err2) {
6380
+ self2.destroy();
6381
+ cb();
6382
+ callback(err2);
6383
+ } else {
6384
+ self2.bytesWritten += bytes;
6385
+ self2.pos += bytes;
6386
+ self2.emit("progress");
6387
+ cb();
6388
+ callback();
6389
+ }
6390
+ });
6391
+ });
6392
+ };
6393
+ WriteStream.prototype.destroy = function() {
6394
+ if (this.destroyed) return;
6395
+ this.destroyed = true;
6396
+ this.context.unref();
6397
+ };
6398
+ util.inherits(BufferSlicer, EventEmitter);
6399
+ function BufferSlicer(buffer, options) {
6400
+ EventEmitter.call(this);
6401
+ options = options || {};
6402
+ this.refCount = 0;
6403
+ this.buffer = buffer;
6404
+ this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
6405
+ }
6406
+ BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
6407
+ var end = position + length;
6408
+ var delta = end - this.buffer.length;
6409
+ var written = delta > 0 ? delta : length;
6410
+ this.buffer.copy(buffer, offset, position, end);
6411
+ setImmediate(function() {
6412
+ callback(null, written);
6413
+ });
6414
+ };
6415
+ BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
6416
+ buffer.copy(this.buffer, position, offset, offset + length);
6417
+ setImmediate(function() {
6418
+ callback(null, length, buffer);
6419
+ });
6420
+ };
6421
+ BufferSlicer.prototype.createReadStream = function(options) {
6422
+ options = options || {};
6423
+ var readStream = new PassThrough(options);
6424
+ readStream.destroyed = false;
6425
+ readStream.start = options.start || 0;
6426
+ readStream.endOffset = options.end;
6427
+ readStream.pos = readStream.endOffset || this.buffer.length;
6428
+ var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
6429
+ var offset = 0;
6430
+ while (true) {
6431
+ var nextOffset = offset + this.maxChunkSize;
6432
+ if (nextOffset >= entireSlice.length) {
6433
+ if (offset < entireSlice.length) {
6434
+ readStream.write(entireSlice.slice(offset, entireSlice.length));
6435
+ }
6436
+ break;
6437
+ }
6438
+ readStream.write(entireSlice.slice(offset, nextOffset));
6439
+ offset = nextOffset;
6440
+ }
6441
+ readStream.end();
6442
+ readStream.destroy = function() {
6443
+ readStream.destroyed = true;
6444
+ };
6445
+ return readStream;
6446
+ };
6447
+ BufferSlicer.prototype.createWriteStream = function(options) {
6448
+ var bufferSlicer = this;
6449
+ options = options || {};
6450
+ var writeStream = new Writable(options);
6451
+ writeStream.start = options.start || 0;
6452
+ writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
6453
+ writeStream.bytesWritten = 0;
6454
+ writeStream.pos = writeStream.start;
6455
+ writeStream.destroyed = false;
6456
+ writeStream._write = function(buffer, encoding, callback) {
6457
+ if (writeStream.destroyed) return;
6458
+ var end = writeStream.pos + buffer.length;
6459
+ if (end > writeStream.endOffset) {
6460
+ var err = new Error("maximum file length exceeded");
6461
+ err.code = "ETOOBIG";
6462
+ writeStream.destroyed = true;
6463
+ callback(err);
6464
+ return;
6465
+ }
6466
+ buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
6467
+ writeStream.bytesWritten += buffer.length;
6468
+ writeStream.pos = end;
6469
+ writeStream.emit("progress");
6470
+ callback();
6471
+ };
6472
+ writeStream.destroy = function() {
6473
+ writeStream.destroyed = true;
6474
+ };
6475
+ return writeStream;
6476
+ };
6477
+ BufferSlicer.prototype.ref = function() {
6478
+ this.refCount += 1;
6479
+ };
6480
+ BufferSlicer.prototype.unref = function() {
6481
+ this.refCount -= 1;
6482
+ if (this.refCount < 0) {
6483
+ throw new Error("invalid unref");
6484
+ }
6485
+ };
6486
+ function createFromBuffer(buffer, options) {
6487
+ return new BufferSlicer(buffer, options);
6488
+ }
6489
+ function createFromFd(fd, options) {
6490
+ return new FdSlicer(fd, options);
6491
+ }
6492
+ return fdSlicer;
6493
+ }
6494
+ var bufferCrc32;
6495
+ var hasRequiredBufferCrc32;
6496
+ function requireBufferCrc32() {
6497
+ if (hasRequiredBufferCrc32) return bufferCrc32;
6498
+ hasRequiredBufferCrc32 = 1;
6499
+ var Buffer2 = require$$0$1.Buffer;
6500
+ var CRC_TABLE = [
6501
+ 0,
6502
+ 1996959894,
6503
+ 3993919788,
6504
+ 2567524794,
6505
+ 124634137,
6506
+ 1886057615,
6507
+ 3915621685,
6508
+ 2657392035,
6509
+ 249268274,
6510
+ 2044508324,
6511
+ 3772115230,
6512
+ 2547177864,
6513
+ 162941995,
6514
+ 2125561021,
6515
+ 3887607047,
6516
+ 2428444049,
6517
+ 498536548,
6518
+ 1789927666,
6519
+ 4089016648,
6520
+ 2227061214,
6521
+ 450548861,
6522
+ 1843258603,
6523
+ 4107580753,
6524
+ 2211677639,
6525
+ 325883990,
6526
+ 1684777152,
6527
+ 4251122042,
6528
+ 2321926636,
6529
+ 335633487,
6530
+ 1661365465,
6531
+ 4195302755,
6532
+ 2366115317,
6533
+ 997073096,
6534
+ 1281953886,
6535
+ 3579855332,
6536
+ 2724688242,
6537
+ 1006888145,
6538
+ 1258607687,
6539
+ 3524101629,
6540
+ 2768942443,
6541
+ 901097722,
6542
+ 1119000684,
6543
+ 3686517206,
6544
+ 2898065728,
6545
+ 853044451,
6546
+ 1172266101,
6547
+ 3705015759,
6548
+ 2882616665,
6549
+ 651767980,
6550
+ 1373503546,
6551
+ 3369554304,
6552
+ 3218104598,
6553
+ 565507253,
6554
+ 1454621731,
6555
+ 3485111705,
6556
+ 3099436303,
6557
+ 671266974,
6558
+ 1594198024,
6559
+ 3322730930,
6560
+ 2970347812,
6561
+ 795835527,
6562
+ 1483230225,
6563
+ 3244367275,
6564
+ 3060149565,
6565
+ 1994146192,
6566
+ 31158534,
6567
+ 2563907772,
6568
+ 4023717930,
6569
+ 1907459465,
6570
+ 112637215,
6571
+ 2680153253,
6572
+ 3904427059,
6573
+ 2013776290,
6574
+ 251722036,
6575
+ 2517215374,
6576
+ 3775830040,
6577
+ 2137656763,
6578
+ 141376813,
6579
+ 2439277719,
6580
+ 3865271297,
6581
+ 1802195444,
6582
+ 476864866,
6583
+ 2238001368,
6584
+ 4066508878,
6585
+ 1812370925,
6586
+ 453092731,
6587
+ 2181625025,
6588
+ 4111451223,
6589
+ 1706088902,
6590
+ 314042704,
6591
+ 2344532202,
6592
+ 4240017532,
6593
+ 1658658271,
6594
+ 366619977,
6595
+ 2362670323,
6596
+ 4224994405,
6597
+ 1303535960,
6598
+ 984961486,
6599
+ 2747007092,
6600
+ 3569037538,
6601
+ 1256170817,
6602
+ 1037604311,
6603
+ 2765210733,
6604
+ 3554079995,
6605
+ 1131014506,
6606
+ 879679996,
6607
+ 2909243462,
6608
+ 3663771856,
6609
+ 1141124467,
6610
+ 855842277,
6611
+ 2852801631,
6612
+ 3708648649,
6613
+ 1342533948,
6614
+ 654459306,
6615
+ 3188396048,
6616
+ 3373015174,
6617
+ 1466479909,
6618
+ 544179635,
6619
+ 3110523913,
6620
+ 3462522015,
6621
+ 1591671054,
6622
+ 702138776,
6623
+ 2966460450,
6624
+ 3352799412,
6625
+ 1504918807,
6626
+ 783551873,
6627
+ 3082640443,
6628
+ 3233442989,
6629
+ 3988292384,
6630
+ 2596254646,
6631
+ 62317068,
6632
+ 1957810842,
6633
+ 3939845945,
6634
+ 2647816111,
6635
+ 81470997,
6636
+ 1943803523,
6637
+ 3814918930,
6638
+ 2489596804,
6639
+ 225274430,
6640
+ 2053790376,
6641
+ 3826175755,
6642
+ 2466906013,
6643
+ 167816743,
6644
+ 2097651377,
6645
+ 4027552580,
6646
+ 2265490386,
6647
+ 503444072,
6648
+ 1762050814,
6649
+ 4150417245,
6650
+ 2154129355,
6651
+ 426522225,
6652
+ 1852507879,
6653
+ 4275313526,
6654
+ 2312317920,
6655
+ 282753626,
6656
+ 1742555852,
6657
+ 4189708143,
6658
+ 2394877945,
6659
+ 397917763,
6660
+ 1622183637,
6661
+ 3604390888,
6662
+ 2714866558,
6663
+ 953729732,
6664
+ 1340076626,
6665
+ 3518719985,
6666
+ 2797360999,
6667
+ 1068828381,
6668
+ 1219638859,
6669
+ 3624741850,
6670
+ 2936675148,
6671
+ 906185462,
6672
+ 1090812512,
6673
+ 3747672003,
6674
+ 2825379669,
6675
+ 829329135,
6676
+ 1181335161,
6677
+ 3412177804,
6678
+ 3160834842,
6679
+ 628085408,
6680
+ 1382605366,
6681
+ 3423369109,
6682
+ 3138078467,
6683
+ 570562233,
6684
+ 1426400815,
6685
+ 3317316542,
6686
+ 2998733608,
6687
+ 733239954,
6688
+ 1555261956,
6689
+ 3268935591,
6690
+ 3050360625,
6691
+ 752459403,
6692
+ 1541320221,
6693
+ 2607071920,
6694
+ 3965973030,
6695
+ 1969922972,
6696
+ 40735498,
6697
+ 2617837225,
6698
+ 3943577151,
6699
+ 1913087877,
6700
+ 83908371,
6701
+ 2512341634,
6702
+ 3803740692,
6703
+ 2075208622,
6704
+ 213261112,
6705
+ 2463272603,
6706
+ 3855990285,
6707
+ 2094854071,
6708
+ 198958881,
6709
+ 2262029012,
6710
+ 4057260610,
6711
+ 1759359992,
6712
+ 534414190,
6713
+ 2176718541,
6714
+ 4139329115,
6715
+ 1873836001,
6716
+ 414664567,
6717
+ 2282248934,
6718
+ 4279200368,
6719
+ 1711684554,
6720
+ 285281116,
6721
+ 2405801727,
6722
+ 4167216745,
6723
+ 1634467795,
6724
+ 376229701,
6725
+ 2685067896,
6726
+ 3608007406,
6727
+ 1308918612,
6728
+ 956543938,
6729
+ 2808555105,
6730
+ 3495958263,
6731
+ 1231636301,
6732
+ 1047427035,
6733
+ 2932959818,
6734
+ 3654703836,
6735
+ 1088359270,
6736
+ 936918e3,
6737
+ 2847714899,
6738
+ 3736837829,
6739
+ 1202900863,
6740
+ 817233897,
6741
+ 3183342108,
6742
+ 3401237130,
6743
+ 1404277552,
6744
+ 615818150,
6745
+ 3134207493,
6746
+ 3453421203,
6747
+ 1423857449,
6748
+ 601450431,
6749
+ 3009837614,
6750
+ 3294710456,
6751
+ 1567103746,
6752
+ 711928724,
6753
+ 3020668471,
6754
+ 3272380065,
6755
+ 1510334235,
6756
+ 755167117
6757
+ ];
6758
+ if (typeof Int32Array !== "undefined") {
6759
+ CRC_TABLE = new Int32Array(CRC_TABLE);
6760
+ }
6761
+ function ensureBuffer(input) {
6762
+ if (Buffer2.isBuffer(input)) {
6763
+ return input;
6764
+ }
6765
+ var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
6766
+ if (typeof input === "number") {
6767
+ return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
6768
+ } else if (typeof input === "string") {
6769
+ return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
6770
+ } else {
6771
+ throw new Error("input must be buffer, number, or string, received " + typeof input);
6772
+ }
6773
+ }
6774
+ function bufferizeInt(num) {
6775
+ var tmp = ensureBuffer(4);
6776
+ tmp.writeInt32BE(num, 0);
6777
+ return tmp;
6778
+ }
6779
+ function _crc32(buf, previous) {
6780
+ buf = ensureBuffer(buf);
6781
+ if (Buffer2.isBuffer(previous)) {
6782
+ previous = previous.readUInt32BE(0);
6783
+ }
6784
+ var crc = ~~previous ^ -1;
6785
+ for (var n = 0; n < buf.length; n++) {
6786
+ crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
6787
+ }
6788
+ return crc ^ -1;
6789
+ }
6790
+ function crc32() {
6791
+ return bufferizeInt(_crc32.apply(null, arguments));
6792
+ }
6793
+ crc32.signed = function() {
6794
+ return _crc32.apply(null, arguments);
6795
+ };
6796
+ crc32.unsigned = function() {
6797
+ return _crc32.apply(null, arguments) >>> 0;
6798
+ };
6799
+ bufferCrc32 = crc32;
6800
+ return bufferCrc32;
6801
+ }
6802
+ var hasRequiredYauzl;
6803
+ function requireYauzl() {
6804
+ if (hasRequiredYauzl) return yauzl;
6805
+ hasRequiredYauzl = 1;
6806
+ var fs2 = require$$0$2;
6807
+ var zlib = require$$1$2;
6808
+ var fd_slicer = requireFdSlicer();
6809
+ var crc32 = requireBufferCrc32();
6810
+ var util = require$$1$1;
6811
+ var EventEmitter = require$$4.EventEmitter;
6812
+ var Transform = require$$6.Transform;
6813
+ var PassThrough = require$$6.PassThrough;
6814
+ var Writable = require$$6.Writable;
6815
+ yauzl.open = open2;
6816
+ yauzl.fromFd = fromFd;
6817
+ yauzl.fromBuffer = fromBuffer2;
6818
+ yauzl.fromRandomAccessReader = fromRandomAccessReader;
6819
+ yauzl.dosDateTimeToDate = dosDateTimeToDate;
6820
+ yauzl.validateFileName = validateFileName;
6821
+ yauzl.ZipFile = ZipFile;
6822
+ yauzl.Entry = Entry;
6823
+ yauzl.RandomAccessReader = RandomAccessReader;
6824
+ function open2(path2, options, callback) {
6825
+ if (typeof options === "function") {
6826
+ callback = options;
6827
+ options = null;
6828
+ }
6829
+ if (options == null) options = {};
6830
+ if (options.autoClose == null) options.autoClose = true;
6831
+ if (options.lazyEntries == null) options.lazyEntries = false;
6832
+ if (options.decodeStrings == null) options.decodeStrings = true;
6833
+ if (options.validateEntrySizes == null) options.validateEntrySizes = true;
6834
+ if (options.strictFileNames == null) options.strictFileNames = false;
6835
+ if (callback == null) callback = defaultCallback;
6836
+ fs2.open(path2, "r", function(err, fd) {
6837
+ if (err) return callback(err);
6838
+ fromFd(fd, options, function(err2, zipfile) {
6839
+ if (err2) fs2.close(fd, defaultCallback);
6840
+ callback(err2, zipfile);
6841
+ });
6842
+ });
6843
+ }
6844
+ function fromFd(fd, options, callback) {
6845
+ if (typeof options === "function") {
6846
+ callback = options;
6847
+ options = null;
6848
+ }
6849
+ if (options == null) options = {};
6850
+ if (options.autoClose == null) options.autoClose = false;
6851
+ if (options.lazyEntries == null) options.lazyEntries = false;
6852
+ if (options.decodeStrings == null) options.decodeStrings = true;
6853
+ if (options.validateEntrySizes == null) options.validateEntrySizes = true;
6854
+ if (options.strictFileNames == null) options.strictFileNames = false;
6855
+ if (callback == null) callback = defaultCallback;
6856
+ fs2.fstat(fd, function(err, stats) {
6857
+ if (err) return callback(err);
6858
+ var reader = fd_slicer.createFromFd(fd, { autoClose: true });
6859
+ fromRandomAccessReader(reader, stats.size, options, callback);
6860
+ });
6861
+ }
6862
+ function fromBuffer2(buffer, options, callback) {
6863
+ if (typeof options === "function") {
6864
+ callback = options;
6865
+ options = null;
6866
+ }
6867
+ if (options == null) options = {};
6868
+ options.autoClose = false;
6869
+ if (options.lazyEntries == null) options.lazyEntries = false;
6870
+ if (options.decodeStrings == null) options.decodeStrings = true;
6871
+ if (options.validateEntrySizes == null) options.validateEntrySizes = true;
6872
+ if (options.strictFileNames == null) options.strictFileNames = false;
6873
+ var reader = fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 });
6874
+ fromRandomAccessReader(reader, buffer.length, options, callback);
6875
+ }
6876
+ function fromRandomAccessReader(reader, totalSize, options, callback) {
6877
+ if (typeof options === "function") {
6878
+ callback = options;
6879
+ options = null;
6880
+ }
6881
+ if (options == null) options = {};
6882
+ if (options.autoClose == null) options.autoClose = true;
6883
+ if (options.lazyEntries == null) options.lazyEntries = false;
6884
+ if (options.decodeStrings == null) options.decodeStrings = true;
6885
+ var decodeStrings = !!options.decodeStrings;
6886
+ if (options.validateEntrySizes == null) options.validateEntrySizes = true;
6887
+ if (options.strictFileNames == null) options.strictFileNames = false;
6888
+ if (callback == null) callback = defaultCallback;
6889
+ if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
6890
+ if (totalSize > Number.MAX_SAFE_INTEGER) {
6891
+ throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
6892
+ }
6893
+ reader.ref();
6894
+ var eocdrWithoutCommentSize = 22;
6895
+ var maxCommentSize = 65535;
6896
+ var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
6897
+ var buffer = newBuffer(bufferSize);
6898
+ var bufferReadStart = totalSize - buffer.length;
6899
+ readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
6900
+ if (err) return callback(err);
6901
+ for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
6902
+ if (buffer.readUInt32LE(i) !== 101010256) continue;
6903
+ var eocdrBuffer = buffer.slice(i);
6904
+ var diskNumber = eocdrBuffer.readUInt16LE(4);
6905
+ if (diskNumber !== 0) {
6906
+ return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
6907
+ }
6908
+ var entryCount = eocdrBuffer.readUInt16LE(10);
6909
+ var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
6910
+ var commentLength = eocdrBuffer.readUInt16LE(20);
6911
+ var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
6912
+ if (commentLength !== expectedCommentLength) {
6913
+ return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
6914
+ }
6915
+ var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false) : eocdrBuffer.slice(22);
6916
+ if (!(entryCount === 65535 || centralDirectoryOffset === 4294967295)) {
6917
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
6918
+ }
6919
+ var zip64EocdlBuffer = newBuffer(20);
6920
+ var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
6921
+ readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err2) {
6922
+ if (err2) return callback(err2);
6923
+ if (zip64EocdlBuffer.readUInt32LE(0) !== 117853008) {
6924
+ return callback(new Error("invalid zip64 end of central directory locator signature"));
6925
+ }
6926
+ var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
6927
+ var zip64EocdrBuffer = newBuffer(56);
6928
+ readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err3) {
6929
+ if (err3) return callback(err3);
6930
+ if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
6931
+ return callback(new Error("invalid zip64 end of central directory record signature"));
6932
+ }
6933
+ entryCount = readUInt64LE(zip64EocdrBuffer, 32);
6934
+ centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
6935
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
6936
+ });
6937
+ });
6938
+ return;
6939
+ }
6940
+ callback(new Error("end of central directory record signature not found"));
6941
+ });
6942
+ }
6943
+ util.inherits(ZipFile, EventEmitter);
6944
+ function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
6945
+ var self2 = this;
6946
+ EventEmitter.call(self2);
6947
+ self2.reader = reader;
6948
+ self2.reader.on("error", function(err) {
6949
+ emitError(self2, err);
6950
+ });
6951
+ self2.reader.once("close", function() {
6952
+ self2.emit("close");
6953
+ });
6954
+ self2.readEntryCursor = centralDirectoryOffset;
6955
+ self2.fileSize = fileSize;
6956
+ self2.entryCount = entryCount;
6957
+ self2.comment = comment;
6958
+ self2.entriesRead = 0;
6959
+ self2.autoClose = !!autoClose;
6960
+ self2.lazyEntries = !!lazyEntries;
6961
+ self2.decodeStrings = !!decodeStrings;
6962
+ self2.validateEntrySizes = !!validateEntrySizes;
6963
+ self2.strictFileNames = !!strictFileNames;
6964
+ self2.isOpen = true;
6965
+ self2.emittedError = false;
6966
+ if (!self2.lazyEntries) self2._readEntry();
6967
+ }
6968
+ ZipFile.prototype.close = function() {
6969
+ if (!this.isOpen) return;
6970
+ this.isOpen = false;
6971
+ this.reader.unref();
6972
+ };
6973
+ function emitErrorAndAutoClose(self2, err) {
6974
+ if (self2.autoClose) self2.close();
6975
+ emitError(self2, err);
6976
+ }
6977
+ function emitError(self2, err) {
6978
+ if (self2.emittedError) return;
6979
+ self2.emittedError = true;
6980
+ self2.emit("error", err);
6981
+ }
6982
+ ZipFile.prototype.readEntry = function() {
6983
+ if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
6984
+ this._readEntry();
6985
+ };
6986
+ ZipFile.prototype._readEntry = function() {
6987
+ var self2 = this;
6988
+ if (self2.entryCount === self2.entriesRead) {
6989
+ setImmediate(function() {
6990
+ if (self2.autoClose) self2.close();
6991
+ if (self2.emittedError) return;
6992
+ self2.emit("end");
6993
+ });
6994
+ return;
6995
+ }
6996
+ if (self2.emittedError) return;
6997
+ var buffer = newBuffer(46);
6998
+ readAndAssertNoEof(self2.reader, buffer, 0, buffer.length, self2.readEntryCursor, function(err) {
6999
+ if (err) return emitErrorAndAutoClose(self2, err);
7000
+ if (self2.emittedError) return;
7001
+ var entry = new Entry();
7002
+ var signature = buffer.readUInt32LE(0);
7003
+ if (signature !== 33639248) return emitErrorAndAutoClose(self2, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
7004
+ entry.versionMadeBy = buffer.readUInt16LE(4);
7005
+ entry.versionNeededToExtract = buffer.readUInt16LE(6);
7006
+ entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
7007
+ entry.compressionMethod = buffer.readUInt16LE(10);
7008
+ entry.lastModFileTime = buffer.readUInt16LE(12);
7009
+ entry.lastModFileDate = buffer.readUInt16LE(14);
7010
+ entry.crc32 = buffer.readUInt32LE(16);
7011
+ entry.compressedSize = buffer.readUInt32LE(20);
7012
+ entry.uncompressedSize = buffer.readUInt32LE(24);
7013
+ entry.fileNameLength = buffer.readUInt16LE(28);
7014
+ entry.extraFieldLength = buffer.readUInt16LE(30);
7015
+ entry.fileCommentLength = buffer.readUInt16LE(32);
7016
+ entry.internalFileAttributes = buffer.readUInt16LE(36);
7017
+ entry.externalFileAttributes = buffer.readUInt32LE(38);
7018
+ entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
7019
+ if (entry.generalPurposeBitFlag & 64) return emitErrorAndAutoClose(self2, new Error("strong encryption is not supported"));
7020
+ self2.readEntryCursor += 46;
7021
+ buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
7022
+ readAndAssertNoEof(self2.reader, buffer, 0, buffer.length, self2.readEntryCursor, function(err2) {
7023
+ if (err2) return emitErrorAndAutoClose(self2, err2);
7024
+ if (self2.emittedError) return;
7025
+ var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
7026
+ entry.fileName = self2.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8) : buffer.slice(0, entry.fileNameLength);
7027
+ var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
7028
+ var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
7029
+ entry.extraFields = [];
7030
+ var i = 0;
7031
+ while (i < extraFieldBuffer.length - 3) {
7032
+ var headerId = extraFieldBuffer.readUInt16LE(i + 0);
7033
+ var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
7034
+ var dataStart = i + 4;
7035
+ var dataEnd = dataStart + dataSize;
7036
+ if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self2, new Error("extra field length exceeds extra field buffer size"));
7037
+ var dataBuffer = newBuffer(dataSize);
7038
+ extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
7039
+ entry.extraFields.push({
7040
+ id: headerId,
7041
+ data: dataBuffer
7042
+ });
7043
+ i = dataEnd;
7044
+ }
7045
+ entry.fileComment = self2.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8) : buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
7046
+ entry.comment = entry.fileComment;
7047
+ self2.readEntryCursor += buffer.length;
7048
+ self2.entriesRead += 1;
7049
+ if (entry.uncompressedSize === 4294967295 || entry.compressedSize === 4294967295 || entry.relativeOffsetOfLocalHeader === 4294967295) {
7050
+ var zip64EiefBuffer = null;
7051
+ for (var i = 0; i < entry.extraFields.length; i++) {
7052
+ var extraField = entry.extraFields[i];
7053
+ if (extraField.id === 1) {
7054
+ zip64EiefBuffer = extraField.data;
7055
+ break;
7056
+ }
7057
+ }
7058
+ if (zip64EiefBuffer == null) {
7059
+ return emitErrorAndAutoClose(self2, new Error("expected zip64 extended information extra field"));
7060
+ }
7061
+ var index = 0;
7062
+ if (entry.uncompressedSize === 4294967295) {
7063
+ if (index + 8 > zip64EiefBuffer.length) {
7064
+ return emitErrorAndAutoClose(self2, new Error("zip64 extended information extra field does not include uncompressed size"));
7065
+ }
7066
+ entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
7067
+ index += 8;
7068
+ }
7069
+ if (entry.compressedSize === 4294967295) {
7070
+ if (index + 8 > zip64EiefBuffer.length) {
7071
+ return emitErrorAndAutoClose(self2, new Error("zip64 extended information extra field does not include compressed size"));
7072
+ }
7073
+ entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
7074
+ index += 8;
7075
+ }
7076
+ if (entry.relativeOffsetOfLocalHeader === 4294967295) {
7077
+ if (index + 8 > zip64EiefBuffer.length) {
7078
+ return emitErrorAndAutoClose(self2, new Error("zip64 extended information extra field does not include relative header offset"));
7079
+ }
7080
+ entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
7081
+ index += 8;
7082
+ }
7083
+ }
7084
+ if (self2.decodeStrings) {
7085
+ for (var i = 0; i < entry.extraFields.length; i++) {
7086
+ var extraField = entry.extraFields[i];
7087
+ if (extraField.id === 28789) {
7088
+ if (extraField.data.length < 6) {
7089
+ continue;
7090
+ }
7091
+ if (extraField.data.readUInt8(0) !== 1) {
7092
+ continue;
7093
+ }
7094
+ var oldNameCrc32 = extraField.data.readUInt32LE(1);
7095
+ if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
7096
+ continue;
7097
+ }
7098
+ entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
7099
+ break;
7100
+ }
7101
+ }
7102
+ }
7103
+ if (self2.validateEntrySizes && entry.compressionMethod === 0) {
7104
+ var expectedCompressedSize = entry.uncompressedSize;
7105
+ if (entry.isEncrypted()) {
7106
+ expectedCompressedSize += 12;
7107
+ }
7108
+ if (entry.compressedSize !== expectedCompressedSize) {
7109
+ var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
7110
+ return emitErrorAndAutoClose(self2, new Error(msg));
7111
+ }
7112
+ }
7113
+ if (self2.decodeStrings) {
7114
+ if (!self2.strictFileNames) {
7115
+ entry.fileName = entry.fileName.replace(/\\/g, "/");
7116
+ }
7117
+ var errorMessage = validateFileName(entry.fileName, self2.validateFileNameOptions);
7118
+ if (errorMessage != null) return emitErrorAndAutoClose(self2, new Error(errorMessage));
7119
+ }
7120
+ self2.emit("entry", entry);
7121
+ if (!self2.lazyEntries) self2._readEntry();
7122
+ });
7123
+ });
7124
+ };
7125
+ ZipFile.prototype.openReadStream = function(entry, options, callback) {
7126
+ var self2 = this;
7127
+ var relativeStart = 0;
7128
+ var relativeEnd = entry.compressedSize;
7129
+ if (callback == null) {
7130
+ callback = options;
7131
+ options = {};
7132
+ } else {
7133
+ if (options.decrypt != null) {
7134
+ if (!entry.isEncrypted()) {
7135
+ throw new Error("options.decrypt can only be specified for encrypted entries");
7136
+ }
7137
+ if (options.decrypt !== false) throw new Error("invalid options.decrypt value: " + options.decrypt);
7138
+ if (entry.isCompressed()) {
7139
+ if (options.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
7140
+ }
7141
+ }
7142
+ if (options.decompress != null) {
7143
+ if (!entry.isCompressed()) {
7144
+ throw new Error("options.decompress can only be specified for compressed entries");
7145
+ }
7146
+ if (!(options.decompress === false || options.decompress === true)) {
7147
+ throw new Error("invalid options.decompress value: " + options.decompress);
7148
+ }
7149
+ }
7150
+ if (options.start != null || options.end != null) {
7151
+ if (entry.isCompressed() && options.decompress !== false) {
7152
+ throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
7153
+ }
7154
+ if (entry.isEncrypted() && options.decrypt !== false) {
7155
+ throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
7156
+ }
7157
+ }
7158
+ if (options.start != null) {
7159
+ relativeStart = options.start;
7160
+ if (relativeStart < 0) throw new Error("options.start < 0");
7161
+ if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
7162
+ }
7163
+ if (options.end != null) {
7164
+ relativeEnd = options.end;
7165
+ if (relativeEnd < 0) throw new Error("options.end < 0");
7166
+ if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
7167
+ if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
7168
+ }
7169
+ }
7170
+ if (!self2.isOpen) return callback(new Error("closed"));
7171
+ if (entry.isEncrypted()) {
7172
+ if (options.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
7173
+ }
7174
+ self2.reader.ref();
7175
+ var buffer = newBuffer(30);
7176
+ readAndAssertNoEof(self2.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
7177
+ try {
7178
+ if (err) return callback(err);
7179
+ var signature = buffer.readUInt32LE(0);
7180
+ if (signature !== 67324752) {
7181
+ return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
7182
+ }
7183
+ var fileNameLength = buffer.readUInt16LE(26);
7184
+ var extraFieldLength = buffer.readUInt16LE(28);
7185
+ var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
7186
+ var decompress;
7187
+ if (entry.compressionMethod === 0) {
7188
+ decompress = false;
7189
+ } else if (entry.compressionMethod === 8) {
7190
+ decompress = options.decompress != null ? options.decompress : true;
7191
+ } else {
7192
+ return callback(new Error("unsupported compression method: " + entry.compressionMethod));
7193
+ }
7194
+ var fileDataStart = localFileHeaderEnd;
7195
+ var fileDataEnd = fileDataStart + entry.compressedSize;
7196
+ if (entry.compressedSize !== 0) {
7197
+ if (fileDataEnd > self2.fileSize) {
7198
+ return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self2.fileSize));
7199
+ }
7200
+ }
7201
+ var readStream = self2.reader.createReadStream({
7202
+ start: fileDataStart + relativeStart,
7203
+ end: fileDataStart + relativeEnd
7204
+ });
7205
+ var endpointStream = readStream;
7206
+ if (decompress) {
7207
+ var destroyed = false;
7208
+ var inflateFilter = zlib.createInflateRaw();
7209
+ readStream.on("error", function(err2) {
7210
+ setImmediate(function() {
7211
+ if (!destroyed) inflateFilter.emit("error", err2);
7212
+ });
7213
+ });
7214
+ readStream.pipe(inflateFilter);
7215
+ if (self2.validateEntrySizes) {
7216
+ endpointStream = new AssertByteCountStream(entry.uncompressedSize);
7217
+ inflateFilter.on("error", function(err2) {
7218
+ setImmediate(function() {
7219
+ if (!destroyed) endpointStream.emit("error", err2);
7220
+ });
7221
+ });
7222
+ inflateFilter.pipe(endpointStream);
7223
+ } else {
7224
+ endpointStream = inflateFilter;
7225
+ }
7226
+ endpointStream.destroy = function() {
7227
+ destroyed = true;
7228
+ if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
7229
+ readStream.unpipe(inflateFilter);
7230
+ readStream.destroy();
7231
+ };
7232
+ }
7233
+ callback(null, endpointStream);
7234
+ } finally {
7235
+ self2.reader.unref();
7236
+ }
7237
+ });
7238
+ };
7239
+ function Entry() {
7240
+ }
7241
+ Entry.prototype.getLastModDate = function() {
7242
+ return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
7243
+ };
7244
+ Entry.prototype.isEncrypted = function() {
7245
+ return (this.generalPurposeBitFlag & 1) !== 0;
7246
+ };
7247
+ Entry.prototype.isCompressed = function() {
7248
+ return this.compressionMethod === 8;
7249
+ };
7250
+ function dosDateTimeToDate(date, time) {
7251
+ var day = date & 31;
7252
+ var month = (date >> 5 & 15) - 1;
7253
+ var year = (date >> 9 & 127) + 1980;
7254
+ var millisecond = 0;
7255
+ var second = (time & 31) * 2;
7256
+ var minute = time >> 5 & 63;
7257
+ var hour = time >> 11 & 31;
7258
+ return new Date(year, month, day, hour, minute, second, millisecond);
7259
+ }
7260
+ function validateFileName(fileName) {
7261
+ if (fileName.indexOf("\\") !== -1) {
7262
+ return "invalid characters in fileName: " + fileName;
7263
+ }
7264
+ if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
7265
+ return "absolute path: " + fileName;
7266
+ }
7267
+ if (fileName.split("/").indexOf("..") !== -1) {
7268
+ return "invalid relative path: " + fileName;
7269
+ }
7270
+ return null;
7271
+ }
7272
+ function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
7273
+ if (length === 0) {
7274
+ return setImmediate(function() {
7275
+ callback(null, newBuffer(0));
7276
+ });
7277
+ }
7278
+ reader.read(buffer, offset, length, position, function(err, bytesRead) {
7279
+ if (err) return callback(err);
7280
+ if (bytesRead < length) {
7281
+ return callback(new Error("unexpected EOF"));
7282
+ }
7283
+ callback();
7284
+ });
7285
+ }
7286
+ util.inherits(AssertByteCountStream, Transform);
7287
+ function AssertByteCountStream(byteCount) {
7288
+ Transform.call(this);
7289
+ this.actualByteCount = 0;
7290
+ this.expectedByteCount = byteCount;
7291
+ }
7292
+ AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
7293
+ this.actualByteCount += chunk.length;
7294
+ if (this.actualByteCount > this.expectedByteCount) {
7295
+ var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
7296
+ return cb(new Error(msg));
7297
+ }
7298
+ cb(null, chunk);
7299
+ };
7300
+ AssertByteCountStream.prototype._flush = function(cb) {
7301
+ if (this.actualByteCount < this.expectedByteCount) {
7302
+ var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
7303
+ return cb(new Error(msg));
7304
+ }
7305
+ cb();
7306
+ };
7307
+ util.inherits(RandomAccessReader, EventEmitter);
7308
+ function RandomAccessReader() {
7309
+ EventEmitter.call(this);
7310
+ this.refCount = 0;
7311
+ }
7312
+ RandomAccessReader.prototype.ref = function() {
7313
+ this.refCount += 1;
7314
+ };
7315
+ RandomAccessReader.prototype.unref = function() {
7316
+ var self2 = this;
7317
+ self2.refCount -= 1;
7318
+ if (self2.refCount > 0) return;
7319
+ if (self2.refCount < 0) throw new Error("invalid unref");
7320
+ self2.close(onCloseDone);
7321
+ function onCloseDone(err) {
7322
+ if (err) return self2.emit("error", err);
7323
+ self2.emit("close");
7324
+ }
7325
+ };
7326
+ RandomAccessReader.prototype.createReadStream = function(options) {
7327
+ var start = options.start;
7328
+ var end = options.end;
7329
+ if (start === end) {
7330
+ var emptyStream = new PassThrough();
7331
+ setImmediate(function() {
7332
+ emptyStream.end();
7333
+ });
7334
+ return emptyStream;
7335
+ }
7336
+ var stream = this._readStreamForRange(start, end);
7337
+ var destroyed = false;
7338
+ var refUnrefFilter = new RefUnrefFilter(this);
7339
+ stream.on("error", function(err) {
7340
+ setImmediate(function() {
7341
+ if (!destroyed) refUnrefFilter.emit("error", err);
7342
+ });
7343
+ });
7344
+ refUnrefFilter.destroy = function() {
7345
+ stream.unpipe(refUnrefFilter);
7346
+ refUnrefFilter.unref();
7347
+ stream.destroy();
7348
+ };
7349
+ var byteCounter = new AssertByteCountStream(end - start);
7350
+ refUnrefFilter.on("error", function(err) {
7351
+ setImmediate(function() {
7352
+ if (!destroyed) byteCounter.emit("error", err);
7353
+ });
7354
+ });
7355
+ byteCounter.destroy = function() {
7356
+ destroyed = true;
7357
+ refUnrefFilter.unpipe(byteCounter);
7358
+ refUnrefFilter.destroy();
7359
+ };
7360
+ return stream.pipe(refUnrefFilter).pipe(byteCounter);
7361
+ };
7362
+ RandomAccessReader.prototype._readStreamForRange = function(start, end) {
7363
+ throw new Error("not implemented");
7364
+ };
7365
+ RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
7366
+ var readStream = this.createReadStream({ start: position, end: position + length });
7367
+ var writeStream = new Writable();
7368
+ var written = 0;
7369
+ writeStream._write = function(chunk, encoding, cb) {
7370
+ chunk.copy(buffer, offset + written, 0, chunk.length);
7371
+ written += chunk.length;
7372
+ cb();
7373
+ };
7374
+ writeStream.on("finish", callback);
7375
+ readStream.on("error", function(error) {
7376
+ callback(error);
7377
+ });
7378
+ readStream.pipe(writeStream);
7379
+ };
7380
+ RandomAccessReader.prototype.close = function(callback) {
7381
+ setImmediate(callback);
7382
+ };
7383
+ util.inherits(RefUnrefFilter, PassThrough);
7384
+ function RefUnrefFilter(context) {
7385
+ PassThrough.call(this);
7386
+ this.context = context;
7387
+ this.context.ref();
7388
+ this.unreffedYet = false;
7389
+ }
7390
+ RefUnrefFilter.prototype._flush = function(cb) {
7391
+ this.unref();
7392
+ cb();
7393
+ };
7394
+ RefUnrefFilter.prototype.unref = function(cb) {
7395
+ if (this.unreffedYet) return;
7396
+ this.unreffedYet = true;
7397
+ this.context.unref();
7398
+ };
7399
+ var cp437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
7400
+ function decodeBuffer(buffer, start, end, isUtf8) {
7401
+ if (isUtf8) {
7402
+ return buffer.toString("utf8", start, end);
7403
+ } else {
7404
+ var result = "";
7405
+ for (var i = start; i < end; i++) {
7406
+ result += cp437[buffer[i]];
7407
+ }
7408
+ return result;
7409
+ }
7410
+ }
7411
+ function readUInt64LE(buffer, offset) {
7412
+ var lower32 = buffer.readUInt32LE(offset);
7413
+ var upper32 = buffer.readUInt32LE(offset + 4);
7414
+ return upper32 * 4294967296 + lower32;
7415
+ }
7416
+ var newBuffer;
7417
+ if (typeof Buffer.allocUnsafe === "function") {
7418
+ newBuffer = function(len) {
7419
+ return Buffer.allocUnsafe(len);
7420
+ };
7421
+ } else {
7422
+ newBuffer = function(len) {
7423
+ return new Buffer(len);
7424
+ };
7425
+ }
7426
+ function defaultCallback(err) {
7427
+ if (err) throw err;
7428
+ }
7429
+ return yauzl;
7430
+ }
7431
+ var extractZip$1;
7432
+ var hasRequiredExtractZip;
7433
+ function requireExtractZip() {
7434
+ if (hasRequiredExtractZip) return extractZip$1;
7435
+ hasRequiredExtractZip = 1;
7436
+ const debug2 = requireSrc()("extract-zip");
7437
+ const { createWriteStream: createWriteStream2, promises: fs2 } = require$$0$2;
7438
+ const getStream2 = requireGetStream();
7439
+ const path2 = path__default;
7440
+ const { promisify } = require$$1$1;
7441
+ const stream = require$$6;
7442
+ const yauzl2 = requireYauzl();
7443
+ const openZip = promisify(yauzl2.open);
7444
+ const pipeline2 = promisify(stream.pipeline);
7445
+ class Extractor {
7446
+ constructor(zipPath, opts) {
7447
+ this.zipPath = zipPath;
7448
+ this.opts = opts;
7449
+ }
7450
+ async extract() {
7451
+ debug2("opening", this.zipPath, "with opts", this.opts);
7452
+ this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
7453
+ this.canceled = false;
7454
+ return new Promise((resolve2, reject) => {
7455
+ this.zipfile.on("error", (err) => {
7456
+ this.canceled = true;
7457
+ reject(err);
7458
+ });
7459
+ this.zipfile.readEntry();
7460
+ this.zipfile.on("close", () => {
7461
+ if (!this.canceled) {
7462
+ debug2("zip extraction complete");
7463
+ resolve2();
7464
+ }
7465
+ });
7466
+ this.zipfile.on("entry", async (entry) => {
7467
+ if (this.canceled) {
7468
+ debug2("skipping entry", entry.fileName, { cancelled: this.canceled });
7469
+ return;
7470
+ }
7471
+ debug2("zipfile entry", entry.fileName);
7472
+ if (entry.fileName.startsWith("__MACOSX/")) {
7473
+ this.zipfile.readEntry();
7474
+ return;
7475
+ }
7476
+ const destDir = path2.dirname(path2.join(this.opts.dir, entry.fileName));
7477
+ try {
7478
+ await fs2.mkdir(destDir, { recursive: true });
7479
+ const canonicalDestDir = await fs2.realpath(destDir);
7480
+ const relativeDestDir = path2.relative(this.opts.dir, canonicalDestDir);
7481
+ if (relativeDestDir.split(path2.sep).includes("..")) {
7482
+ throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
7483
+ }
7484
+ await this.extractEntry(entry);
7485
+ debug2("finished processing", entry.fileName);
7486
+ this.zipfile.readEntry();
7487
+ } catch (err) {
7488
+ this.canceled = true;
7489
+ this.zipfile.close();
7490
+ reject(err);
7491
+ }
7492
+ });
7493
+ });
7494
+ }
7495
+ async extractEntry(entry) {
7496
+ if (this.canceled) {
7497
+ debug2("skipping entry extraction", entry.fileName, { cancelled: this.canceled });
7498
+ return;
7499
+ }
7500
+ if (this.opts.onEntry) {
7501
+ this.opts.onEntry(entry, this.zipfile);
7502
+ }
7503
+ const dest = path2.join(this.opts.dir, entry.fileName);
7504
+ const mode = entry.externalFileAttributes >> 16 & 65535;
7505
+ const IFMT = 61440;
7506
+ const IFDIR = 16384;
7507
+ const IFLNK = 40960;
7508
+ const symlink = (mode & IFMT) === IFLNK;
7509
+ let isDir = (mode & IFMT) === IFDIR;
7510
+ if (!isDir && entry.fileName.endsWith("/")) {
7511
+ isDir = true;
7512
+ }
7513
+ const madeBy = entry.versionMadeBy >> 8;
7514
+ if (!isDir) isDir = madeBy === 0 && entry.externalFileAttributes === 16;
7515
+ debug2("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink });
7516
+ const procMode = this.getExtractedMode(mode, isDir) & 511;
7517
+ const destDir = isDir ? dest : path2.dirname(dest);
7518
+ const mkdirOptions = { recursive: true };
7519
+ if (isDir) {
7520
+ mkdirOptions.mode = procMode;
7521
+ }
7522
+ debug2("mkdir", { dir: destDir, ...mkdirOptions });
7523
+ await fs2.mkdir(destDir, mkdirOptions);
7524
+ if (isDir) return;
7525
+ debug2("opening read stream", dest);
7526
+ const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
7527
+ if (symlink) {
7528
+ const link = await getStream2(readStream);
7529
+ debug2("creating symlink", link, dest);
7530
+ await fs2.symlink(link, dest);
7531
+ } else {
7532
+ await pipeline2(readStream, createWriteStream2(dest, { mode: procMode }));
7533
+ }
7534
+ }
7535
+ getExtractedMode(entryMode, isDir) {
7536
+ let mode = entryMode;
7537
+ if (mode === 0) {
7538
+ if (isDir) {
7539
+ if (this.opts.defaultDirMode) {
7540
+ mode = parseInt(this.opts.defaultDirMode, 10);
7541
+ }
7542
+ if (!mode) {
7543
+ mode = 493;
7544
+ }
7545
+ } else {
7546
+ if (this.opts.defaultFileMode) {
7547
+ mode = parseInt(this.opts.defaultFileMode, 10);
7548
+ }
7549
+ if (!mode) {
7550
+ mode = 420;
7551
+ }
7552
+ }
7553
+ }
7554
+ return mode;
7555
+ }
7556
+ }
7557
+ extractZip$1 = async function(zipPath, opts) {
7558
+ debug2("creating target directory", opts.dir);
7559
+ if (!path2.isAbsolute(opts.dir)) {
7560
+ throw new Error("Target directory is expected to be absolute");
7561
+ }
7562
+ await fs2.mkdir(opts.dir, { recursive: true });
7563
+ opts.dir = await fs2.realpath(opts.dir);
7564
+ return new Extractor(zipPath, opts).extract();
7565
+ };
7566
+ return extractZip$1;
7567
+ }
7568
+ var extractZipExports = requireExtractZip();
7569
+ const extractZip = /* @__PURE__ */ getDefaultExportFromCjs(extractZipExports);
7570
+ const __filename$1 = fileURLToPath(import.meta.url);
7571
+ const __dirname$1 = dirname$1(__filename$1);
7572
+ function getPackageDir() {
7573
+ const envDir = process.env.SHORTCUT_PACKAGE_DIR;
7574
+ if (envDir) {
7575
+ if (envDir === "~")
7576
+ return homedir();
7577
+ if (envDir.startsWith("~/"))
7578
+ return homedir() + envDir.slice(1);
7579
+ return envDir;
7580
+ }
7581
+ let dir = __dirname$1;
7582
+ while (dir !== dirname$1(dir)) {
7583
+ if (existsSync(join$1(dir, "package.json"))) {
7584
+ return dir;
7585
+ }
7586
+ dir = dirname$1(dir);
7587
+ }
7588
+ return __dirname$1;
7589
+ }
7590
+ function getPackageJsonPath() {
7591
+ return join$1(getPackageDir(), "package.json");
7592
+ }
7593
+ const pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
7594
+ const APP_NAME = pkg.shortcutConfig?.name || "shortcut";
7595
+ const CONFIG_DIR_NAME = pkg.shortcutConfig?.configDir || ".shortcut";
7596
+ pkg.version;
7597
+ const NPM_PACKAGE_NAME = pkg.name || "shortcutxl";
7598
+ const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;
7599
+ process.env.SHORTCUT_NPM_REGISTRY_URL?.trim() || `https://registry.npmjs.org/${NPM_PACKAGE_NAME}/latest`;
7600
+ function getAgentDir() {
7601
+ const envDir = process.env[ENV_AGENT_DIR];
7602
+ if (envDir) {
7603
+ if (envDir === "~")
7604
+ return homedir();
7605
+ if (envDir.startsWith("~/"))
7606
+ return homedir() + envDir.slice(1);
7607
+ return envDir;
7608
+ }
7609
+ return join$1(homedir(), CONFIG_DIR_NAME, "agent");
7610
+ }
7611
+ function getBinDir() {
7612
+ return join$1(getAgentDir(), "bin");
7613
+ }
7614
+ async function writeWebStreamToFile(body, destinationPath) {
7615
+ try {
7616
+ await pipeline(Readable.fromWeb(body), createWriteStream(destinationPath));
7617
+ } catch (error) {
7618
+ try {
7619
+ await unlink(destinationPath);
7620
+ } catch {
7621
+ }
7622
+ throw error;
7623
+ }
7624
+ }
7625
+ const TOOLS_DIR = getBinDir();
7626
+ const NETWORK_TIMEOUT_MS = 1e4;
7627
+ function isOfflineModeEnabled() {
7628
+ const value = process.env.SHORTCUT_OFFLINE;
7629
+ if (!value)
7630
+ return false;
7631
+ return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
7632
+ }
7633
+ const TOOLS = {
7634
+ fd: {
7635
+ name: "fd",
7636
+ repo: "sharkdp/fd",
7637
+ binaryName: "fd",
7638
+ tagPrefix: "v",
7639
+ getAssetName: (version, plat, architecture) => {
7640
+ if (plat === "darwin") {
7641
+ const archStr = architecture === "arm64" ? "aarch64" : "x86_64";
7642
+ return `fd-v${version}-${archStr}-apple-darwin.tar.gz`;
7643
+ } else if (plat === "linux") {
7644
+ const archStr = architecture === "arm64" ? "aarch64" : "x86_64";
7645
+ return `fd-v${version}-${archStr}-unknown-linux-gnu.tar.gz`;
7646
+ } else if (plat === "win32") {
7647
+ const archStr = architecture === "arm64" ? "aarch64" : "x86_64";
7648
+ return `fd-v${version}-${archStr}-pc-windows-msvc.zip`;
7649
+ }
7650
+ return null;
7651
+ }
7652
+ },
7653
+ rg: {
7654
+ name: "ripgrep",
7655
+ repo: "BurntSushi/ripgrep",
7656
+ binaryName: "rg",
7657
+ tagPrefix: "",
7658
+ getAssetName: (version, plat, architecture) => {
7659
+ if (plat === "darwin") {
7660
+ const archStr = architecture === "arm64" ? "aarch64" : "x86_64";
7661
+ return `ripgrep-${version}-${archStr}-apple-darwin.tar.gz`;
7662
+ } else if (plat === "linux") {
7663
+ if (architecture === "arm64") {
7664
+ return `ripgrep-${version}-aarch64-unknown-linux-gnu.tar.gz`;
7665
+ }
7666
+ return `ripgrep-${version}-x86_64-unknown-linux-musl.tar.gz`;
7667
+ } else if (plat === "win32") {
7668
+ const archStr = architecture === "arm64" ? "aarch64" : "x86_64";
7669
+ return `ripgrep-${version}-${archStr}-pc-windows-msvc.zip`;
7670
+ }
7671
+ return null;
7672
+ }
7673
+ }
7674
+ };
7675
+ function commandExists(cmd) {
7676
+ try {
7677
+ const result = spawnSync(cmd, ["--version"], { stdio: "pipe" });
7678
+ return result.error === void 0 || result.error === null;
7679
+ } catch {
7680
+ return false;
7681
+ }
7682
+ }
7683
+ function getToolPath(tool) {
7684
+ const config = TOOLS[tool];
7685
+ if (!config)
7686
+ return null;
7687
+ const localPath = join$1(TOOLS_DIR, config.binaryName + (platform() === "win32" ? ".exe" : ""));
7688
+ if (existsSync(localPath)) {
7689
+ return localPath;
7690
+ }
7691
+ if (commandExists(config.binaryName)) {
7692
+ return config.binaryName;
7693
+ }
7694
+ return null;
7695
+ }
7696
+ async function getLatestVersion(repo) {
7697
+ const response = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {
7698
+ headers: { "User-AgentController": `${APP_NAME}-coding-agent` },
7699
+ signal: AbortSignal.timeout(NETWORK_TIMEOUT_MS)
7700
+ });
7701
+ if (!response.ok) {
7702
+ throw new Error(`GitHub API error: ${response.status}`);
7703
+ }
7704
+ const data = await response.json();
7705
+ return data.tag_name.replace(/^v/, "");
7706
+ }
7707
+ async function downloadFile(url, dest) {
7708
+ const response = await fetch(url, {
7709
+ signal: AbortSignal.timeout(NETWORK_TIMEOUT_MS)
7710
+ });
7711
+ if (!response.ok) {
7712
+ throw new Error(`Failed to download: ${response.status}`);
7713
+ }
7714
+ if (!response.body) {
7715
+ throw new Error("No response body");
7716
+ }
7717
+ await writeWebStreamToFile(response.body, dest);
7718
+ }
7719
+ function findBinaryRecursively(rootDir, binaryFileName) {
7720
+ const stack = [rootDir];
7721
+ while (stack.length > 0) {
7722
+ const currentDir = stack.pop();
7723
+ if (!currentDir)
7724
+ continue;
7725
+ const entries = readdirSync(currentDir, { withFileTypes: true });
7726
+ for (const entry of entries) {
7727
+ const fullPath = join$1(currentDir, entry.name);
7728
+ if (entry.isFile() && entry.name === binaryFileName) {
7729
+ return fullPath;
7730
+ }
7731
+ if (entry.isDirectory()) {
7732
+ stack.push(fullPath);
7733
+ }
7734
+ }
7735
+ }
7736
+ return null;
7737
+ }
7738
+ async function downloadTool(tool) {
7739
+ const config = TOOLS[tool];
7740
+ if (!config)
7741
+ throw new Error(`Unknown tool: ${tool}`);
7742
+ const plat = platform();
7743
+ const architecture = arch();
7744
+ const version = await getLatestVersion(config.repo);
7745
+ const assetName = config.getAssetName(version, plat, architecture);
7746
+ if (!assetName) {
7747
+ throw new Error(`Unsupported platform: ${plat}/${architecture}`);
7748
+ }
7749
+ mkdirSync(TOOLS_DIR, { recursive: true });
7750
+ const downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;
7751
+ const archivePath = join$1(TOOLS_DIR, assetName);
7752
+ const binaryExt = plat === "win32" ? ".exe" : "";
7753
+ const binaryPath = join$1(TOOLS_DIR, config.binaryName + binaryExt);
7754
+ await downloadFile(downloadUrl, archivePath);
7755
+ const extractDir = join$1(TOOLS_DIR, `extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
7756
+ mkdirSync(extractDir, { recursive: true });
7757
+ try {
7758
+ if (assetName.endsWith(".tar.gz")) {
7759
+ const extractResult = spawnSync("tar", ["xzf", archivePath, "-C", extractDir], {
7760
+ stdio: "pipe"
7761
+ });
7762
+ if (extractResult.error || extractResult.status !== 0) {
7763
+ const errMsg = extractResult.error?.message ?? extractResult.stderr?.toString().trim() ?? "unknown error";
7764
+ throw new Error(`Failed to extract ${assetName}: ${errMsg}`);
7765
+ }
7766
+ } else if (assetName.endsWith(".zip")) {
7767
+ await extractZip(archivePath, { dir: extractDir });
7768
+ } else {
7769
+ throw new Error(`Unsupported archive format: ${assetName}`);
7770
+ }
7771
+ const binaryFileName = config.binaryName + binaryExt;
7772
+ const extractedDir = join$1(extractDir, assetName.replace(/\.(tar\.gz|zip)$/, ""));
7773
+ const extractedBinaryCandidates = [
7774
+ join$1(extractedDir, binaryFileName),
7775
+ join$1(extractDir, binaryFileName)
7776
+ ];
7777
+ let extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync(candidate));
7778
+ if (!extractedBinary) {
7779
+ extractedBinary = findBinaryRecursively(extractDir, binaryFileName) ?? void 0;
7780
+ }
7781
+ if (extractedBinary) {
7782
+ renameSync(extractedBinary, binaryPath);
7783
+ } else {
7784
+ throw new Error(`Binary not found in archive: expected ${binaryFileName} under ${extractDir}`);
7785
+ }
7786
+ if (plat !== "win32") {
7787
+ chmodSync(binaryPath, 493);
7788
+ }
7789
+ } finally {
7790
+ rmSync(archivePath, { force: true });
7791
+ rmSync(extractDir, { recursive: true, force: true });
7792
+ }
7793
+ return binaryPath;
7794
+ }
7795
+ const TERMUX_PACKAGES = {
7796
+ fd: "fd",
7797
+ rg: "ripgrep"
7798
+ };
7799
+ async function ensureTool(tool, silent = false) {
7800
+ const existingPath = getToolPath(tool);
7801
+ if (existingPath) {
7802
+ return existingPath;
7803
+ }
7804
+ const config = TOOLS[tool];
7805
+ if (!config)
7806
+ return void 0;
7807
+ if (isOfflineModeEnabled()) {
7808
+ if (!silent) {
7809
+ console.log(chalk.yellow(`${config.name} not found. Offline mode enabled, skipping download.`));
7810
+ }
7811
+ return void 0;
7812
+ }
7813
+ if (platform() === "android") {
7814
+ const pkgName = TERMUX_PACKAGES[tool];
7815
+ if (!silent) {
7816
+ console.log(chalk.yellow(`${config.name} not found. Install with: pkg install ${pkgName}`));
7817
+ }
7818
+ return void 0;
7819
+ }
7820
+ if (!silent) {
7821
+ console.log(chalk.dim(`${config.name} not found. Downloading...`));
7822
+ }
7823
+ try {
7824
+ const path2 = await downloadTool(tool);
7825
+ if (!silent) {
7826
+ console.log(chalk.dim(`${config.name} installed to ${path2}`));
7827
+ }
7828
+ return path2;
7829
+ } catch (e) {
7830
+ if (!silent) {
7831
+ console.log(chalk.yellow(`Failed to download ${config.name}: ${e instanceof Error ? e.message : e}`));
7832
+ }
7833
+ return void 0;
7834
+ }
7835
+ }
7836
+ const PATH_DELIMITERS = /* @__PURE__ */ new Set([" ", " ", '"', "'", "="]);
7837
+ function findLastDelimiter(text) {
7838
+ for (let i = text.length - 1; i >= 0; i -= 1) {
7839
+ if (PATH_DELIMITERS.has(text[i] ?? "")) return i;
7840
+ }
7841
+ return -1;
7842
+ }
7843
+ function findUnclosedQuoteStart(text) {
7844
+ let inQuotes = false;
7845
+ let quoteStart = -1;
7846
+ for (let i = 0; i < text.length; i += 1) {
7847
+ if (text[i] === '"') {
7848
+ inQuotes = !inQuotes;
7849
+ if (inQuotes) quoteStart = i;
7850
+ }
7851
+ }
7852
+ return inQuotes ? quoteStart : null;
7853
+ }
7854
+ function isTokenStart(text, index) {
7855
+ return index === 0 || PATH_DELIMITERS.has(text[index - 1] ?? "");
7856
+ }
7857
+ function extractQuotedPrefix(text) {
7858
+ const quoteStart = findUnclosedQuoteStart(text);
7859
+ if (quoteStart === null) return null;
7860
+ if (quoteStart > 0 && text[quoteStart - 1] === "@") {
7861
+ if (!isTokenStart(text, quoteStart - 1)) return null;
7862
+ return text.slice(quoteStart - 1);
7863
+ }
7864
+ if (!isTokenStart(text, quoteStart)) return null;
7865
+ return text.slice(quoteStart);
7866
+ }
7867
+ function extractAtPrefix(text) {
7868
+ const quotedPrefix = extractQuotedPrefix(text);
7869
+ if (quotedPrefix?.startsWith('@"')) return quotedPrefix;
7870
+ const lastDelimiterIndex = findLastDelimiter(text);
7871
+ const tokenStart = lastDelimiterIndex === -1 ? 0 : lastDelimiterIndex + 1;
7872
+ return text[tokenStart] === "@" ? text.slice(tokenStart) : null;
7873
+ }
7874
+ function parsePathPrefix(prefix) {
7875
+ if (prefix.startsWith('@"')) {
7876
+ return { rawPrefix: prefix.slice(2), isAtPrefix: true, isQuotedPrefix: true };
7877
+ }
7878
+ if (prefix.startsWith('"')) {
7879
+ return { rawPrefix: prefix.slice(1), isAtPrefix: false, isQuotedPrefix: true };
7880
+ }
7881
+ if (prefix.startsWith("@")) {
7882
+ return { rawPrefix: prefix.slice(1), isAtPrefix: true, isQuotedPrefix: false };
7883
+ }
7884
+ return { rawPrefix: prefix, isAtPrefix: false, isQuotedPrefix: false };
7885
+ }
7886
+ function buildCompletionValue(path2, options) {
7887
+ const needsQuotes = options.isQuotedPrefix || path2.includes(" ");
7888
+ const prefix = options.isAtPrefix ? "@" : "";
7889
+ return needsQuotes ? `${prefix}"${path2}"` : `${prefix}${path2}`;
7890
+ }
7891
+ function applyAutocompleteCompletion(lines, cursorLine, cursorCol, item, prefix) {
7892
+ const currentLine = lines[cursorLine] || "";
7893
+ const beforePrefix = currentLine.slice(0, cursorCol - prefix.length);
7894
+ const afterCursor = currentLine.slice(cursorCol);
7895
+ const isQuotedPrefix = prefix.startsWith('"') || prefix.startsWith('@"');
7896
+ const adjustedAfterCursor = isQuotedPrefix && item.value.endsWith('"') && afterCursor.startsWith('"') ? afterCursor.slice(1) : afterCursor;
7897
+ const isSlashCommand = prefix.startsWith("/") && !prefix.slice(1).includes("/") && (beforePrefix.trim() === "" || item.value.startsWith("skill:"));
7898
+ if (isSlashCommand) {
7899
+ const newLines2 = [...lines];
7900
+ newLines2[cursorLine] = `${beforePrefix}/${item.value} ${adjustedAfterCursor}`;
7901
+ return {
7902
+ lines: newLines2,
7903
+ cursorLine,
7904
+ cursorCol: beforePrefix.length + item.value.length + 2
7905
+ };
7906
+ }
7907
+ if (prefix.startsWith("@")) {
7908
+ const isDirectory2 = item.label.endsWith("/");
7909
+ const suffix = isDirectory2 ? "" : " ";
7910
+ const newLines2 = [...lines];
7911
+ newLines2[cursorLine] = `${beforePrefix + item.value}${suffix}${adjustedAfterCursor}`;
7912
+ const cursorOffset2 = isDirectory2 && item.value.endsWith('"') ? item.value.length - 1 : item.value.length;
7913
+ return {
7914
+ lines: newLines2,
7915
+ cursorLine,
7916
+ cursorCol: beforePrefix.length + cursorOffset2 + suffix.length
7917
+ };
7918
+ }
7919
+ const newLines = [...lines];
7920
+ newLines[cursorLine] = beforePrefix + item.value + adjustedAfterCursor;
7921
+ const isDirectory = item.label.endsWith("/");
7922
+ const cursorOffset = isDirectory && item.value.endsWith('"') ? item.value.length - 1 : item.value.length;
7923
+ return {
7924
+ lines: newLines,
7925
+ cursorLine,
7926
+ cursorCol: beforePrefix.length + cursorOffset
7927
+ };
7928
+ }
7929
+ function fuzzyMatch(query, text) {
7930
+ const queryLower = query.toLowerCase();
7931
+ const textLower = text.toLowerCase();
7932
+ const matchQuery = (normalizedQuery) => {
7933
+ if (normalizedQuery.length === 0) {
7934
+ return { matches: true, score: 0 };
7935
+ }
7936
+ if (normalizedQuery.length > textLower.length) {
7937
+ return { matches: false, score: 0 };
7938
+ }
7939
+ let queryIndex = 0;
7940
+ let score = 0;
7941
+ let lastMatchIndex = -1;
7942
+ let consecutiveMatches = 0;
7943
+ for (let i = 0; i < textLower.length && queryIndex < normalizedQuery.length; i++) {
7944
+ if (textLower[i] === normalizedQuery[queryIndex]) {
7945
+ const isWordBoundary = i === 0 || /[\s\-_./:]/.test(textLower[i - 1]);
7946
+ if (lastMatchIndex === i - 1) {
7947
+ consecutiveMatches++;
7948
+ score -= consecutiveMatches * 5;
7949
+ } else {
7950
+ consecutiveMatches = 0;
7951
+ if (lastMatchIndex >= 0) {
7952
+ score += (i - lastMatchIndex - 1) * 2;
7953
+ }
7954
+ }
7955
+ if (isWordBoundary) {
7956
+ score -= 10;
7957
+ }
7958
+ score += i * 0.1;
7959
+ lastMatchIndex = i;
7960
+ queryIndex++;
7961
+ }
7962
+ }
7963
+ if (queryIndex < normalizedQuery.length) {
7964
+ return { matches: false, score: 0 };
7965
+ }
7966
+ return { matches: true, score };
7967
+ };
7968
+ const primaryMatch = matchQuery(queryLower);
7969
+ if (primaryMatch.matches) {
7970
+ return primaryMatch;
7971
+ }
7972
+ const alphaNumericMatch = queryLower.match(/^(?<letters>[a-z]+)(?<digits>[0-9]+)$/);
7973
+ const numericAlphaMatch = queryLower.match(/^(?<digits>[0-9]+)(?<letters>[a-z]+)$/);
7974
+ const swappedQuery = alphaNumericMatch ? `${alphaNumericMatch.groups?.digits ?? ""}${alphaNumericMatch.groups?.letters ?? ""}` : numericAlphaMatch ? `${numericAlphaMatch.groups?.letters ?? ""}${numericAlphaMatch.groups?.digits ?? ""}` : "";
7975
+ if (!swappedQuery) {
7976
+ return primaryMatch;
7977
+ }
7978
+ const swappedMatch = matchQuery(swappedQuery);
7979
+ if (!swappedMatch.matches) {
7980
+ return primaryMatch;
7981
+ }
7982
+ return { matches: true, score: swappedMatch.score + 5 };
7983
+ }
7984
+ function fuzzyFilter(items, query, getText) {
7985
+ if (!query.trim()) {
7986
+ return items;
7987
+ }
7988
+ const tokens = query.trim().split(/\s+/).filter((t) => t.length > 0);
7989
+ if (tokens.length === 0) {
7990
+ return items;
7991
+ }
7992
+ const results = [];
7993
+ for (const item of items) {
7994
+ const text = getText(item);
7995
+ let totalScore = 0;
7996
+ let allMatch = true;
7997
+ for (const token of tokens) {
7998
+ const match = fuzzyMatch(token, text);
7999
+ if (match.matches) {
8000
+ totalScore += match.score;
8001
+ } else {
8002
+ allMatch = false;
8003
+ break;
8004
+ }
8005
+ }
8006
+ if (allMatch) {
8007
+ results.push({ item, totalScore });
8008
+ }
8009
+ }
8010
+ results.sort((a, b) => a.totalScore - b.totalScore);
8011
+ return results.map((r) => r.item);
8012
+ }
8013
+ const LEFT_BOUNDARY_CHARS = /* @__PURE__ */ new Set(["(", "[", "{", '"', "'", ",", ":", ";", "!", "?"]);
8014
+ function isWhitespaceChar(char) {
8015
+ return char === " " || char === " " || char === "\n" || char === "\r";
8016
+ }
8017
+ function isInlineSkillLeftBoundary(char) {
8018
+ return char === void 0 || isWhitespaceChar(char) || LEFT_BOUNDARY_CHARS.has(char);
8019
+ }
8020
+ function extractInlineSkillAutocompleteToken(textBeforeCursor) {
8021
+ const slashIndex = textBeforeCursor.lastIndexOf("/");
8022
+ if (slashIndex === -1) return null;
8023
+ if (!isInlineSkillLeftBoundary(textBeforeCursor[slashIndex - 1])) return null;
8024
+ const token = textBeforeCursor.slice(slashIndex);
8025
+ if (token.includes("/", 1) || token.includes(" ")) return null;
8026
+ if (token === "/") {
8027
+ return { token, query: "", explicit: false };
8028
+ }
8029
+ if (token.startsWith("/skill:")) {
8030
+ const query2 = token.slice("/skill:".length);
8031
+ return /^[a-z0-9-]*$/.test(query2) ? { token, query: query2, explicit: true } : null;
8032
+ }
8033
+ const query = token.slice(1);
8034
+ return /^[a-z0-9-]*$/.test(query) ? { token, query, explicit: false } : null;
8035
+ }
8036
+ function walkDirectoryWithFd(baseDir, fdPath, query, maxResults) {
8037
+ const args = [
8038
+ "--base-directory",
8039
+ baseDir,
8040
+ "--max-results",
8041
+ String(maxResults),
8042
+ "--type",
8043
+ "f",
8044
+ "--type",
8045
+ "d",
8046
+ "--full-path",
8047
+ "--hidden",
8048
+ "--exclude",
8049
+ ".git",
8050
+ "--exclude",
8051
+ ".git/*",
8052
+ "--exclude",
8053
+ ".git/**"
8054
+ ];
8055
+ if (query) {
8056
+ args.push(query);
8057
+ }
8058
+ const result = spawnSync(fdPath, args, {
8059
+ encoding: "utf-8",
8060
+ stdio: ["pipe", "pipe", "pipe"],
8061
+ maxBuffer: 10 * 1024 * 1024
8062
+ });
8063
+ if (result.status !== 0 || !result.stdout) {
8064
+ return [];
8065
+ }
8066
+ const lines = result.stdout.trim().split(/\r?\n/).filter(Boolean);
8067
+ const results = [];
8068
+ for (const line of lines) {
8069
+ const posixPath = line.replaceAll("\\", "/");
8070
+ const normalizedPath = posixPath.endsWith("/") ? posixPath.slice(0, -1) : posixPath;
8071
+ if (normalizedPath === ".git" || normalizedPath.startsWith(".git/") || normalizedPath.includes("/.git/")) {
8072
+ continue;
8073
+ }
8074
+ const isDirectory = posixPath.endsWith("/");
8075
+ results.push({
8076
+ path: posixPath,
8077
+ isDirectory
8078
+ });
8079
+ }
8080
+ return results;
8081
+ }
8082
+ function walkDirectoryWithoutFd(baseDir, query, maxResults) {
8083
+ const normalizedQuery = query.toLowerCase();
8084
+ const results = [];
8085
+ const pendingDirectories = [""];
8086
+ let visitedEntries = 0;
8087
+ const maxVisitedEntries = 2e4;
8088
+ while (pendingDirectories.length > 0 && results.length < maxResults && visitedEntries < maxVisitedEntries) {
8089
+ const relativeDirectory = pendingDirectories.shift() ?? "";
8090
+ const directory = relativeDirectory ? join$1(baseDir, relativeDirectory) : baseDir;
8091
+ let entries;
8092
+ try {
8093
+ entries = readdirSync(directory, { withFileTypes: true });
8094
+ } catch {
8095
+ continue;
8096
+ }
8097
+ entries.sort((a, b) => {
8098
+ if (a.isDirectory() !== b.isDirectory()) return a.isDirectory() ? -1 : 1;
8099
+ return a.name.localeCompare(b.name);
8100
+ });
8101
+ for (const entry of entries) {
8102
+ visitedEntries++;
8103
+ if (entry.name === ".git" || entry.name === "node_modules") continue;
8104
+ const relativePath = relativeDirectory ? join$1(relativeDirectory, entry.name) : entry.name;
8105
+ const displayPath = relativePath.split("\\").join("/");
8106
+ const isDirectory = entry.isDirectory();
8107
+ if (isDirectory) pendingDirectories.push(relativePath);
8108
+ if (!normalizedQuery || displayPath.toLowerCase().includes(normalizedQuery)) {
8109
+ results.push({ path: isDirectory ? `${displayPath}/` : displayPath, isDirectory });
8110
+ if (results.length >= maxResults) break;
8111
+ }
8112
+ if (visitedEntries >= maxVisitedEntries) break;
8113
+ }
8114
+ }
8115
+ return results;
8116
+ }
8117
+ class CombinedAutocompleteProvider {
8118
+ commands;
8119
+ basePath;
8120
+ fdPath;
8121
+ atMentionItems;
8122
+ constructor(commands = [], basePath = process.cwd(), fdPath = null, atMentionItems = []) {
8123
+ this.commands = commands;
8124
+ this.basePath = basePath;
8125
+ this.fdPath = fdPath;
8126
+ this.atMentionItems = atMentionItems;
8127
+ }
8128
+ setAtMentionItems(items) {
8129
+ this.atMentionItems = items;
8130
+ }
8131
+ getSuggestions(lines, cursorLine, cursorCol) {
8132
+ const currentLine = lines[cursorLine] || "";
8133
+ const textBeforeCursor = currentLine.slice(0, cursorCol);
8134
+ const atPrefix = this.extractAtPrefix(textBeforeCursor);
8135
+ if (atPrefix) {
8136
+ const { rawPrefix, isQuotedPrefix } = parsePathPrefix(atPrefix);
8137
+ const mentionSuggestions = isQuotedPrefix ? [] : fuzzyFilter(this.atMentionItems, rawPrefix, (item) => item.label);
8138
+ const fileSuggestions = this.getFuzzyFileSuggestions(rawPrefix, {
8139
+ isQuotedPrefix
8140
+ });
8141
+ const suggestions = [...mentionSuggestions, ...fileSuggestions];
8142
+ if (suggestions.length === 0) return null;
8143
+ return {
8144
+ items: suggestions,
8145
+ prefix: atPrefix
8146
+ };
8147
+ }
8148
+ if (textBeforeCursor.startsWith("/")) {
8149
+ const spaceIndex = textBeforeCursor.indexOf(" ");
8150
+ if (spaceIndex === -1) {
8151
+ const prefix = textBeforeCursor.slice(1);
8152
+ const commandItems = this.commands.map((cmd) => ({
8153
+ name: "name" in cmd ? cmd.name : cmd.value,
8154
+ label: "name" in cmd ? cmd.name : cmd.label,
8155
+ description: cmd.description
8156
+ }));
8157
+ const filtered = fuzzyFilter(commandItems, prefix, (item) => item.name).map((item) => ({
8158
+ value: item.name,
8159
+ label: item.label,
8160
+ ...item.description && { description: item.description }
8161
+ }));
8162
+ if (filtered.length === 0) return null;
8163
+ return {
8164
+ items: filtered,
8165
+ prefix: textBeforeCursor
8166
+ };
8167
+ } else {
8168
+ const commandName = textBeforeCursor.slice(1, spaceIndex);
8169
+ const argumentText = textBeforeCursor.slice(spaceIndex + 1);
8170
+ const command = this.commands.find((cmd) => {
8171
+ const name = "name" in cmd ? cmd.name : cmd.value;
8172
+ return name === commandName;
8173
+ });
8174
+ if (!command || !("getArgumentCompletions" in command) || !command.getArgumentCompletions) {
8175
+ return null;
8176
+ }
8177
+ const argumentSuggestions = command.getArgumentCompletions(argumentText);
8178
+ if (!argumentSuggestions || argumentSuggestions.length === 0) {
8179
+ return null;
8180
+ }
8181
+ return {
8182
+ items: argumentSuggestions,
8183
+ prefix: argumentText
8184
+ };
8185
+ }
8186
+ }
8187
+ const inlineSkillToken = !textBeforeCursor.startsWith("/") ? extractInlineSkillAutocompleteToken(textBeforeCursor) : null;
8188
+ if (inlineSkillToken) {
8189
+ const rawQuery = inlineSkillToken.query;
8190
+ const commandItems = this.commands.map((cmd) => ({
8191
+ name: "name" in cmd ? cmd.name : cmd.value,
8192
+ label: "name" in cmd ? cmd.name : cmd.label,
8193
+ description: cmd.description
8194
+ })).filter((item) => item.name.startsWith("skill:")).map((item) => ({
8195
+ ...item,
8196
+ matchName: item.name.slice("skill:".length)
8197
+ }));
8198
+ const filtered = fuzzyFilter(commandItems, rawQuery, (item) => item.matchName).map(
8199
+ (item) => ({
8200
+ value: item.name,
8201
+ label: item.label,
8202
+ ...item.description && { description: item.description }
8203
+ })
8204
+ );
8205
+ if (filtered.length === 0) return null;
8206
+ return {
8207
+ items: filtered,
8208
+ prefix: inlineSkillToken.token
8209
+ };
8210
+ }
8211
+ const pathMatch = this.extractPathPrefix(textBeforeCursor, false);
8212
+ if (pathMatch !== null) {
8213
+ const suggestions = this.getFileSuggestions(pathMatch);
8214
+ if (suggestions.length === 0) return null;
8215
+ if (suggestions.length === 1 && suggestions[0]?.value === pathMatch && !pathMatch.endsWith("/")) {
8216
+ return {
8217
+ items: suggestions,
8218
+ prefix: pathMatch
8219
+ };
8220
+ }
8221
+ return {
8222
+ items: suggestions,
8223
+ prefix: pathMatch
8224
+ };
8225
+ }
8226
+ return null;
8227
+ }
8228
+ applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
8229
+ return applyAutocompleteCompletion(lines, cursorLine, cursorCol, item, prefix);
8230
+ }
8231
+ // Extract @ prefix for fuzzy file suggestions
8232
+ extractAtPrefix(text) {
8233
+ return extractAtPrefix(text);
8234
+ }
8235
+ // Extract a path-like prefix from the text before cursor
8236
+ extractPathPrefix(text, forceExtract = false) {
8237
+ const quotedPrefix = extractQuotedPrefix(text);
8238
+ if (quotedPrefix) {
8239
+ return quotedPrefix;
8240
+ }
8241
+ const lastDelimiterIndex = findLastDelimiter(text);
8242
+ const pathPrefix = lastDelimiterIndex === -1 ? text : text.slice(lastDelimiterIndex + 1);
8243
+ if (forceExtract) {
8244
+ return pathPrefix;
8245
+ }
8246
+ if (pathPrefix.includes("/") || pathPrefix.startsWith(".") || pathPrefix.startsWith("~/")) {
8247
+ return pathPrefix;
8248
+ }
8249
+ if (pathPrefix === "" && text.endsWith(" ")) {
8250
+ return pathPrefix;
8251
+ }
8252
+ return null;
8253
+ }
8254
+ // Expand home directory (~/) to actual home path
8255
+ expandHomePath(path2) {
8256
+ if (path2.startsWith("~/")) {
8257
+ const expandedPath = join$1(homedir(), path2.slice(2));
8258
+ return path2.endsWith("/") && !expandedPath.endsWith("/") ? `${expandedPath}/` : expandedPath;
8259
+ } else if (path2 === "~") {
8260
+ return homedir();
8261
+ }
8262
+ return path2;
8263
+ }
8264
+ resolveScopedFuzzyQuery(rawQuery) {
8265
+ const slashIndex = rawQuery.lastIndexOf("/");
8266
+ if (slashIndex === -1) {
8267
+ return null;
8268
+ }
8269
+ const displayBase = rawQuery.slice(0, slashIndex + 1);
8270
+ const query = rawQuery.slice(slashIndex + 1);
8271
+ let baseDir;
8272
+ if (displayBase.startsWith("~/")) {
8273
+ baseDir = this.expandHomePath(displayBase);
8274
+ } else if (displayBase.startsWith("/")) {
8275
+ baseDir = displayBase;
8276
+ } else {
8277
+ baseDir = join$1(this.basePath, displayBase);
8278
+ }
8279
+ try {
8280
+ if (!statSync(baseDir).isDirectory()) {
8281
+ return null;
8282
+ }
8283
+ } catch {
8284
+ return null;
8285
+ }
8286
+ return { baseDir, query, displayBase };
8287
+ }
8288
+ scopedPathForDisplay(displayBase, relativePath) {
8289
+ if (displayBase === "/") {
8290
+ return `/${relativePath}`;
8291
+ }
8292
+ return `${displayBase}${relativePath}`;
8293
+ }
8294
+ // Get file/directory suggestions for a given path prefix
8295
+ getFileSuggestions(prefix) {
8296
+ try {
8297
+ let searchDir;
8298
+ let searchPrefix;
8299
+ const { rawPrefix, isAtPrefix, isQuotedPrefix } = parsePathPrefix(prefix);
8300
+ let expandedPrefix = rawPrefix;
8301
+ if (expandedPrefix.startsWith("~")) {
8302
+ expandedPrefix = this.expandHomePath(expandedPrefix);
8303
+ }
8304
+ const isRootPrefix = rawPrefix === "" || rawPrefix === "./" || rawPrefix === "../" || rawPrefix === "~" || rawPrefix === "~/" || rawPrefix === "/" || isAtPrefix && rawPrefix === "";
8305
+ if (isRootPrefix) {
8306
+ if (rawPrefix.startsWith("~") || expandedPrefix.startsWith("/")) {
8307
+ searchDir = expandedPrefix;
8308
+ } else {
8309
+ searchDir = join$1(this.basePath, expandedPrefix);
8310
+ }
8311
+ searchPrefix = "";
8312
+ } else if (rawPrefix.endsWith("/")) {
8313
+ if (rawPrefix.startsWith("~") || expandedPrefix.startsWith("/")) {
8314
+ searchDir = expandedPrefix;
8315
+ } else {
8316
+ searchDir = join$1(this.basePath, expandedPrefix);
8317
+ }
8318
+ searchPrefix = "";
8319
+ } else {
8320
+ const dir = dirname$1(expandedPrefix);
8321
+ const file = basename$1(expandedPrefix);
8322
+ if (rawPrefix.startsWith("~") || expandedPrefix.startsWith("/")) {
8323
+ searchDir = dir;
8324
+ } else {
8325
+ searchDir = join$1(this.basePath, dir);
8326
+ }
8327
+ searchPrefix = file;
8328
+ }
8329
+ const entries = readdirSync(searchDir, { withFileTypes: true });
8330
+ const suggestions = [];
8331
+ for (const entry of entries) {
8332
+ if (!entry.name.toLowerCase().startsWith(searchPrefix.toLowerCase())) {
8333
+ continue;
8334
+ }
8335
+ let isDirectory = entry.isDirectory();
8336
+ if (!isDirectory && entry.isSymbolicLink()) {
8337
+ try {
8338
+ const fullPath = join$1(searchDir, entry.name);
8339
+ isDirectory = statSync(fullPath).isDirectory();
8340
+ } catch {
8341
+ }
8342
+ }
8343
+ let relativePath;
8344
+ const name = entry.name;
8345
+ const displayPrefix = rawPrefix;
8346
+ if (displayPrefix.endsWith("/")) {
8347
+ relativePath = displayPrefix + name;
8348
+ } else if (displayPrefix.includes("/")) {
8349
+ if (displayPrefix.startsWith("~/")) {
8350
+ const homeRelativeDir = displayPrefix.slice(2);
8351
+ const dir = dirname$1(homeRelativeDir);
8352
+ relativePath = `~/${dir === "." ? name : join$1(dir, name)}`;
8353
+ } else if (displayPrefix.startsWith("/")) {
8354
+ const dir = dirname$1(displayPrefix);
8355
+ if (dir === "/") {
8356
+ relativePath = `/${name}`;
8357
+ } else {
8358
+ relativePath = `${dir}/${name}`;
8359
+ }
8360
+ } else {
8361
+ relativePath = join$1(dirname$1(displayPrefix), name);
8362
+ }
8363
+ } else {
8364
+ if (displayPrefix.startsWith("~")) {
8365
+ relativePath = `~/${name}`;
8366
+ } else {
8367
+ relativePath = name;
8368
+ }
8369
+ }
8370
+ const pathValue = isDirectory ? `${relativePath}/` : relativePath;
8371
+ const value = buildCompletionValue(pathValue, {
8372
+ isDirectory,
8373
+ isAtPrefix,
8374
+ isQuotedPrefix
8375
+ });
8376
+ suggestions.push({
8377
+ value,
8378
+ label: name + (isDirectory ? "/" : "")
8379
+ });
8380
+ }
8381
+ suggestions.sort((a, b) => {
8382
+ const aIsDir = a.value.endsWith("/");
8383
+ const bIsDir = b.value.endsWith("/");
8384
+ if (aIsDir && !bIsDir) return -1;
8385
+ if (!aIsDir && bIsDir) return 1;
8386
+ return a.label.localeCompare(b.label);
8387
+ });
8388
+ return suggestions;
8389
+ } catch (_e) {
8390
+ return [];
8391
+ }
8392
+ }
8393
+ // Score an entry against the query (higher = better match)
8394
+ // isDirectory adds bonus to prioritize folders
8395
+ scoreEntry(filePath, query, isDirectory) {
8396
+ const fileName = basename$1(filePath);
8397
+ const lowerFileName = fileName.toLowerCase();
8398
+ const lowerQuery = query.toLowerCase();
8399
+ let score = 0;
8400
+ if (lowerFileName === lowerQuery) score = 100;
8401
+ else if (lowerFileName.startsWith(lowerQuery)) score = 80;
8402
+ else if (lowerFileName.includes(lowerQuery)) score = 50;
8403
+ else if (filePath.toLowerCase().includes(lowerQuery)) score = 30;
8404
+ if (isDirectory && score > 0) score += 10;
8405
+ return score;
8406
+ }
8407
+ // Fuzzy file search using fd (fast, respects .gitignore)
8408
+ getFuzzyFileSuggestions(query, options) {
8409
+ try {
8410
+ const scopedQuery = this.resolveScopedFuzzyQuery(query);
8411
+ const fdBaseDir = scopedQuery?.baseDir ?? this.basePath;
8412
+ const fdQuery = scopedQuery?.query ?? query;
8413
+ const entries = this.fdPath ? walkDirectoryWithFd(fdBaseDir, this.fdPath, fdQuery, 100) : walkDirectoryWithoutFd(fdBaseDir, fdQuery, 100);
8414
+ const scoredEntries = entries.map((entry) => ({
8415
+ ...entry,
8416
+ score: fdQuery ? this.scoreEntry(entry.path, fdQuery, entry.isDirectory) : 1
8417
+ })).filter((entry) => entry.score > 0);
8418
+ scoredEntries.sort((a, b) => b.score - a.score);
8419
+ const topEntries = scoredEntries.slice(0, 20);
8420
+ const suggestions = [];
8421
+ for (const { path: entryPath, isDirectory } of topEntries) {
8422
+ const pathWithoutSlash = isDirectory ? entryPath.slice(0, -1) : entryPath;
8423
+ const displayPath = scopedQuery ? this.scopedPathForDisplay(scopedQuery.displayBase, pathWithoutSlash) : pathWithoutSlash;
8424
+ const entryName = basename$1(pathWithoutSlash);
8425
+ const completionPath = isDirectory ? `${displayPath}/` : displayPath;
8426
+ const value = buildCompletionValue(completionPath, {
8427
+ isDirectory,
8428
+ isAtPrefix: true,
8429
+ isQuotedPrefix: options.isQuotedPrefix
8430
+ });
8431
+ suggestions.push({
8432
+ value,
8433
+ label: entryName + (isDirectory ? "/" : ""),
8434
+ description: displayPath
8435
+ });
8436
+ }
8437
+ return suggestions;
8438
+ } catch {
8439
+ return [];
8440
+ }
8441
+ }
8442
+ // Force file completion (called on Tab key) - always returns suggestions
8443
+ getForceFileSuggestions(lines, cursorLine, cursorCol) {
8444
+ const currentLine = lines[cursorLine] || "";
8445
+ const textBeforeCursor = currentLine.slice(0, cursorCol);
8446
+ if (textBeforeCursor.trim().startsWith("/") && !textBeforeCursor.trim().includes(" ")) {
8447
+ return null;
8448
+ }
8449
+ const pathMatch = this.extractPathPrefix(textBeforeCursor, true);
8450
+ if (pathMatch !== null) {
8451
+ const suggestions = this.getFileSuggestions(pathMatch);
8452
+ if (suggestions.length === 0) return null;
8453
+ return {
8454
+ items: suggestions,
8455
+ prefix: pathMatch
8456
+ };
8457
+ }
8458
+ return null;
8459
+ }
8460
+ // Check if we should trigger file completion (called on Tab key)
8461
+ shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
8462
+ const currentLine = lines[cursorLine] || "";
8463
+ const textBeforeCursor = currentLine.slice(0, cursorCol);
8464
+ if (textBeforeCursor.trim().startsWith("/") && !textBeforeCursor.trim().includes(" ")) {
8465
+ return false;
8466
+ }
8467
+ return true;
8468
+ }
8469
+ }
8470
+ class FileMentionSearchService {
8471
+ constructor(ensureFd = () => ensureTool("fd", true)) {
8472
+ this.ensureFd = ensureFd;
8473
+ }
8474
+ ensureFd;
8475
+ fdPathPromise;
8476
+ providers = /* @__PURE__ */ new Map();
8477
+ initialize() {
8478
+ this.fdPathPromise ??= this.ensureFd().catch(() => void 0);
8479
+ return this.fdPathPromise;
8480
+ }
8481
+ async search(request) {
8482
+ if (!isAbsolute(request.cwd)) throw new Error("File mention cwd must be absolute");
8483
+ if (!request.prefix.startsWith("@")) throw new Error("File mention prefix must start with @");
8484
+ let provider = this.providers.get(request.cwd);
8485
+ if (!provider) {
8486
+ provider = new CombinedAutocompleteProvider([], request.cwd, await this.initialize());
8487
+ this.providers.set(request.cwd, provider);
8488
+ }
8489
+ const suggestions = provider.getSuggestions([request.prefix], 0, request.prefix.length);
8490
+ return suggestions?.prefix.startsWith("@") ? suggestions : null;
8491
+ }
8492
+ }
5347
8493
  function readLaunchArgument(name) {
5348
8494
  return readLaunchArguments(name).at(-1);
5349
8495
  }
@@ -5355,6 +8501,7 @@ const agents = new AgentProcessManager({
5355
8501
  cliPath: readLaunchArgument("shortcut-runtime-cli"),
5356
8502
  runtimeArgs: readLaunchArguments("shortcut-runtime-arg")
5357
8503
  });
8504
+ const fileMentions = new FileMentionSearchService();
5358
8505
  let mainWindow = null;
5359
8506
  let launchCwd = readLaunchArgument("shortcut-cwd") ?? process.cwd();
5360
8507
  function registerAgentIpc() {
@@ -5375,6 +8522,10 @@ function registerAgentIpc() {
5375
8522
  const result = mainWindow ? await dialog.showOpenDialog(mainWindow, options) : await dialog.showOpenDialog(options);
5376
8523
  return result.canceled ? [] : prepareRpcAttachments(result.filePaths);
5377
8524
  });
8525
+ ipcMain.handle(
8526
+ AgentIpcChannel.FileMentionSuggestions,
8527
+ (_event, request) => fileMentions.search(request)
8528
+ );
5378
8529
  ipcMain.handle(AgentIpcChannel.OpenFolder, async (_event, folderPath) => {
5379
8530
  if (!isAbsolute(folderPath)) throw new Error("Folder path must be absolute");
5380
8531
  const error = await shell.openPath(folderPath);
@@ -5398,7 +8549,7 @@ function createWindow() {
5398
8549
  minWidth: 820,
5399
8550
  minHeight: 560,
5400
8551
  title: "Shortcut CLI",
5401
- backgroundColor: "#f7f9f6",
8552
+ backgroundColor: "#f5f5f5",
5402
8553
  webPreferences: {
5403
8554
  preload: join(__dirname, "../preload/index.cjs"),
5404
8555
  contextIsolation: true,
@@ -5447,6 +8598,7 @@ const singleInstance = app.requestSingleInstanceLock({ cwd: launchCwd });
5447
8598
  if (!singleInstance) {
5448
8599
  app.quit();
5449
8600
  } else {
8601
+ void fileMentions.initialize();
5450
8602
  app.on("second-instance", (_event, _argv, _workingDirectory, additionalData) => {
5451
8603
  if (!mainWindow) return;
5452
8604
  const requestedCwd = additionalData.cwd;