shortcutxl 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/README.md +59 -0
  2. package/agent-docs/README.md +397 -0
  3. package/agent-docs/docs/compaction.md +390 -0
  4. package/agent-docs/docs/custom-provider.md +580 -0
  5. package/agent-docs/docs/development.md +69 -0
  6. package/agent-docs/docs/extensions.md +1971 -0
  7. package/agent-docs/docs/json.md +79 -0
  8. package/agent-docs/docs/keybindings.md +174 -0
  9. package/agent-docs/docs/models.md +293 -0
  10. package/agent-docs/docs/packages.md +209 -0
  11. package/agent-docs/docs/prompt-templates.md +67 -0
  12. package/agent-docs/docs/providers.md +186 -0
  13. package/agent-docs/docs/rpc.md +1317 -0
  14. package/agent-docs/docs/sdk.md +962 -0
  15. package/agent-docs/docs/session.md +412 -0
  16. package/agent-docs/docs/settings.md +223 -0
  17. package/agent-docs/docs/shell-aliases.md +13 -0
  18. package/agent-docs/docs/skills.md +231 -0
  19. package/agent-docs/docs/terminal-setup.md +70 -0
  20. package/agent-docs/docs/termux.md +127 -0
  21. package/agent-docs/docs/themes.md +295 -0
  22. package/agent-docs/docs/tree.md +219 -0
  23. package/agent-docs/docs/tui.md +887 -0
  24. package/agent-docs/docs/windows.md +17 -0
  25. package/agent-docs/examples/README.md +25 -0
  26. package/agent-docs/examples/extensions/README.md +205 -0
  27. package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -0
  28. package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -0
  29. package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -0
  30. package/agent-docs/examples/extensions/bookmark.ts +50 -0
  31. package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -0
  32. package/agent-docs/examples/extensions/claude-rules.ts +86 -0
  33. package/agent-docs/examples/extensions/commands.ts +75 -0
  34. package/agent-docs/examples/extensions/confirm-destructive.ts +59 -0
  35. package/agent-docs/examples/extensions/custom-compaction.ts +126 -0
  36. package/agent-docs/examples/extensions/custom-footer.ts +63 -0
  37. package/agent-docs/examples/extensions/custom-header.ts +73 -0
  38. package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -0
  39. package/agent-docs/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  40. package/agent-docs/examples/extensions/custom-provider-anthropic/package.json +19 -0
  41. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -0
  42. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  43. package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -0
  44. package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -0
  45. package/agent-docs/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
  46. package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -0
  47. package/agent-docs/examples/extensions/doom-overlay/README.md +46 -0
  48. package/agent-docs/examples/extensions/doom-overlay/doom/build.sh +152 -0
  49. package/agent-docs/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  50. package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -0
  51. package/agent-docs/examples/extensions/doom-overlay/doom-engine.ts +186 -0
  52. package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -0
  53. package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -0
  54. package/agent-docs/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  55. package/agent-docs/examples/extensions/dynamic-resources/SKILL.md +8 -0
  56. package/agent-docs/examples/extensions/dynamic-resources/dynamic.json +79 -0
  57. package/agent-docs/examples/extensions/dynamic-resources/dynamic.md +5 -0
  58. package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -0
  59. package/agent-docs/examples/extensions/dynamic-tools.ts +77 -0
  60. package/agent-docs/examples/extensions/event-bus.ts +43 -0
  61. package/agent-docs/examples/extensions/file-trigger.ts +41 -0
  62. package/agent-docs/examples/extensions/git-checkpoint.ts +53 -0
  63. package/agent-docs/examples/extensions/handoff.ts +155 -0
  64. package/agent-docs/examples/extensions/hello.ts +25 -0
  65. package/agent-docs/examples/extensions/inline-bash.ts +94 -0
  66. package/agent-docs/examples/extensions/input-transform.ts +43 -0
  67. package/agent-docs/examples/extensions/interactive-shell.ts +209 -0
  68. package/agent-docs/examples/extensions/mac-system-theme.ts +47 -0
  69. package/agent-docs/examples/extensions/message-renderer.ts +59 -0
  70. package/agent-docs/examples/extensions/minimal-mode.ts +430 -0
  71. package/agent-docs/examples/extensions/modal-editor.ts +90 -0
  72. package/agent-docs/examples/extensions/model-status.ts +31 -0
  73. package/agent-docs/examples/extensions/notify.ts +55 -0
  74. package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -0
  75. package/agent-docs/examples/extensions/overlay-test.ts +159 -0
  76. package/agent-docs/examples/extensions/permission-gate.ts +37 -0
  77. package/agent-docs/examples/extensions/pirate.ts +47 -0
  78. package/agent-docs/examples/extensions/plan-mode/README.md +65 -0
  79. package/agent-docs/examples/extensions/plan-mode/index.ts +363 -0
  80. package/agent-docs/examples/extensions/plan-mode/utils.ts +173 -0
  81. package/agent-docs/examples/extensions/preset.ts +418 -0
  82. package/agent-docs/examples/extensions/protected-paths.ts +30 -0
  83. package/agent-docs/examples/extensions/qna.ts +122 -0
  84. package/agent-docs/examples/extensions/question.ts +278 -0
  85. package/agent-docs/examples/extensions/questionnaire.ts +440 -0
  86. package/agent-docs/examples/extensions/rainbow-editor.ts +90 -0
  87. package/agent-docs/examples/extensions/reload-runtime.ts +37 -0
  88. package/agent-docs/examples/extensions/rpc-demo.ts +124 -0
  89. package/agent-docs/examples/extensions/sandbox/index.ts +324 -0
  90. package/agent-docs/examples/extensions/sandbox/package-lock.json +92 -0
  91. package/agent-docs/examples/extensions/sandbox/package.json +19 -0
  92. package/agent-docs/examples/extensions/send-user-message.ts +97 -0
  93. package/agent-docs/examples/extensions/session-name.ts +27 -0
  94. package/agent-docs/examples/extensions/shutdown-command.ts +69 -0
  95. package/agent-docs/examples/extensions/snake.ts +343 -0
  96. package/agent-docs/examples/extensions/space-invaders.ts +566 -0
  97. package/agent-docs/examples/extensions/ssh.ts +233 -0
  98. package/agent-docs/examples/extensions/status-line.ts +40 -0
  99. package/agent-docs/examples/extensions/subagent/README.md +172 -0
  100. package/agent-docs/examples/extensions/subagent/agents/planner.md +37 -0
  101. package/agent-docs/examples/extensions/subagent/agents/reviewer.md +35 -0
  102. package/agent-docs/examples/extensions/subagent/agents/scout.md +50 -0
  103. package/agent-docs/examples/extensions/subagent/agents/worker.md +24 -0
  104. package/agent-docs/examples/extensions/subagent/agents.ts +130 -0
  105. package/agent-docs/examples/extensions/subagent/index.ts +1068 -0
  106. package/agent-docs/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  107. package/agent-docs/examples/extensions/subagent/prompts/implement.md +10 -0
  108. package/agent-docs/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  109. package/agent-docs/examples/extensions/summarize.ts +206 -0
  110. package/agent-docs/examples/extensions/system-prompt-header.ts +17 -0
  111. package/agent-docs/examples/extensions/timed-confirm.ts +72 -0
  112. package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -0
  113. package/agent-docs/examples/extensions/todo.ts +314 -0
  114. package/agent-docs/examples/extensions/tool-override.ts +146 -0
  115. package/agent-docs/examples/extensions/tools.ts +145 -0
  116. package/agent-docs/examples/extensions/trigger-compact.ts +40 -0
  117. package/agent-docs/examples/extensions/truncated-tool.ts +194 -0
  118. package/agent-docs/examples/extensions/widget-placement.ts +17 -0
  119. package/agent-docs/examples/extensions/with-deps/index.ts +37 -0
  120. package/agent-docs/examples/extensions/with-deps/package-lock.json +31 -0
  121. package/agent-docs/examples/extensions/with-deps/package.json +22 -0
  122. package/agent-docs/examples/rpc-extension-ui.ts +654 -0
  123. package/agent-docs/examples/sdk/01-minimal.ts +22 -0
  124. package/agent-docs/examples/sdk/02-custom-model.ts +48 -0
  125. package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -0
  126. package/agent-docs/examples/sdk/04-skills.ts +53 -0
  127. package/agent-docs/examples/sdk/05-tools.ts +56 -0
  128. package/agent-docs/examples/sdk/06-extensions.ts +88 -0
  129. package/agent-docs/examples/sdk/07-context-files.ts +40 -0
  130. package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -0
  131. package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -0
  132. package/agent-docs/examples/sdk/10-settings.ts +54 -0
  133. package/agent-docs/examples/sdk/11-sessions.ts +48 -0
  134. package/agent-docs/examples/sdk/12-full-control.ts +82 -0
  135. package/agent-docs/examples/sdk/README.md +144 -0
  136. package/agent-docs/xll-skill.md +61 -0
  137. package/agent-docs/xll-spec.md +110 -0
  138. package/dist/cli/args.js +290 -0
  139. package/dist/cli/config-selector.js +31 -0
  140. package/dist/cli/file-processor.js +79 -0
  141. package/dist/cli/list-models.js +92 -0
  142. package/dist/cli/package-commands.js +210 -0
  143. package/dist/cli/report-settings-errors.js +11 -0
  144. package/dist/cli/session-picker.js +34 -0
  145. package/dist/cli.js +19 -0
  146. package/dist/config.js +288 -0
  147. package/dist/core/abort.js +15 -0
  148. package/dist/core/agent-loop.js +352 -0
  149. package/dist/core/agent-session.js +2019 -0
  150. package/dist/core/agent.js +410 -0
  151. package/dist/core/auth-storage.js +456 -0
  152. package/dist/core/bash-executor.js +222 -0
  153. package/dist/core/compaction/branch-summarization.js +242 -0
  154. package/dist/core/compaction/compaction.js +610 -0
  155. package/dist/core/compaction/index.js +7 -0
  156. package/dist/core/compaction/utils.js +139 -0
  157. package/dist/core/defaults.js +6 -0
  158. package/dist/core/diagnostics.js +2 -0
  159. package/dist/core/event-bus.js +25 -0
  160. package/dist/core/exec.js +71 -0
  161. package/dist/core/export-html/ansi-to-html.js +256 -0
  162. package/dist/core/export-html/index.js +238 -0
  163. package/dist/core/export-html/session-view-model.js +342 -0
  164. package/dist/core/export-html/template.css +1110 -0
  165. package/dist/core/export-html/template.html +76 -0
  166. package/dist/core/export-html/template.js +1990 -0
  167. package/dist/core/export-html/tool-renderer.js +63 -0
  168. package/dist/core/export-html/vendor/highlight.min.js +7725 -0
  169. package/dist/core/export-html/vendor/marked.min.js +1803 -0
  170. package/dist/core/extensions/index.js +9 -0
  171. package/dist/core/extensions/loader.js +422 -0
  172. package/dist/core/extensions/runner.js +651 -0
  173. package/dist/core/extensions/types.js +35 -0
  174. package/dist/core/extensions/wrapper.js +102 -0
  175. package/dist/core/footer-data-provider.js +162 -0
  176. package/dist/core/index.js +9 -0
  177. package/dist/core/keybindings.js +153 -0
  178. package/dist/core/messages.js +133 -0
  179. package/dist/core/model-registry.js +539 -0
  180. package/dist/core/model-resolver.js +370 -0
  181. package/dist/core/package-manager.js +1485 -0
  182. package/dist/core/prompt-templates.js +253 -0
  183. package/dist/core/resolve-config-value.js +59 -0
  184. package/dist/core/resource-loader.js +700 -0
  185. package/dist/core/sdk.js +197 -0
  186. package/dist/core/session-bash.js +99 -0
  187. package/dist/core/session-compaction.js +165 -0
  188. package/dist/core/session-manager.js +1153 -0
  189. package/dist/core/session-models.js +99 -0
  190. package/dist/core/session-retry.js +155 -0
  191. package/dist/core/settings-manager.js +572 -0
  192. package/dist/core/skills.js +382 -0
  193. package/dist/core/slash-commands.js +31 -0
  194. package/dist/core/system-prompt.js +161 -0
  195. package/dist/core/theme.js +770 -0
  196. package/dist/core/timings.js +26 -0
  197. package/dist/core/tools/bash.js +258 -0
  198. package/dist/core/tools/edit-diff.js +245 -0
  199. package/dist/core/tools/edit.js +148 -0
  200. package/dist/core/tools/find.js +208 -0
  201. package/dist/core/tools/grep.js +246 -0
  202. package/dist/core/tools/index.js +67 -0
  203. package/dist/core/tools/ls.js +123 -0
  204. package/dist/core/tools/path-utils.js +81 -0
  205. package/dist/core/tools/read.js +160 -0
  206. package/dist/core/tools/truncate.js +70 -0
  207. package/dist/core/tools/write.js +82 -0
  208. package/dist/custom/agents/action.js +13 -0
  209. package/dist/custom/agents/document-reader.js +70 -0
  210. package/dist/custom/agents/general.js +26 -0
  211. package/dist/custom/agents/index.js +49 -0
  212. package/dist/custom/agents/installation.js +13 -0
  213. package/dist/custom/agents/types.js +7 -0
  214. package/dist/custom/auth/refresh-timer.js +33 -0
  215. package/dist/custom/auth/shortcut-oauth.js +145 -0
  216. package/dist/custom/constants.js +21 -0
  217. package/dist/custom/context/workbook-summary.js +73 -0
  218. package/dist/custom/credits/shortcut-credits.js +29 -0
  219. package/dist/custom/cron/cron-daemon-entry.js +18 -0
  220. package/dist/custom/cron/daemon-ipc.js +131 -0
  221. package/dist/custom/cron/daemon.js +224 -0
  222. package/dist/custom/cron/jobs.js +226 -0
  223. package/dist/custom/cron/run-log.js +51 -0
  224. package/dist/custom/cron/schedule.js +72 -0
  225. package/dist/custom/cron/status-line.js +98 -0
  226. package/dist/custom/cron/store.js +87 -0
  227. package/dist/custom/cron/types.js +8 -0
  228. package/dist/custom/dev/index.js +59 -0
  229. package/dist/custom/dev/trace-export.js +58 -0
  230. package/dist/custom/ensure-excel.js +63 -0
  231. package/dist/custom/excel-config.js +36 -0
  232. package/dist/custom/preflight.js +422 -0
  233. package/dist/custom/prompts/action.js +100 -0
  234. package/dist/custom/prompts/api.js +66 -0
  235. package/dist/custom/prompts/installation.js +124 -0
  236. package/dist/custom/prompts/shared.js +138 -0
  237. package/dist/custom/providers/llm-usage.js +42 -0
  238. package/dist/custom/providers/message-converter.js +74 -0
  239. package/dist/custom/providers/provider-ids.js +9 -0
  240. package/dist/custom/providers/register-openai-codex-provider.js +27 -0
  241. package/dist/custom/providers/register-shortcut-provider.js +52 -0
  242. package/dist/custom/providers/shortcut-invoke.js +117 -0
  243. package/dist/custom/providers/shortcut-stream.js +252 -0
  244. package/dist/custom/providers/sse-protocol.js +38 -0
  245. package/dist/custom/sync-xll.js +130 -0
  246. package/dist/custom/tools/cron.js +413 -0
  247. package/dist/custom/tools/excel-exec.js +167 -0
  248. package/dist/custom/tools/excel-range.js +50 -0
  249. package/dist/custom/tools/llm-analysis.js +265 -0
  250. package/dist/custom/tools/render-helpers.js +38 -0
  251. package/dist/custom/tools/switch-mode.js +94 -0
  252. package/dist/custom/tools/task/agents.js +6 -0
  253. package/dist/custom/tools/task/index.js +8 -0
  254. package/dist/custom/tools/task/render.js +348 -0
  255. package/dist/custom/tools/task/subprocess.js +320 -0
  256. package/dist/custom/tools/task/task.js +205 -0
  257. package/dist/custom/tools/todo-list.js +195 -0
  258. package/dist/custom/tracing/session-upload.js +93 -0
  259. package/dist/index.js +45 -0
  260. package/dist/main.js +613 -0
  261. package/dist/migrations.js +265 -0
  262. package/dist/modes/index.js +8 -0
  263. package/dist/modes/interactive/components/armin.js +337 -0
  264. package/dist/modes/interactive/components/assistant-message.js +94 -0
  265. package/dist/modes/interactive/components/bash-execution.js +171 -0
  266. package/dist/modes/interactive/components/bordered-loader.js +51 -0
  267. package/dist/modes/interactive/components/branch-summary-message.js +45 -0
  268. package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
  269. package/dist/modes/interactive/components/config-selector.js +488 -0
  270. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  271. package/dist/modes/interactive/components/custom-editor.js +93 -0
  272. package/dist/modes/interactive/components/custom-message.js +81 -0
  273. package/dist/modes/interactive/components/daxnuts.js +140 -0
  274. package/dist/modes/interactive/components/diff.js +133 -0
  275. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  276. package/dist/modes/interactive/components/extension-editor.js +105 -0
  277. package/dist/modes/interactive/components/extension-input.js +61 -0
  278. package/dist/modes/interactive/components/extension-selector.js +78 -0
  279. package/dist/modes/interactive/components/footer.js +309 -0
  280. package/dist/modes/interactive/components/index.js +33 -0
  281. package/dist/modes/interactive/components/keybinding-hints.js +61 -0
  282. package/dist/modes/interactive/components/layout.js +64 -0
  283. package/dist/modes/interactive/components/login-dialog.js +148 -0
  284. package/dist/modes/interactive/components/model-selector.js +237 -0
  285. package/dist/modes/interactive/components/oauth-selector.js +111 -0
  286. package/dist/modes/interactive/components/session-selector-search.js +157 -0
  287. package/dist/modes/interactive/components/session-selector.js +860 -0
  288. package/dist/modes/interactive/components/settings-selector.js +123 -0
  289. package/dist/modes/interactive/components/show-images-selector.js +35 -0
  290. package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
  291. package/dist/modes/interactive/components/theme-selector.js +47 -0
  292. package/dist/modes/interactive/components/thinking-selector.js +47 -0
  293. package/dist/modes/interactive/components/tool-execution.js +789 -0
  294. package/dist/modes/interactive/components/tool-group.js +106 -0
  295. package/dist/modes/interactive/components/tree-selector.js +962 -0
  296. package/dist/modes/interactive/components/user-message-selector.js +115 -0
  297. package/dist/modes/interactive/components/user-message.js +48 -0
  298. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  299. package/dist/modes/interactive/file-attachments.js +135 -0
  300. package/dist/modes/interactive/interactive-mode.js +3775 -0
  301. package/dist/modes/interactive/theme/dark.json +85 -0
  302. package/dist/modes/interactive/theme/light.json +85 -0
  303. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  304. package/dist/modes/interactive/theme/theme.js +177 -0
  305. package/dist/modes/print-mode.js +101 -0
  306. package/dist/modes/rpc/rpc-client.js +387 -0
  307. package/dist/modes/rpc/rpc-mode.js +509 -0
  308. package/dist/modes/rpc/rpc-types.js +8 -0
  309. package/dist/subagent-entry.js +145 -0
  310. package/dist/tool-names.js +34 -0
  311. package/dist/tui/autocomplete.js +596 -0
  312. package/dist/tui/components/box.js +104 -0
  313. package/dist/tui/components/cancellable-loader.js +35 -0
  314. package/dist/tui/components/editor.js +1679 -0
  315. package/dist/tui/components/image.js +69 -0
  316. package/dist/tui/components/input.js +433 -0
  317. package/dist/tui/components/loader.js +49 -0
  318. package/dist/tui/components/markdown.js +629 -0
  319. package/dist/tui/components/select-list.js +152 -0
  320. package/dist/tui/components/settings-list.js +185 -0
  321. package/dist/tui/components/spacer.js +23 -0
  322. package/dist/tui/components/text.js +89 -0
  323. package/dist/tui/components/truncated-text.js +51 -0
  324. package/dist/tui/editor-component.js +2 -0
  325. package/dist/tui/fuzzy.js +107 -0
  326. package/dist/tui/get-east-asian-width/index.js +32 -0
  327. package/dist/tui/get-east-asian-width/lookup.js +404 -0
  328. package/dist/tui/index.js +32 -0
  329. package/dist/tui/keybindings.js +114 -0
  330. package/dist/tui/keys.js +959 -0
  331. package/dist/tui/kill-ring.js +44 -0
  332. package/dist/tui/stdin-buffer.js +317 -0
  333. package/dist/tui/terminal-image.js +288 -0
  334. package/dist/tui/terminal.js +249 -0
  335. package/dist/tui/tui/autocomplete.js +596 -0
  336. package/dist/tui/tui/components/box.js +106 -0
  337. package/dist/tui/tui/components/cancellable-loader.js +35 -0
  338. package/dist/tui/tui/components/editor.js +1679 -0
  339. package/dist/tui/tui/components/image.js +69 -0
  340. package/dist/tui/tui/components/input.js +433 -0
  341. package/dist/tui/tui/components/loader.js +49 -0
  342. package/dist/tui/tui/components/markdown.js +629 -0
  343. package/dist/tui/tui/components/select-list.js +152 -0
  344. package/dist/tui/tui/components/settings-list.js +185 -0
  345. package/dist/tui/tui/components/spacer.js +23 -0
  346. package/dist/tui/tui/components/text.js +91 -0
  347. package/dist/tui/tui/components/truncated-text.js +51 -0
  348. package/dist/tui/tui/editor-component.js +2 -0
  349. package/dist/tui/tui/fuzzy.js +107 -0
  350. package/dist/tui/tui/get-east-asian-width/index.js +32 -0
  351. package/dist/tui/tui/get-east-asian-width/lookup.js +404 -0
  352. package/dist/tui/tui/index.js +32 -0
  353. package/dist/tui/tui/keybindings.js +114 -0
  354. package/dist/tui/tui/keys.js +959 -0
  355. package/dist/tui/tui/kill-ring.js +44 -0
  356. package/dist/tui/tui/stdin-buffer.js +317 -0
  357. package/dist/tui/tui/terminal-image.js +288 -0
  358. package/dist/tui/tui/terminal.js +249 -0
  359. package/dist/tui/tui/tui.js +955 -0
  360. package/dist/tui/tui/undo-stack.js +25 -0
  361. package/dist/tui/tui/utils.js +800 -0
  362. package/dist/tui/tui.js +955 -0
  363. package/dist/tui/undo-stack.js +25 -0
  364. package/dist/tui/utils.js +800 -0
  365. package/dist/utils/changelog.js +87 -0
  366. package/dist/utils/clipboard-image.js +164 -0
  367. package/dist/utils/clipboard-native.js +14 -0
  368. package/dist/utils/clipboard.js +67 -0
  369. package/dist/utils/frontmatter.js +26 -0
  370. package/dist/utils/git.js +166 -0
  371. package/dist/utils/image-convert.js +35 -0
  372. package/dist/utils/image-resize.js +183 -0
  373. package/dist/utils/mime.js +26 -0
  374. package/dist/utils/photon.js +121 -0
  375. package/dist/utils/shell.js +217 -0
  376. package/dist/utils/sleep.js +17 -0
  377. package/dist/utils/tools-manager.js +259 -0
  378. package/package.json +78 -0
  379. package/skills/excel-com-api/SKILL.md +74 -0
  380. package/skills/excel-com-api/excel-type-library.py +27767 -0
  381. package/skills/excel-com-api/office-type-library.py +10867 -0
  382. package/skills/integrations/SKILL.md +138 -0
  383. package/skills/integrations/alphasense.md +457 -0
  384. package/skills/integrations/bloomberg.md +803 -0
  385. package/skills/integrations/calcbench.md +315 -0
  386. package/skills/integrations/capiq.md +848 -0
  387. package/skills/integrations/dynamics-365-finance.md +354 -0
  388. package/skills/integrations/earnings_transcripts.md +387 -0
  389. package/skills/integrations/factset.md +758 -0
  390. package/skills/integrations/ice-fixed-income.md +344 -0
  391. package/skills/integrations/moodys-analytics.md +313 -0
  392. package/skills/integrations/morningstar.md +433 -0
  393. package/skills/integrations/nasdaq-data-link.md +249 -0
  394. package/skills/integrations/pitchbook.md +413 -0
  395. package/skills/integrations/preqin.md +422 -0
  396. package/skills/integrations/quickbooks.md +289 -0
  397. package/skills/integrations/quickfs.md +314 -0
  398. package/skills/integrations/refinitiv.md +473 -0
  399. package/skills/integrations/sage-intacct.md +401 -0
  400. package/skills/integrations/visible-alpha.md +320 -0
  401. package/skills/integrations/xero.md +393 -0
  402. package/skills/integrations/ycharts.md +306 -0
  403. package/skills/pdf-creation/SKILL.md +93 -0
  404. package/skills/pdf-extraction/SKILL.md +32 -0
  405. package/skills/powerpoint-creation/SKILL.md +110 -0
  406. package/skills/sec-edgar/SKILL.md +127 -0
  407. package/skills/sec-edgar/sec_to_pdf.py +109 -0
  408. package/xll/ShortcutXL.xll +0 -0
  409. package/xll/modules/debug_render.py +272 -0
  410. package/xll/modules/gameboy.py +241 -0
  411. package/xll/modules/pong.py +188 -0
  412. package/xll/modules/shortcut_xl/__init__.py +18 -0
  413. package/xll/modules/shortcut_xl/_categorize.py +200 -0
  414. package/xll/modules/shortcut_xl/_com.py +108 -0
  415. package/xll/modules/shortcut_xl/_format.py +252 -0
  416. package/xll/modules/shortcut_xl/_log.py +12 -0
  417. package/xll/modules/shortcut_xl/_managed.py +116 -0
  418. package/xll/modules/shortcut_xl/_registry.py +44 -0
  419. package/xll/modules/shortcut_xl/_threading.py +161 -0
  420. package/xll/modules/shortcut_xl/_tracking.py +283 -0
  421. package/xll/modules/stocks.py +100 -0
  422. package/xll/python3.dll +0 -0
  423. package/xll/python312.dll +0 -0
@@ -0,0 +1,860 @@
1
+ import { Container, getEditorKeybindings, Input, matchesKey, Spacer, Text, truncateToWidth, visibleWidth } from '../../../tui/index.js';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ import { unlink } from 'node:fs/promises';
5
+ import * as os from 'node:os';
6
+ import { KeybindingsManager } from '../../../core/keybindings.js';
7
+ import { theme } from '../../../core/theme.js';
8
+ import { DynamicBorder } from './dynamic-border.js';
9
+ import { appKey, appKeyHint, keyHint } from './keybinding-hints.js';
10
+ import { filterAndSortSessions, hasSessionName } from './session-selector-search.js';
11
+ function shortenPath(path) {
12
+ const home = os.homedir();
13
+ if (!path)
14
+ return path;
15
+ if (path.startsWith(home)) {
16
+ return `~${path.slice(home.length)}`;
17
+ }
18
+ return path;
19
+ }
20
+ function formatSessionDate(date) {
21
+ const now = new Date();
22
+ const diffMs = now.getTime() - date.getTime();
23
+ const diffMins = Math.floor(diffMs / 60000);
24
+ const diffHours = Math.floor(diffMs / 3600000);
25
+ const diffDays = Math.floor(diffMs / 86400000);
26
+ if (diffMins < 1)
27
+ return 'now';
28
+ if (diffMins < 60)
29
+ return `${diffMins}m`;
30
+ if (diffHours < 24)
31
+ return `${diffHours}h`;
32
+ if (diffDays < 7)
33
+ return `${diffDays}d`;
34
+ if (diffDays < 30)
35
+ return `${Math.floor(diffDays / 7)}w`;
36
+ if (diffDays < 365)
37
+ return `${Math.floor(diffDays / 30)}mo`;
38
+ return `${Math.floor(diffDays / 365)}y`;
39
+ }
40
+ class SessionSelectorHeader {
41
+ scope;
42
+ sortMode;
43
+ nameFilter;
44
+ keybindings;
45
+ requestRender;
46
+ loading = false;
47
+ loadProgress = null;
48
+ showPath = false;
49
+ confirmingDeletePath = null;
50
+ statusMessage = null;
51
+ statusTimeout = null;
52
+ showRenameHint = false;
53
+ constructor(scope, sortMode, nameFilter, keybindings, requestRender) {
54
+ this.scope = scope;
55
+ this.sortMode = sortMode;
56
+ this.nameFilter = nameFilter;
57
+ this.keybindings = keybindings;
58
+ this.requestRender = requestRender;
59
+ }
60
+ setScope(scope) {
61
+ this.scope = scope;
62
+ }
63
+ setSortMode(sortMode) {
64
+ this.sortMode = sortMode;
65
+ }
66
+ setNameFilter(nameFilter) {
67
+ this.nameFilter = nameFilter;
68
+ }
69
+ setLoading(loading) {
70
+ this.loading = loading;
71
+ // Progress is scoped to the current load; clear whenever the loading state is set
72
+ this.loadProgress = null;
73
+ }
74
+ setProgress(loaded, total) {
75
+ this.loadProgress = { loaded, total };
76
+ }
77
+ setShowPath(showPath) {
78
+ this.showPath = showPath;
79
+ }
80
+ setShowRenameHint(show) {
81
+ this.showRenameHint = show;
82
+ }
83
+ setConfirmingDeletePath(path) {
84
+ this.confirmingDeletePath = path;
85
+ }
86
+ clearStatusTimeout() {
87
+ if (!this.statusTimeout)
88
+ return;
89
+ clearTimeout(this.statusTimeout);
90
+ this.statusTimeout = null;
91
+ }
92
+ setStatusMessage(msg, autoHideMs) {
93
+ this.clearStatusTimeout();
94
+ this.statusMessage = msg;
95
+ if (!msg || !autoHideMs)
96
+ return;
97
+ this.statusTimeout = setTimeout(() => {
98
+ this.statusMessage = null;
99
+ this.statusTimeout = null;
100
+ this.requestRender();
101
+ }, autoHideMs);
102
+ }
103
+ invalidate() { }
104
+ render(width) {
105
+ const title = this.scope === 'current' ? 'Resume Session (Current Folder)' : 'Resume Session (All)';
106
+ const leftText = theme.bold(title);
107
+ const sortLabel = this.sortMode === 'threaded' ? 'Threaded' : this.sortMode === 'recent' ? 'Recent' : 'Fuzzy';
108
+ const sortText = theme.fg('muted', 'Sort: ') + theme.fg('accent', sortLabel);
109
+ const nameLabel = this.nameFilter === 'all' ? 'All' : 'Named';
110
+ const nameText = theme.fg('muted', 'Name: ') + theme.fg('accent', nameLabel);
111
+ let scopeText;
112
+ if (this.loading) {
113
+ const progressText = this.loadProgress
114
+ ? `${this.loadProgress.loaded}/${this.loadProgress.total}`
115
+ : '...';
116
+ scopeText = `${theme.fg('muted', '○ Current Folder | ')}${theme.fg('accent', `Loading ${progressText}`)}`;
117
+ }
118
+ else if (this.scope === 'current') {
119
+ scopeText = `${theme.fg('accent', '◉ Current Folder')}${theme.fg('muted', ' | ○ All')}`;
120
+ }
121
+ else {
122
+ scopeText = `${theme.fg('muted', '○ Current Folder | ')}${theme.fg('accent', '◉ All')}`;
123
+ }
124
+ const rightText = truncateToWidth(`${scopeText} ${nameText} ${sortText}`, width, '');
125
+ const availableLeft = Math.max(0, width - visibleWidth(rightText) - 1);
126
+ const left = truncateToWidth(leftText, availableLeft, '');
127
+ const spacing = Math.max(0, width - visibleWidth(left) - visibleWidth(rightText));
128
+ // Build hint lines - changes based on state (all branches truncate to width)
129
+ let hintLine1;
130
+ let hintLine2;
131
+ if (this.confirmingDeletePath !== null) {
132
+ const confirmHint = 'Delete session? [Enter] confirm · [Esc/Ctrl+C] cancel';
133
+ hintLine1 = theme.fg('error', truncateToWidth(confirmHint, width, '…'));
134
+ hintLine2 = '';
135
+ }
136
+ else if (this.statusMessage) {
137
+ const color = this.statusMessage.type === 'error' ? 'error' : 'accent';
138
+ hintLine1 = theme.fg(color, truncateToWidth(this.statusMessage.message, width, '…'));
139
+ hintLine2 = '';
140
+ }
141
+ else {
142
+ const pathState = this.showPath ? '(on)' : '(off)';
143
+ const sep = theme.fg('muted', ' · ');
144
+ const hint1 = keyHint('tab', 'scope') + sep + theme.fg('muted', 're:<pattern> regex · "phrase" exact');
145
+ const hint2Parts = [
146
+ keyHint('toggleSessionSort', 'sort'),
147
+ appKeyHint(this.keybindings, 'toggleSessionNamedFilter', 'named'),
148
+ keyHint('deleteSession', 'delete'),
149
+ keyHint('toggleSessionPath', `path ${pathState}`)
150
+ ];
151
+ if (this.showRenameHint) {
152
+ hint2Parts.push(keyHint('renameSession', 'rename'));
153
+ }
154
+ const hint2 = hint2Parts.join(sep);
155
+ hintLine1 = truncateToWidth(hint1, width, '…');
156
+ hintLine2 = truncateToWidth(hint2, width, '…');
157
+ }
158
+ return [`${left}${' '.repeat(spacing)}${rightText}`, hintLine1, hintLine2];
159
+ }
160
+ }
161
+ /**
162
+ * Build a tree structure from sessions based on parentSessionPath.
163
+ * Returns root nodes sorted by modified date (descending).
164
+ */
165
+ function buildSessionTree(sessions) {
166
+ const byPath = new Map();
167
+ for (const session of sessions) {
168
+ byPath.set(session.path, { session, children: [] });
169
+ }
170
+ const roots = [];
171
+ for (const session of sessions) {
172
+ const node = byPath.get(session.path);
173
+ const parentPath = session.parentSessionPath;
174
+ if (parentPath && byPath.has(parentPath)) {
175
+ byPath.get(parentPath).children.push(node);
176
+ }
177
+ else {
178
+ roots.push(node);
179
+ }
180
+ }
181
+ // Sort children and roots by modified date (descending)
182
+ const sortNodes = (nodes) => {
183
+ nodes.sort((a, b) => b.session.modified.getTime() - a.session.modified.getTime());
184
+ for (const node of nodes) {
185
+ sortNodes(node.children);
186
+ }
187
+ };
188
+ sortNodes(roots);
189
+ return roots;
190
+ }
191
+ /**
192
+ * Flatten tree into display list with tree structure metadata.
193
+ */
194
+ function flattenSessionTree(roots) {
195
+ const result = [];
196
+ const walk = (node, depth, ancestorContinues, isLast) => {
197
+ result.push({ session: node.session, depth, isLast, ancestorContinues });
198
+ for (let i = 0; i < node.children.length; i++) {
199
+ const childIsLast = i === node.children.length - 1;
200
+ // Only show continuation line for non-root ancestors
201
+ const continues = depth > 0 ? !isLast : false;
202
+ walk(node.children[i], depth + 1, [...ancestorContinues, continues], childIsLast);
203
+ }
204
+ };
205
+ for (let i = 0; i < roots.length; i++) {
206
+ walk(roots[i], 0, [], i === roots.length - 1);
207
+ }
208
+ return result;
209
+ }
210
+ /**
211
+ * Custom session list component with multi-line items and search
212
+ */
213
+ class SessionList {
214
+ getSelectedSessionPath() {
215
+ const selected = this.filteredSessions[this.selectedIndex];
216
+ return selected?.session.path;
217
+ }
218
+ allSessions = [];
219
+ filteredSessions = [];
220
+ selectedIndex = 0;
221
+ searchInput;
222
+ showCwd = false;
223
+ sortMode = 'threaded';
224
+ nameFilter = 'all';
225
+ keybindings;
226
+ showPath = false;
227
+ confirmingDeletePath = null;
228
+ currentSessionFilePath;
229
+ onSelect;
230
+ onCancel;
231
+ onExit = () => { };
232
+ onToggleScope;
233
+ onToggleSort;
234
+ onToggleNameFilter;
235
+ onTogglePath;
236
+ onDeleteConfirmationChange;
237
+ onDeleteSession;
238
+ onRenameSession;
239
+ onError;
240
+ maxVisible = 10; // Max sessions visible (one line each)
241
+ // Focusable implementation - propagate to searchInput for IME cursor positioning
242
+ _focused = false;
243
+ get focused() {
244
+ return this._focused;
245
+ }
246
+ set focused(value) {
247
+ this._focused = value;
248
+ this.searchInput.focused = value;
249
+ }
250
+ constructor(sessions, showCwd, sortMode, nameFilter, keybindings, currentSessionFilePath) {
251
+ this.allSessions = sessions;
252
+ this.filteredSessions = [];
253
+ this.searchInput = new Input();
254
+ this.showCwd = showCwd;
255
+ this.sortMode = sortMode;
256
+ this.nameFilter = nameFilter;
257
+ this.keybindings = keybindings;
258
+ this.currentSessionFilePath = currentSessionFilePath;
259
+ this.filterSessions('');
260
+ // Handle Enter in search input - select current item
261
+ this.searchInput.onSubmit = () => {
262
+ if (this.filteredSessions[this.selectedIndex]) {
263
+ const selected = this.filteredSessions[this.selectedIndex];
264
+ if (this.onSelect) {
265
+ this.onSelect(selected.session.path);
266
+ }
267
+ }
268
+ };
269
+ }
270
+ setSortMode(sortMode) {
271
+ this.sortMode = sortMode;
272
+ this.filterSessions(this.searchInput.getValue());
273
+ }
274
+ setNameFilter(nameFilter) {
275
+ this.nameFilter = nameFilter;
276
+ this.filterSessions(this.searchInput.getValue());
277
+ }
278
+ setSessions(sessions, showCwd) {
279
+ this.allSessions = sessions;
280
+ this.showCwd = showCwd;
281
+ this.filterSessions(this.searchInput.getValue());
282
+ }
283
+ filterSessions(query) {
284
+ const trimmed = query.trim();
285
+ const nameFiltered = this.nameFilter === 'all'
286
+ ? this.allSessions
287
+ : this.allSessions.filter((session) => hasSessionName(session));
288
+ if (this.sortMode === 'threaded' && !trimmed) {
289
+ // Threaded mode without search: show tree structure
290
+ const roots = buildSessionTree(nameFiltered);
291
+ this.filteredSessions = flattenSessionTree(roots);
292
+ }
293
+ else {
294
+ // Other modes or with search: flat list
295
+ const filtered = filterAndSortSessions(nameFiltered, query, this.sortMode, 'all');
296
+ this.filteredSessions = filtered.map((session) => ({
297
+ session,
298
+ depth: 0,
299
+ isLast: true,
300
+ ancestorContinues: []
301
+ }));
302
+ }
303
+ this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredSessions.length - 1));
304
+ }
305
+ setConfirmingDeletePath(path) {
306
+ this.confirmingDeletePath = path;
307
+ this.onDeleteConfirmationChange?.(path);
308
+ }
309
+ startDeleteConfirmationForSelectedSession() {
310
+ const selected = this.filteredSessions[this.selectedIndex];
311
+ if (!selected)
312
+ return;
313
+ // Prevent deleting current session
314
+ if (this.currentSessionFilePath && selected.session.path === this.currentSessionFilePath) {
315
+ this.onError?.('Cannot delete the currently active session');
316
+ return;
317
+ }
318
+ this.setConfirmingDeletePath(selected.session.path);
319
+ }
320
+ invalidate() { }
321
+ render(width) {
322
+ const lines = [];
323
+ // Render search input
324
+ lines.push(...this.searchInput.render(width));
325
+ lines.push(''); // Blank line after search
326
+ if (this.filteredSessions.length === 0) {
327
+ let emptyMessage;
328
+ if (this.nameFilter === 'named') {
329
+ const toggleKey = appKey(this.keybindings, 'toggleSessionNamedFilter');
330
+ if (this.showCwd) {
331
+ emptyMessage = ` No named sessions found. Press ${toggleKey} to show all.`;
332
+ }
333
+ else {
334
+ emptyMessage = ` No named sessions in current folder. Press ${toggleKey} to show all, or Tab to view all.`;
335
+ }
336
+ }
337
+ else if (this.showCwd) {
338
+ // "All" scope - no sessions anywhere that match filter
339
+ emptyMessage = ' No sessions found';
340
+ }
341
+ else {
342
+ // "Current folder" scope - hint to try "all"
343
+ emptyMessage = ' No sessions in current folder. Press Tab to view all.';
344
+ }
345
+ lines.push(theme.fg('muted', truncateToWidth(emptyMessage, width, '…')));
346
+ return lines;
347
+ }
348
+ // Calculate visible range with scrolling
349
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredSessions.length - this.maxVisible));
350
+ const endIndex = Math.min(startIndex + this.maxVisible, this.filteredSessions.length);
351
+ // Render visible sessions (one line each with tree structure)
352
+ for (let i = startIndex; i < endIndex; i++) {
353
+ const node = this.filteredSessions[i];
354
+ const session = node.session;
355
+ const isSelected = i === this.selectedIndex;
356
+ const isConfirmingDelete = session.path === this.confirmingDeletePath;
357
+ const isCurrent = this.currentSessionFilePath === session.path;
358
+ // Build tree prefix
359
+ const prefix = this.buildTreePrefix(node);
360
+ // Session display text (name or first message)
361
+ const hasName = !!session.name;
362
+ const displayText = session.name ?? session.lastMessage;
363
+ const normalizedMessage = displayText.replace(/\n/g, ' ').trim();
364
+ // Right side: message count and age
365
+ const age = formatSessionDate(session.modified);
366
+ const msgCount = String(session.messageCount);
367
+ let rightPart = `${msgCount} ${age}`;
368
+ if (this.showCwd && session.cwd) {
369
+ rightPart = `${shortenPath(session.cwd)} ${rightPart}`;
370
+ }
371
+ if (this.showPath) {
372
+ rightPart = `${shortenPath(session.path)} ${rightPart}`;
373
+ }
374
+ // Cursor
375
+ const cursor = isSelected ? theme.fg('accent', '› ') : ' ';
376
+ // Calculate available width for message
377
+ const prefixWidth = visibleWidth(prefix);
378
+ const rightWidth = visibleWidth(rightPart) + 2; // +2 for spacing
379
+ const availableForMsg = width - 2 - prefixWidth - rightWidth; // -2 for cursor
380
+ const truncatedMsg = truncateToWidth(normalizedMessage, Math.max(10, availableForMsg), '…');
381
+ // Style message
382
+ let messageColor = null;
383
+ if (isConfirmingDelete) {
384
+ messageColor = 'error';
385
+ }
386
+ else if (isCurrent) {
387
+ messageColor = 'accent';
388
+ }
389
+ else if (hasName) {
390
+ messageColor = 'warning';
391
+ }
392
+ let styledMsg = messageColor ? theme.fg(messageColor, truncatedMsg) : truncatedMsg;
393
+ if (isSelected) {
394
+ styledMsg = theme.bold(styledMsg);
395
+ }
396
+ // Build line
397
+ const leftPart = cursor + theme.fg('dim', prefix) + styledMsg;
398
+ const leftWidth = visibleWidth(leftPart);
399
+ const spacing = Math.max(1, width - leftWidth - visibleWidth(rightPart));
400
+ const styledRight = theme.fg(isConfirmingDelete ? 'error' : 'dim', rightPart);
401
+ let line = leftPart + ' '.repeat(spacing) + styledRight;
402
+ if (isSelected) {
403
+ line = theme.bg('selectedBg', line);
404
+ }
405
+ lines.push(truncateToWidth(line, width));
406
+ }
407
+ // Add scroll indicator if needed
408
+ if (startIndex > 0 || endIndex < this.filteredSessions.length) {
409
+ const scrollText = ` (${this.selectedIndex + 1}/${this.filteredSessions.length})`;
410
+ const scrollInfo = theme.fg('muted', truncateToWidth(scrollText, width, ''));
411
+ lines.push(scrollInfo);
412
+ }
413
+ return lines;
414
+ }
415
+ buildTreePrefix(node) {
416
+ if (node.depth === 0) {
417
+ return '';
418
+ }
419
+ const parts = node.ancestorContinues.map((continues) => (continues ? '│ ' : ' '));
420
+ const branch = node.isLast ? '└─ ' : '├─ ';
421
+ return parts.join('') + branch;
422
+ }
423
+ handleInput(keyData) {
424
+ const kb = getEditorKeybindings();
425
+ // Handle delete confirmation state first - intercept all keys
426
+ if (this.confirmingDeletePath !== null) {
427
+ if (kb.matches(keyData, 'selectConfirm')) {
428
+ const pathToDelete = this.confirmingDeletePath;
429
+ this.setConfirmingDeletePath(null);
430
+ void this.onDeleteSession?.(pathToDelete);
431
+ return;
432
+ }
433
+ // Allow both Escape and Ctrl+C to cancel (consistent with pi UX)
434
+ if (kb.matches(keyData, 'selectCancel') || matchesKey(keyData, 'ctrl+c')) {
435
+ this.setConfirmingDeletePath(null);
436
+ return;
437
+ }
438
+ // Ignore all other keys while confirming
439
+ return;
440
+ }
441
+ if (kb.matches(keyData, 'tab')) {
442
+ if (this.onToggleScope) {
443
+ this.onToggleScope();
444
+ }
445
+ return;
446
+ }
447
+ if (kb.matches(keyData, 'toggleSessionSort')) {
448
+ this.onToggleSort?.();
449
+ return;
450
+ }
451
+ if (this.keybindings.matches(keyData, 'toggleSessionNamedFilter')) {
452
+ this.onToggleNameFilter?.();
453
+ return;
454
+ }
455
+ // Ctrl+P: toggle path display
456
+ if (kb.matches(keyData, 'toggleSessionPath')) {
457
+ this.showPath = !this.showPath;
458
+ this.onTogglePath?.(this.showPath);
459
+ return;
460
+ }
461
+ // Ctrl+D: initiate delete confirmation (useful on terminals that don't distinguish Ctrl+Backspace from Backspace)
462
+ if (kb.matches(keyData, 'deleteSession')) {
463
+ this.startDeleteConfirmationForSelectedSession();
464
+ return;
465
+ }
466
+ // Ctrl+R: rename selected session
467
+ if (matchesKey(keyData, 'ctrl+r')) {
468
+ const selected = this.filteredSessions[this.selectedIndex];
469
+ if (selected) {
470
+ this.onRenameSession?.(selected.session.path);
471
+ }
472
+ return;
473
+ }
474
+ // Ctrl+Backspace: non-invasive convenience alias for delete
475
+ // Only triggers deletion when the query is empty; otherwise it is forwarded to the input
476
+ if (kb.matches(keyData, 'deleteSessionNoninvasive')) {
477
+ if (this.searchInput.getValue().length > 0) {
478
+ this.searchInput.handleInput(keyData);
479
+ this.filterSessions(this.searchInput.getValue());
480
+ return;
481
+ }
482
+ this.startDeleteConfirmationForSelectedSession();
483
+ return;
484
+ }
485
+ // Up arrow
486
+ if (kb.matches(keyData, 'selectUp')) {
487
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
488
+ }
489
+ // Down arrow
490
+ else if (kb.matches(keyData, 'selectDown')) {
491
+ this.selectedIndex = Math.min(this.filteredSessions.length - 1, this.selectedIndex + 1);
492
+ }
493
+ // Page up - jump up by maxVisible items
494
+ else if (kb.matches(keyData, 'selectPageUp')) {
495
+ this.selectedIndex = Math.max(0, this.selectedIndex - this.maxVisible);
496
+ }
497
+ // Page down - jump down by maxVisible items
498
+ else if (kb.matches(keyData, 'selectPageDown')) {
499
+ this.selectedIndex = Math.min(this.filteredSessions.length - 1, this.selectedIndex + this.maxVisible);
500
+ }
501
+ // Enter
502
+ else if (kb.matches(keyData, 'selectConfirm')) {
503
+ const selected = this.filteredSessions[this.selectedIndex];
504
+ if (selected && this.onSelect) {
505
+ this.onSelect(selected.session.path);
506
+ }
507
+ }
508
+ // Escape - cancel
509
+ else if (kb.matches(keyData, 'selectCancel')) {
510
+ if (this.onCancel) {
511
+ this.onCancel();
512
+ }
513
+ }
514
+ // Pass everything else to search input
515
+ else {
516
+ this.searchInput.handleInput(keyData);
517
+ this.filterSessions(this.searchInput.getValue());
518
+ }
519
+ }
520
+ }
521
+ /**
522
+ * Delete a session file, trying the `trash` CLI first, then falling back to unlink
523
+ */
524
+ async function deleteSessionFile(sessionPath) {
525
+ // Try `trash` first (if installed)
526
+ const trashArgs = sessionPath.startsWith('-') ? ['--', sessionPath] : [sessionPath];
527
+ const trashResult = spawnSync('trash', trashArgs, { encoding: 'utf-8' });
528
+ const getTrashErrorHint = () => {
529
+ const parts = [];
530
+ if (trashResult.error) {
531
+ parts.push(trashResult.error.message);
532
+ }
533
+ const stderr = trashResult.stderr?.trim();
534
+ if (stderr) {
535
+ parts.push(stderr.split('\n')[0] ?? stderr);
536
+ }
537
+ if (parts.length === 0)
538
+ return null;
539
+ return `trash: ${parts.join(' · ').slice(0, 200)}`;
540
+ };
541
+ // If trash reports success, or the file is gone afterwards, treat it as successful
542
+ if (trashResult.status === 0 || !existsSync(sessionPath)) {
543
+ return { ok: true, method: 'trash' };
544
+ }
545
+ // Fallback to permanent deletion
546
+ try {
547
+ await unlink(sessionPath);
548
+ return { ok: true, method: 'unlink' };
549
+ }
550
+ catch (err) {
551
+ const unlinkError = err instanceof Error ? err.message : String(err);
552
+ const trashErrorHint = getTrashErrorHint();
553
+ const error = trashErrorHint ? `${unlinkError} (${trashErrorHint})` : unlinkError;
554
+ return { ok: false, method: 'unlink', error };
555
+ }
556
+ }
557
+ /**
558
+ * Component that renders a session selector
559
+ */
560
+ export class SessionSelectorComponent extends Container {
561
+ handleInput(data) {
562
+ if (this.mode === 'rename') {
563
+ const kb = getEditorKeybindings();
564
+ if (kb.matches(data, 'selectCancel') || matchesKey(data, 'ctrl+c')) {
565
+ this.exitRenameMode();
566
+ return;
567
+ }
568
+ this.renameInput.handleInput(data);
569
+ return;
570
+ }
571
+ this.sessionList.handleInput(data);
572
+ }
573
+ canRename = true;
574
+ sessionList;
575
+ header;
576
+ keybindings;
577
+ scope = 'current';
578
+ sortMode = 'threaded';
579
+ nameFilter = 'all';
580
+ currentSessions = null;
581
+ allSessions = null;
582
+ currentSessionsLoader;
583
+ allSessionsLoader;
584
+ onCancel;
585
+ requestRender;
586
+ renameSession;
587
+ currentLoading = false;
588
+ allLoading = false;
589
+ allLoadSeq = 0;
590
+ mode = 'list';
591
+ renameInput = new Input();
592
+ renameTargetPath = null;
593
+ // Focusable implementation - propagate to sessionList for IME cursor positioning
594
+ _focused = false;
595
+ get focused() {
596
+ return this._focused;
597
+ }
598
+ set focused(value) {
599
+ this._focused = value;
600
+ this.sessionList.focused = value;
601
+ this.renameInput.focused = value;
602
+ if (value && this.mode === 'rename') {
603
+ this.renameInput.focused = true;
604
+ }
605
+ }
606
+ buildBaseLayout(content, options) {
607
+ this.clear();
608
+ this.addChild(new Spacer(1));
609
+ this.addChild(new DynamicBorder((s) => theme.fg('accent', s)));
610
+ this.addChild(new Spacer(1));
611
+ if (options?.showHeader ?? true) {
612
+ this.addChild(this.header);
613
+ this.addChild(new Spacer(1));
614
+ }
615
+ this.addChild(content);
616
+ this.addChild(new Spacer(1));
617
+ this.addChild(new DynamicBorder((s) => theme.fg('accent', s)));
618
+ }
619
+ constructor(currentSessionsLoader, allSessionsLoader, onSelect, onCancel, onExit, requestRender, options, currentSessionFilePath) {
620
+ super();
621
+ this.keybindings = options?.keybindings ?? KeybindingsManager.create();
622
+ this.currentSessionsLoader = currentSessionsLoader;
623
+ this.allSessionsLoader = allSessionsLoader;
624
+ this.onCancel = onCancel;
625
+ this.requestRender = requestRender;
626
+ this.header = new SessionSelectorHeader(this.scope, this.sortMode, this.nameFilter, this.keybindings, this.requestRender);
627
+ const renameSession = options?.renameSession;
628
+ this.renameSession = renameSession;
629
+ this.canRename = !!renameSession;
630
+ this.header.setShowRenameHint(options?.showRenameHint ?? this.canRename);
631
+ // Create session list (starts empty, will be populated after load)
632
+ this.sessionList = new SessionList([], false, this.sortMode, this.nameFilter, this.keybindings, currentSessionFilePath);
633
+ this.buildBaseLayout(this.sessionList);
634
+ this.renameInput.onSubmit = (value) => {
635
+ void this.confirmRename(value);
636
+ };
637
+ // Ensure header status timeouts are cleared when leaving the selector
638
+ const clearStatusMessage = () => this.header.setStatusMessage(null);
639
+ this.sessionList.onSelect = (sessionPath) => {
640
+ clearStatusMessage();
641
+ onSelect(sessionPath);
642
+ };
643
+ this.sessionList.onCancel = () => {
644
+ clearStatusMessage();
645
+ onCancel();
646
+ };
647
+ this.sessionList.onExit = () => {
648
+ clearStatusMessage();
649
+ onExit();
650
+ };
651
+ this.sessionList.onToggleScope = () => this.toggleScope();
652
+ this.sessionList.onToggleSort = () => this.toggleSortMode();
653
+ this.sessionList.onToggleNameFilter = () => this.toggleNameFilter();
654
+ this.sessionList.onRenameSession = (sessionPath) => {
655
+ if (!renameSession)
656
+ return;
657
+ if (this.scope === 'current' && this.currentLoading)
658
+ return;
659
+ if (this.scope === 'all' && this.allLoading)
660
+ return;
661
+ const sessions = this.scope === 'all' ? (this.allSessions ?? []) : (this.currentSessions ?? []);
662
+ const session = sessions.find((s) => s.path === sessionPath);
663
+ this.enterRenameMode(sessionPath, session?.name);
664
+ };
665
+ // Sync list events to header
666
+ this.sessionList.onTogglePath = (showPath) => {
667
+ this.header.setShowPath(showPath);
668
+ this.requestRender();
669
+ };
670
+ this.sessionList.onDeleteConfirmationChange = (path) => {
671
+ this.header.setConfirmingDeletePath(path);
672
+ this.requestRender();
673
+ };
674
+ this.sessionList.onError = (msg) => {
675
+ this.header.setStatusMessage({ type: 'error', message: msg }, 3000);
676
+ this.requestRender();
677
+ };
678
+ // Handle session deletion
679
+ this.sessionList.onDeleteSession = async (sessionPath) => {
680
+ const result = await deleteSessionFile(sessionPath);
681
+ if (result.ok) {
682
+ if (this.currentSessions) {
683
+ this.currentSessions = this.currentSessions.filter((s) => s.path !== sessionPath);
684
+ }
685
+ if (this.allSessions) {
686
+ this.allSessions = this.allSessions.filter((s) => s.path !== sessionPath);
687
+ }
688
+ const sessions = this.scope === 'all' ? (this.allSessions ?? []) : (this.currentSessions ?? []);
689
+ const showCwd = this.scope === 'all';
690
+ this.sessionList.setSessions(sessions, showCwd);
691
+ const msg = result.method === 'trash' ? 'Session moved to trash' : 'Session deleted';
692
+ this.header.setStatusMessage({ type: 'info', message: msg }, 2000);
693
+ await this.refreshSessionsAfterMutation();
694
+ }
695
+ else {
696
+ const errorMessage = result.error ?? 'Unknown error';
697
+ this.header.setStatusMessage({ type: 'error', message: `Failed to delete: ${errorMessage}` }, 3000);
698
+ }
699
+ this.requestRender();
700
+ };
701
+ // Start loading current sessions immediately
702
+ this.loadCurrentSessions();
703
+ }
704
+ loadCurrentSessions() {
705
+ void this.loadScope('current', 'initial');
706
+ }
707
+ enterRenameMode(sessionPath, currentName) {
708
+ this.mode = 'rename';
709
+ this.renameTargetPath = sessionPath;
710
+ this.renameInput.setValue(currentName ?? '');
711
+ this.renameInput.focused = true;
712
+ const panel = new Container();
713
+ panel.addChild(new Text(theme.bold('Rename Session'), 1, 0));
714
+ panel.addChild(new Spacer(1));
715
+ panel.addChild(this.renameInput);
716
+ panel.addChild(new Spacer(1));
717
+ panel.addChild(new Text(theme.fg('muted', 'Enter to save · Esc/Ctrl+C to cancel'), 1, 0));
718
+ this.buildBaseLayout(panel, { showHeader: false });
719
+ this.requestRender();
720
+ }
721
+ exitRenameMode() {
722
+ this.mode = 'list';
723
+ this.renameTargetPath = null;
724
+ this.buildBaseLayout(this.sessionList);
725
+ this.requestRender();
726
+ }
727
+ async confirmRename(value) {
728
+ const next = value.trim();
729
+ if (!next)
730
+ return;
731
+ const target = this.renameTargetPath;
732
+ if (!target) {
733
+ this.exitRenameMode();
734
+ return;
735
+ }
736
+ // Find current name for callback
737
+ const renameSession = this.renameSession;
738
+ if (!renameSession) {
739
+ this.exitRenameMode();
740
+ return;
741
+ }
742
+ try {
743
+ await renameSession(target, next);
744
+ await this.refreshSessionsAfterMutation();
745
+ }
746
+ finally {
747
+ this.exitRenameMode();
748
+ }
749
+ }
750
+ async loadScope(scope, reason) {
751
+ const showCwd = scope === 'all';
752
+ // Mark loading
753
+ if (scope === 'current') {
754
+ this.currentLoading = true;
755
+ }
756
+ else {
757
+ this.allLoading = true;
758
+ }
759
+ const seq = scope === 'all' ? ++this.allLoadSeq : undefined;
760
+ this.header.setScope(scope);
761
+ this.header.setLoading(true);
762
+ this.requestRender();
763
+ const onProgress = (loaded, total) => {
764
+ if (scope !== this.scope)
765
+ return;
766
+ if (seq !== undefined && seq !== this.allLoadSeq)
767
+ return;
768
+ this.header.setProgress(loaded, total);
769
+ this.requestRender();
770
+ };
771
+ try {
772
+ const sessions = await (scope === 'current'
773
+ ? this.currentSessionsLoader(onProgress)
774
+ : this.allSessionsLoader(onProgress));
775
+ if (scope === 'current') {
776
+ this.currentSessions = sessions;
777
+ this.currentLoading = false;
778
+ }
779
+ else {
780
+ this.allSessions = sessions;
781
+ this.allLoading = false;
782
+ }
783
+ if (scope !== this.scope)
784
+ return;
785
+ if (seq !== undefined && seq !== this.allLoadSeq)
786
+ return;
787
+ this.header.setLoading(false);
788
+ this.sessionList.setSessions(sessions, showCwd);
789
+ this.requestRender();
790
+ if (scope === 'all' && sessions.length === 0 && (this.currentSessions?.length ?? 0) === 0) {
791
+ this.onCancel();
792
+ }
793
+ }
794
+ catch (err) {
795
+ if (scope === 'current') {
796
+ this.currentLoading = false;
797
+ }
798
+ else {
799
+ this.allLoading = false;
800
+ }
801
+ if (scope !== this.scope)
802
+ return;
803
+ if (seq !== undefined && seq !== this.allLoadSeq)
804
+ return;
805
+ const message = err instanceof Error ? err.message : String(err);
806
+ this.header.setLoading(false);
807
+ this.header.setStatusMessage({ type: 'error', message: `Failed to load sessions: ${message}` }, 4000);
808
+ if (reason === 'initial') {
809
+ this.sessionList.setSessions([], showCwd);
810
+ }
811
+ this.requestRender();
812
+ }
813
+ }
814
+ toggleSortMode() {
815
+ // Cycle: threaded -> recent -> relevance -> threaded
816
+ this.sortMode =
817
+ this.sortMode === 'threaded'
818
+ ? 'recent'
819
+ : this.sortMode === 'recent'
820
+ ? 'relevance'
821
+ : 'threaded';
822
+ this.header.setSortMode(this.sortMode);
823
+ this.sessionList.setSortMode(this.sortMode);
824
+ this.requestRender();
825
+ }
826
+ toggleNameFilter() {
827
+ this.nameFilter = this.nameFilter === 'all' ? 'named' : 'all';
828
+ this.header.setNameFilter(this.nameFilter);
829
+ this.sessionList.setNameFilter(this.nameFilter);
830
+ this.requestRender();
831
+ }
832
+ async refreshSessionsAfterMutation() {
833
+ await this.loadScope(this.scope, 'refresh');
834
+ }
835
+ toggleScope() {
836
+ if (this.scope === 'current') {
837
+ this.scope = 'all';
838
+ this.header.setScope(this.scope);
839
+ if (this.allSessions !== null) {
840
+ this.header.setLoading(false);
841
+ this.sessionList.setSessions(this.allSessions, true);
842
+ this.requestRender();
843
+ return;
844
+ }
845
+ if (!this.allLoading) {
846
+ void this.loadScope('all', 'toggle');
847
+ }
848
+ return;
849
+ }
850
+ this.scope = 'current';
851
+ this.header.setScope(this.scope);
852
+ this.header.setLoading(this.currentLoading);
853
+ this.sessionList.setSessions(this.currentSessions ?? [], false);
854
+ this.requestRender();
855
+ }
856
+ getSessionList() {
857
+ return this.sessionList;
858
+ }
859
+ }
860
+ //# sourceMappingURL=session-selector.js.map